use of org.whole.lang.reflect.FeatureDescriptorEnum in project whole by wholeplatform.
the class SimpleEntityStyledTreePart method getModelSpecificChildren.
protected List<IEntity> getModelSpecificChildren() {
IFeatureStyling[] featuresStyling = entityStyling.getFeaturesStyling();
int size = featuresStyling.length;
if (size == 0)
return Collections.emptyList();
else {
IEntity entity = getModelEntity();
EntityDescriptor<?> ed = entity.wGetEntityDescriptor();
FeatureDescriptorEnum fdEnum = ed.getFeatureDescriptorEnum();
List<IEntity> list = new ArrayList<IEntity>(size);
for (int i = 0; i < size; i++) list.add(entity.wGet(ed.getEntityFeatureDescriptor(fdEnum.valueOf(featuresStyling[i].getName()))));
return list;
}
}
use of org.whole.lang.reflect.FeatureDescriptorEnum in project whole by wholeplatform.
the class AbstractFreeformContentPanePart method refreshVisuals.
@Override
protected void refreshVisuals() {
IEntity e = getPresentationEntity();
FeatureDescriptorEnum fe = e.wGetEntityDescriptor().getFeatureDescriptorEnum();
int x = e.wGet(fe.valueOf("x")).wIntValue();
int y = e.wGet(fe.valueOf("y")).wIntValue();
// int width = e.wGet(fe.valueOf("width")).wIntValue();
// int height = e.wGet(fe.valueOf("height")).wIntValue();
// width, height);
Rectangle bounds = new Rectangle(x, y, -1, -1);
((GraphicalEditPart) getParent()).setLayoutConstraint(this, getFigure(), bounds);
}
use of org.whole.lang.reflect.FeatureDescriptorEnum in project whole by wholeplatform.
the class GrammarsUIInterpreterVisitor method createConfigurations.
public static Map<String, IEntity> createConfigurations(IEntity grammarBased) {
FeatureDescriptorEnum fdEnum = grammarBased.wGetLanguageKit().getFeatureDescriptorEnum();
Map<String, IEntity> configurations = new HashMap<String, IEntity>();
ScannerIterator<IEntity> i = IteratorFactory.childScannerIterator();
i.reset(grammarBased);
for (IEntity configuration : i) {
IEntity name = configuration.wGet(fdEnum.valueOf("name"));
configurations.put(name.wStringValue(), configuration);
}
return configurations;
}
use of org.whole.lang.reflect.FeatureDescriptorEnum in project whole by wholeplatform.
the class QueriesContentAssistVisitor method allFeatureTypes.
private boolean allFeatureTypes(IEntity entity, EntityDescriptor<?> targetEd) {
if (!EntityUtils.hasParent(entity) || !entity.wGetParent().wGetEntityDescriptor(entity).isPlatformSupertypeOf(targetEd))
return false;
ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
languagesGroup.getText().setValue("queries.languages");
Actions actions = aef.createActions(0);
QueriesEntityFactory qef = QueriesEntityFactory.instance;
String actualLanguageURI = "";
String actualFeatureName = "";
FeatureDescriptor actualFD = null;
try {
actualFD = CommonsDataTypePersistenceParser.parseFeatureDescriptor(entity.wStringValue());
actualLanguageURI = actualFD.getLanguageKit().getURI();
actualFeatureName = actualFD.getName();
} catch (Exception e) {
if (DataTypeUtils.getDataKind(entity).isString())
actualFeatureName = entity.wStringValue();
}
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
if (languageKit.getURI().equals(actualLanguageURI))
continue;
FeatureDescriptorEnum fdEnum = languageKit.getFeatureDescriptorEnum();
if (fdEnum.values().isEmpty())
continue;
FeatureDescriptor fd = null;
if (actualFeatureName.length() > 0)
fd = fdEnum.valueOf(actualFeatureName);
if (fd == null)
fd = fdEnum.valueOf(0);
IEntity prototype = qef.create(targetEd, CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
}
languagesGroup.setActions(actions);
boolean addedLanguages = EntityUtils.isResolver(entity) ? mergeResult(targetEd, languagesGroup) : mergeResult(languagesGroup);
if (actualFD != null) {
GroupAction featurenamesGroup = aef.createGroupAction();
featurenamesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
featurenamesGroup.getText().setValue("queries.featurenames");
actions = aef.createActions(0);
FeatureDescriptorEnum fdEnum = actualFD.getFeatureDescriptorEnum();
List<FeatureDescriptor> fds = new ArrayList<FeatureDescriptor>(fdEnum.values());
Collections.sort(fds, EnumValueImpl.getByNameComparator());
for (FeatureDescriptor fd : fds) {
if (fd.equals(actualFD))
continue;
IEntity prototype = qef.create(targetEd, CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, fd.getName()));
}
featurenamesGroup.setActions(actions);
addedLanguages |= EntityUtils.isResolver(entity) ? mergeResult(targetEd, languagesGroup) : mergeResult(featurenamesGroup);
}
return addedLanguages;
}
use of org.whole.lang.reflect.FeatureDescriptorEnum in project whole by wholeplatform.
the class JSONLDEntityDecoder method decode.
public IEntity decode(org.whole.lang.json.model.Object jsonEntity) {
String edUri = null;
Value body = jsonEntity;
for (int i = 0; i < jsonEntity.size(); i++) {
Pair pair = jsonEntity.get(i);
String name = pair.getName().getValue();
if (name.equals("@type"))
edUri = pair.getValue().wStringValue();
else if (name.equals("@list") || name.equals("@set") || name.equals("@value"))
body = pair.getValue();
}
if (edUri == null)
return super.applyRules(jsonEntity);
EntityDescriptor<?> ed = CommonsDataTypePersistenceParser.getEntityDescriptor(edUri, true, null);
IEntityFactory ef = GenericEntityFactory.instance(RegistryConfigurations.RESOLVER);
IEntity entity = ef.create(ed);
switch(ed.getEntityKind()) {
case SIMPLE:
FeatureDescriptorEnum fdEnum = ed.getFeatureDescriptorEnum();
for (int i = 0; i < body.wSize(); i++) {
Pair pair = (Pair) body.wGet(i);
String name = pair.getName().getValue();
if (!name.startsWith("@")) {
FeatureDescriptor fd = fdEnum.valueOf(name);
entity.wSet(fd, applyRules(pair.getValue()));
}
}
break;
case COMPOSITE:
for (int i = 0; i < body.wSize(); i++) entity.wAdd(applyRules(body.wGet(i)));
break;
case DATA:
DataTypeUtils.convert(body, entity);
}
return entity;
}
Aggregations