Search in sources :

Example 91 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractUIBuilder method addTranslateItem.

@Override
public void addTranslateItem() {
    FeatureDescriptor menu = ActionsFeatureDescriptorEnum.translateMenuActions;
    VisibilityExpression expression = new ActionsVisibleWhen(menu);
    IContributionItem ici = new ActionsCompositeContributionItem(this, menu);
    addActionsItem(TRANSLATE_LABEL, expression, ici);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsVisibleWhen(org.whole.lang.e4.ui.expressions.ActionsVisibleWhen) IContributionItem(org.eclipse.jface.action.IContributionItem) VisibilityExpression(org.whole.lang.e4.ui.expressions.VisibilityExpression) ActionsCompositeContributionItem(org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)

Example 92 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class AbstractUIBuilder method addSourceItem.

@Override
public void addSourceItem() {
    FeatureDescriptor menu = ActionsFeatureDescriptorEnum.sourceMenuActions;
    VisibilityExpression expression = new ActionsVisibleWhen(menu);
    IContributionItem ici = new ActionsCompositeContributionItem(this, menu);
    addActionsItem(SOURCE_LABEL, expression, ici);
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) ActionsVisibleWhen(org.whole.lang.e4.ui.expressions.ActionsVisibleWhen) IContributionItem(org.eclipse.jface.action.IContributionItem) VisibilityExpression(org.whole.lang.e4.ui.expressions.VisibilityExpression) ActionsCompositeContributionItem(org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)

Example 93 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class E4Utils method wrapToBehavior.

public static IEntity wrapToBehavior(EntityDescriptor<?> ed, FeatureDescriptor intoFD, IEntityTransformer entityTransformer) {
    IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
    if (intoFD != null)
        bm.wDefValue("intoFDUri", CommonsDataTypePersistenceParser.unparseFeatureDescriptor(intoFD));
    if (entityTransformer instanceof DefaultWrapInTransformer) {
        FeatureDescriptor fd = ((DefaultWrapInTransformer) entityTransformer).getFeatureDescriptor();
        bm.wDefValue("edUri", CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
        if (fd != null)
            bm.wDefValue("fdUri", CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
        else
            bm.wDefValue("fdIndex", ((DefaultWrapInTransformer) entityTransformer).getIndex());
        IEntity wrapInBehavior = WrapActionsTemplateManager.instance().create(fd != null ? "WrapIn" : "WrapInIndex");
        wrapInBehavior = BehaviorUtils.evaluate(wrapInBehavior, 1, bm);
        Matcher.removeVars(wrapInBehavior, false);
        return wrapInBehavior;
    } else if (entityTransformer instanceof DefaultWrapWithinTransformer) {
        FeatureDescriptor fd = ((DefaultWrapWithinTransformer) entityTransformer).getFeatureDescriptor();
        bm.wDefValue("edUri", CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
        bm.wDefValue("fdUri", CommonsDataTypePersistenceParser.unparseFeatureDescriptor(fd));
        IEntity wrapWithinBehavior = WrapActionsTemplateManager.instance().create("WrapWithin");
        wrapWithinBehavior = BehaviorUtils.evaluate(wrapWithinBehavior, 1, bm);
        Matcher.removeVars(wrapWithinBehavior, false);
        return wrapWithinBehavior;
    } else
        throw new IllegalArgumentException("unsupported entity transformer");
}
Also used : DefaultWrapWithinTransformer(org.whole.lang.util.DefaultWrapWithinTransformer) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IEntity(org.whole.lang.model.IEntity) IBindingManager(org.whole.lang.bindings.IBindingManager) DefaultWrapInTransformer(org.whole.lang.util.DefaultWrapInTransformer)

Example 94 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class E4ResourceBindingsContributor method addResourceBindings.

public void addResourceBindings(final IBindingManager bm) {
    if (bm.wIsSet("debug#breakpointsEnabled") && bm.wIsSet("eclipse#eclipseContext")) {
        try {
            EPartService partService = ((IEclipseContext) bm.wGetValue("eclipse#eclipseContext")).get(EPartService.class);
            final MPart debugPart = partService.findPart(IE4UIConstants.DEBUG_PART_ID);
            if (debugPart == null)
                return;
            IEntity breakpointsEnabled = BindingManagerFactory.instance.createValue(true);
            breakpointsEnabled.wAddRequestEventHandler(new IdentityRequestEventHandler() {

                public boolean notifyRequested(IEntity source, FeatureDescriptor feature, boolean value) {
                    Map<String, String> persistedState = debugPart.getPersistedState();
                    return Boolean.valueOf(persistedState.get("debug#breakpointsEnabled"));
                }
            });
            bm.wSet("debug#breakpointsEnabled", breakpointsEnabled);
        } catch (Exception e) {
        }
    }
}
Also used : MPart(org.eclipse.e4.ui.model.application.ui.basic.MPart) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) EPartService(org.eclipse.e4.ui.workbench.modeling.EPartService) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) Map(java.util.Map) IdentityRequestEventHandler(org.whole.lang.events.IdentityRequestEventHandler)

Example 95 with FeatureDescriptor

use of org.whole.lang.reflect.FeatureDescriptor in project whole by wholeplatform.

the class GrammarsDefaultEntityRegistryConfiguration method apply.

public void apply(IEntityRegistry er) {
    super.apply(er);
    GrammarsEntityFactory ef = GrammarsEntityFactory.instance(er);
    RegExp regex;
    Literal literal;
    IdentityEventHandler deriveLiteralPattern = new IdentityEventHandler() {

        private static final long serialVersionUID = 1L;

        private String derivedPattern;

        @Override
        public void notifyChanged(IEntity source, FeatureDescriptor featureDesc, String oldValue, String newValue) {
            IEntity parent = source.wGetParent();
            if (parent instanceof LiteralTerminal) {
                LiteralTerminal literalTerminal = (LiteralTerminal) parent;
                Literal literal = literalTerminal.getLiteral();
                if (literal == source) {
                    derivedPattern = StringUtils.quoteRegex(newValue);
                    literalTerminal.getPattern().wSetValue(derivedPattern);
                } else if (newValue != derivedPattern) {
                    source.wRemoveChangeEventHandler(this);
                    literal.wRemoveChangeEventHandler(this);
                }
            }
        }
    };
    er.put(ef.createEmpty(ef.createLiteral("")));
    er.put(ef.createChoose(2));
    er.put(ef.createConcatenate(2));
    er.put(ef.createLiteralTerminal(regex = ef.createRegExp("pattern"), ef.createCategory(CategoryEnum.DELIMITER), literal = ef.createLiteral("literal")));
    regex.wAddChangeEventHandler(deriveLiteralPattern);
    literal.wAddChangeEventHandler(deriveLiteralPattern);
    er.put(ef.createDataTerminal(ef.createRegExp(".*"), ef.createCategory(CategoryEnum.LITERAL), ef.createFormat("%s")));
    er.put(ef.createAs(ef.createNonTerminal("nt"), ef.createName("name")));
    er.put(ef.createByLines(1));
    er.put(ef.createBySize(10));
    er.put(ef.createRepeat(ef.createSize(0), ef.createUnbounded(), ef.buildLiteralTerminal().set(GrammarsFeatureDescriptorEnum.literal, ",").getResult(), createResolver(GrammarsEntityDescriptorEnum.Rule)));
    er.put(ef.createBySize(5));
    er.put(ef.createGrammar(ef.createName("GrammarName"), createResolver(GrammarsEntityDescriptorEnum.TargetLanguage), createResolver(GrammarsEntityDescriptorEnum.NonTerminal), ef.createLiteralTerminal(ef.createRegExp("\\p{javaWhitespace}*"), ef.createCategory(CategoryEnum.SEPARATOR), ef.createLiteral("")), ef.createProductions(0), ef.createProductions(ef.create(GrammarsEntityDescriptorEnum.Production, ef.createNonTerminal("StartSymbol"), createResolver(GrammarsEntityDescriptorEnum.Rule))), // ef.createNamespace("org.whole.examples.grammarname"),
    createResolver(GrammarsEntityDescriptorEnum.URI), createResolver(GrammarsEntityDescriptorEnum.Namespace), createResolver(GrammarsEntityDescriptorEnum.Version), createResolver(GrammarsEntityDescriptorEnum.Literal), createResolver(GrammarsEntityDescriptorEnum.Literal), createResolver(GrammarsEntityDescriptorEnum.Literal)));
}
Also used : IdentityEventHandler(org.whole.lang.events.IdentityEventHandler) RegExp(org.whole.lang.grammars.model.RegExp) IEntity(org.whole.lang.model.IEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) Literal(org.whole.lang.grammars.model.Literal) LiteralTerminal(org.whole.lang.grammars.model.LiteralTerminal)

Aggregations

FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)100 IEntity (org.whole.lang.model.IEntity)43 InternalIEntity (org.whole.lang.model.InternalIEntity)6 ILanguageKit (org.whole.lang.reflect.ILanguageKit)6 HashSet (java.util.HashSet)5 IContributionItem (org.eclipse.jface.action.IContributionItem)5 ActionsVisibleWhen (org.whole.lang.e4.ui.expressions.ActionsVisibleWhen)5 VisibilityExpression (org.whole.lang.e4.ui.expressions.VisibilityExpression)5 ActionsCompositeContributionItem (org.whole.lang.e4.ui.menu.ActionsCompositeContributionItem)5 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 HashMap (java.util.HashMap)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 ITransactionScope (org.whole.lang.bindings.ITransactionScope)3 IdentityRequestEventHandler (org.whole.lang.events.IdentityRequestEventHandler)3 IMappingStrategy (org.whole.lang.xsd.codebase.IMappingStrategy)3 IEntityFactory (org.whole.lang.factories.IEntityFactory)2 ArrayType (org.whole.lang.pojo.model.ArrayType)2 CollectionType (org.whole.lang.pojo.model.CollectionType)2 MapType (org.whole.lang.pojo.model.MapType)2