use of org.whole.lang.reflect.EntityDescriptor in project whole by wholeplatform.
the class EntityDescriptorEnumBuilder method addSimpleEntity.
// public void addSupertypes(String eType, String name, Set<String> supertypes) {
// if (supertypes.size()>1) {//!supertypes.isEmpty()) {
// ExpressionStatement expStm = etypeExpressionMap.get(eType);
// Expression edExp = expStm.getExpression();
//
// MethodInvocation nfd = newMethodInvocation("withSupertypes");
// expStm.setExpression(nfd);
// nfd.setExpression(edExp); // after unparenting edExp
//
// for (String sType : supertypes)
// if (!sType.equals(name))
// nfd.arguments().add(ast.newSimpleName(sType+"_ord"));
// }
// }
@SuppressWarnings("unchecked")
public void addSimpleEntity(String eName, String name, String eType, Set<String> modifiers, Set<String> allSubtypes) {
String eName_Ord = eName + "_ord";
String oldType = entities.put(eName, eType);
if (oldType == null) {
// public static final int [eName_ord] = [nextOrdinal];
FieldDeclaration fieldDecl = newFieldDeclaration("int", eName_Ord, newLiteral(nextOrdinal));
// assume ModifierKeyword.PRIVATE_KEYWORD
fieldDecl.modifiers().remove(0);
fieldDecl.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
fieldDecl.modifiers().add(ast.newModifier(ModifierKeyword.STATIC_KEYWORD));
fieldDecl.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD));
addBodyDeclaration(nextOrdinal++, fieldDecl);
// public static final EntityDescriptor<eName> [eName] = (EntityDescriptor<eName>) instance.valueOf([eName_ord]);
fieldDecl = newFieldDeclaration(newParameterizedType(EntityDescriptor.class.getName(), eName), newVariableDeclarationFragment(eName, newCastExpression(newParameterizedType(EntityDescriptor.class.getName(), eName), newMethodInvocation("instance", "valueOf", ast.newSimpleName(eName_Ord)))));
// assume ModifierKeyword.PRIVATE_KEYWORD
fieldDecl.modifiers().remove(0);
fieldDecl.modifiers().add(ast.newModifier(ModifierKeyword.PUBLIC_KEYWORD));
fieldDecl.modifiers().add(ast.newModifier(ModifierKeyword.STATIC_KEYWORD));
fieldDecl.modifiers().add(ast.newModifier(ModifierKeyword.FINAL_KEYWORD));
addBodyDeclaration(nextOrdinal * 2, fieldDecl);
} else if (oldType.equals(eType))
return;
// putSimpleEntity([eName_ord], "[eName]", [eType].class);
MethodInvocation callExp = newMethodInvocation("putSimpleEntity");
callExp.arguments().add(ast.newSimpleName(eName_Ord));
callExp.arguments().add(newLiteral(name));
if (!eName.equals(name))
callExp.arguments().add(newLiteral(eName));
callExp.arguments().add(newTypeLiteral(eType));
callExp.arguments().add(newLiteral(modifiers != null && modifiers.contains("ABSTRACT")));
if (!allSubtypes.isEmpty())
for (String type : allSubtypes) if (!type.equals(name))
callExp.arguments().add(ast.newSimpleName(type + "_ord"));
ExpressionStatement expStm = newExpressionStatement(callExp);
initEntityDescriptors.getBody().statements().add(expStm);
etypeExpressionMap.put(eType, expStm);
}
use of org.whole.lang.reflect.EntityDescriptor in project whole by wholeplatform.
the class CommandFactory method addOverSimpleConstraints.
protected synchronized void addOverSimpleConstraints(final Object[][] dndRules) {
EnablerPredicateFactory pf = getEnablerPredicateFactory();
List<IPartRequestHandler> cloneList = new ArrayList<IPartRequestHandler>(dndRules.length);
List<IPartRequestHandler> shareList = new ArrayList<IPartRequestHandler>(dndRules.length);
for (Object[] dndRule : dndRules) {
EntityDescriptor<?> dndED = (EntityDescriptor<?>) dndRule[0];
EntityDescriptor<?> targetED = (EntityDescriptor<?>) dndRule[1];
IFeatureTransformer featureTransformer = (IFeatureTransformer) dndRule[2];
boolean isExecutable = (Boolean) dndRule[3];
cloneList.add(new PartRequestHandler(pf.dndSingleOver(dndED, targetED), isExecutable ? new ReplaceChildCommandFactory(CLONE(featureTransformer)) : unexecutableFeature));
shareList.add(new PartRequestHandler(pf.dndSingleOver(dndED, targetED), isExecutable ? new ReplaceChildCommandFactory(SHARE(featureTransformer)) : unexecutableFeature));
}
addHandlers(PartRequest.CLONE_CHILD, cloneList);
addHandlers(PartRequest.SHARE_CHILD, shareList);
}
use of org.whole.lang.reflect.EntityDescriptor in project whole by wholeplatform.
the class DefaultUITemplate method applyPalette.
public void applyPalette(IPaletteBuilder builder) {
builder.Drawer_(languageKit.getName());
EntityDescriptorEnum entityTypes = languageKit.getEntityDescriptorEnum();
for (Iterator i = entityTypes.values().iterator(); i.hasNext(); ) {
EntityDescriptor<?> ed = (EntityDescriptor<?>) i.next();
if (ed.isAbstract())
continue;
if (contains(connectionDescriptors, ed))
builder.Connection(ed);
else
builder.Template(ed);
}
builder._Drawer();
}
use of org.whole.lang.reflect.EntityDescriptor in project whole by wholeplatform.
the class DataTypesGrammarsDataTypeParser method deploy.
public static void deploy(String grammarURI) {
Grammar grammar = GrammarsRegistry.instance().getGrammar(grammarURI);
ILanguageKit lk = ReflectionFactory.getLanguageKit(GrammarsUtils.getLanguageURI(grammar), false, null);
EntityDescriptor<?> ed = lk.getEntityDescriptorEnum().valueOf("DateLiteral");
Map<EntityDescriptor<?>, IDataTypeParser> strategies = new HashMap<EntityDescriptor<?>, IDataTypeParser>();
strategies.put(ed, new DataTypesGrammarsDataTypeParser());
install(lk, strategies);
}
Aggregations