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);
}
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);
}
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");
}
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) {
}
}
}
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)));
}
Aggregations