Search in sources :

Example 1 with ActionsEntityFactory

use of org.whole.lang.actions.factories.ActionsEntityFactory in project whole by wholeplatform.

the class SemanticsInterpreterVisitor method visit.

@Override
public void visit(StructuredVariable entity) {
    ActionsEntityFactory aef = ActionsEntityFactory.instance;
    QueriesEntityFactory qef = QueriesEntityFactory.instance;
    ActionCall actionCall = aef.createActionCall(aef.createLabel("whole:org.whole.lang.semantics:SemanticsActions:1.0.0#toVariableFlatName"), qef.createVariableRefStep("variable").wGetAdapter(ActionsEntityDescriptorEnum.SelectedEntities));
    getBindings().wDef("variable", entity);
    IEntity varNameEntity = BehaviorUtils.evaluate(actionCall, 0, getOperation());
    if (isSelectedFeature(SemanticsUtils.USE_IDENTIFIER_SEMANTICS))
        setResult(varNameEntity);
    else {
        IEntity varValue = BindingUtils.wGet(getBindings(), varNameEntity.wStringValue());
        if (varValue == null)
            throw new MissingVariableException(entity.toString()).withSourceEntity(entity).withBindings(getBindings());
        setResult(varValue);
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) ActionsEntityFactory(org.whole.lang.actions.factories.ActionsEntityFactory) ActionCall(org.whole.lang.actions.model.ActionCall) MissingVariableException(org.whole.lang.visitors.MissingVariableException)

Example 2 with ActionsEntityFactory

use of org.whole.lang.actions.factories.ActionsEntityFactory in project whole by wholeplatform.

the class ActionsUIContentAssistVisitor method createReplaceTemplateAction.

protected TemplateAction createReplaceTemplateAction(IEntity prototype, String label, ImageDescriptor icon) {
    ActionsEntityFactory aef = ActionsEntityFactory.instance;
    TemplateAction action = aef.createTemplateAction();
    action.getKind().setValue(ActionKindEnum.REPLACE);
    action.getText().setValue(label);
    if (icon != null)
        action.getIcon().setValue(icon);
    action.setEnablerPredicate(createStageUpFragment(Predicate, createNotEqualsQuery(prototype)));
    action.setTransformation(createStageUpFragment(Transformation, EntityUtils.clone(prototype)));
    return action;
}
Also used : TemplateAction(org.whole.lang.actions.model.TemplateAction) ActionsEntityFactory(org.whole.lang.actions.factories.ActionsEntityFactory)

Example 3 with ActionsEntityFactory

use of org.whole.lang.actions.factories.ActionsEntityFactory in project whole by wholeplatform.

the class ActionsUIEntityFactory method createTemplateAction.

public TemplateAction createTemplateAction(ActionKindEnum.Value kind, IEntity prototype, String label, ImageDescriptor icon, boolean differentPredicate) {
    ActionsEntityFactory aef = ActionsEntityFactory.instance;
    TemplateAction action = aef.createTemplateAction();
    action.getKind().setValue(kind);
    action.getText().setValue(label);
    if (icon != null)
        action.getIcon().setValue(icon);
    if (differentPredicate && kind == ActionKindEnum.REPLACE)
        action.setEnablerPredicate(createStageUpFragment(Predicate, createNotEqualsPredicate(prototype)));
    action.setTransformation(createStageUpFragment(Transformation, EntityUtils.cloneIfParented(prototype)));
    return action;
}
Also used : TemplateAction(org.whole.lang.actions.model.TemplateAction) ActionsEntityFactory(org.whole.lang.actions.factories.ActionsEntityFactory)

Example 4 with ActionsEntityFactory

use of org.whole.lang.actions.factories.ActionsEntityFactory in project whole by wholeplatform.

the class ActionsUIContentAssistVisitor method allLanguages.

protected boolean allLanguages(IEntity entity) {
    if (!Matcher.match(ActionsEntityDescriptorEnum.URI, entity))
        return false;
    ActionsEntityFactory aef = ActionsEntityFactory.instance;
    GroupAction languagesGroup = aef.createGroupAction();
    Actions actions = aef.createActions(0);
    String actualLanguageURI = DataTypeUtils.getAsPersistenceString(entity);
    IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
    for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
        String uri = languageKit.getURI();
        if (uri.equals(actualLanguageURI))
            continue;
        URI prototype = aef.createURI(uri);
        actions.wAdd(createReplaceTemplateAction(prototype, ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
    }
    languagesGroup.setActions(actions);
    return mergeResult(languagesGroup);
}
Also used : GroupAction(org.whole.lang.actions.model.GroupAction) Actions(org.whole.lang.actions.model.Actions) URI(org.whole.lang.actions.model.URI) ActionsEntityFactory(org.whole.lang.actions.factories.ActionsEntityFactory) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 5 with ActionsEntityFactory

use of org.whole.lang.actions.factories.ActionsEntityFactory in project whole by wholeplatform.

the class WorkflowsIDEContentAssistVisitor method chooseClass.

protected boolean chooseClass(IEntity entity) {
    if (!WorkflowsUtils.isClassNameInJavaActivity(entity))
        return false;
    ReplaceWithClassNameAction action = new ReplaceWithClassNameAction((IEclipseContext) getBindings().wGetValue("eclipse#eclipseContext"), WorkflowsEntityDescriptorEnum.StringLiteral, entity.wStringValue(), "Select class...");
    ActionsEntityFactory aef = ActionsEntityFactory.instance;
    GroupAction customGroup = aef.createGroupAction();
    customGroup.setFillStrategy(aef.createFlat());
    customGroup.getText().setValue("workflows.custom");
    customGroup.setActions(aef.createActions(aef.createCustomAction(action)));
    return EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, customGroup) : mergeResult(customGroup);
}
Also used : ReplaceWithClassNameAction(org.whole.lang.ui.actions.ReplaceWithClassNameAction) GroupAction(org.whole.lang.actions.model.GroupAction) ActionsEntityFactory(org.whole.lang.actions.factories.ActionsEntityFactory)

Aggregations

ActionsEntityFactory (org.whole.lang.actions.factories.ActionsEntityFactory)6 GroupAction (org.whole.lang.actions.model.GroupAction)3 TemplateAction (org.whole.lang.actions.model.TemplateAction)2 IEntity (org.whole.lang.model.IEntity)2 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 ActionCall (org.whole.lang.actions.model.ActionCall)1 Actions (org.whole.lang.actions.model.Actions)1 URI (org.whole.lang.actions.model.URI)1 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1 ILanguageKit (org.whole.lang.reflect.ILanguageKit)1 ReplaceWithClassNameAction (org.whole.lang.ui.actions.ReplaceWithClassNameAction)1 ReplaceWithResourceAction (org.whole.lang.ui.actions.ReplaceWithResourceAction)1 ReplaceWithResourceAndPersistenceAction (org.whole.lang.ui.actions.ReplaceWithResourceAndPersistenceAction)1 MissingVariableException (org.whole.lang.visitors.MissingVariableException)1 Expression (org.whole.lang.workflows.model.Expression)1 PersistenceActivity (org.whole.lang.workflows.model.PersistenceActivity)1