Search in sources :

Example 1 with FeatureDescriptorEnum

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;
    }
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList) IFeatureStyling(org.whole.lang.ui.notations.styledtree.styling.IFeatureStyling)

Example 2 with FeatureDescriptorEnum

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);
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) Rectangle(org.eclipse.draw2d.geometry.Rectangle) GraphicalEditPart(org.eclipse.gef.GraphicalEditPart)

Example 3 with FeatureDescriptorEnum

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;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) HashMap(java.util.HashMap)

Example 4 with FeatureDescriptorEnum

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;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) Actions(org.whole.lang.actions.model.Actions) IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ArrayList(java.util.ArrayList) ILanguageKit(org.whole.lang.reflect.ILanguageKit) GroupAction(org.whole.lang.actions.model.GroupAction) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsUIEntityFactory(org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)

Example 5 with FeatureDescriptorEnum

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;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IEntityFactory(org.whole.lang.factories.IEntityFactory) Value(org.whole.lang.json.model.Value) Pair(org.whole.lang.json.model.Pair)

Aggregations

IEntity (org.whole.lang.model.IEntity)10 FeatureDescriptorEnum (org.whole.lang.reflect.FeatureDescriptorEnum)10 ILanguageKit (org.whole.lang.reflect.ILanguageKit)3 ArrayList (java.util.ArrayList)2 Rectangle (org.eclipse.draw2d.geometry.Rectangle)2 GraphicalEditPart (org.eclipse.gef.GraphicalEditPart)2 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)2 IEntityFigure (org.whole.lang.ui.figures.IEntityFigure)2 HashMap (java.util.HashMap)1 Actions (org.whole.lang.actions.model.Actions)1 GroupAction (org.whole.lang.actions.model.GroupAction)1 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)1 CommonsFeatureDescriptorEnum (org.whole.lang.commons.reflect.CommonsFeatureDescriptorEnum)1 IEntityFactory (org.whole.lang.factories.IEntityFactory)1 Pair (org.whole.lang.json.model.Pair)1 Value (org.whole.lang.json.model.Value)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)1 CompositeFigure (org.whole.lang.ui.figures.CompositeFigure)1 EntityFigure (org.whole.lang.ui.figures.EntityFigure)1