Search in sources :

Example 1 with ActionFactory

use of org.whole.lang.e4.ui.actions.ActionFactory in project whole by wholeplatform.

the class ActionsE4InterpreterVisitor method createAction.

protected IAction createAction(Value kind, IEnablerPredicate enablerPredicate, IEntityTransformer transformer, IEntity prototype, String text) {
    // FIXME transformer always passed as null
    IEclipseContext context = (IEclipseContext) getBindings().wGetValue("context");
    ActionFactory actionRegistry = new ActionFactory(context);
    QueriesEntityFactory qf = QueriesEntityFactory.instance;
    IEntity predicate = enablerPredicate instanceof OpaqueEnablerPredicate ? ((OpaqueEnablerPredicate) enablerPredicate).value : qf.createBooleanLiteral(true);
    switch(kind.getOrdinal()) {
        case ActionKindEnum.REPLACE_ord:
            return actionRegistry.createReplaceFragmentAction(text, predicate, prototype);
        case ActionKindEnum.INSERT_ord:
            return actionRegistry.createAddFragmentAction(text, predicate, prototype);
        case ActionKindEnum.WRAP_ord:
            IEntity behavior = qf.createPointwiseUpdate(qf.createVariableRefStep("focusEntity"), CommonsEntityAdapterFactory.createStageUpFragment(QueriesEntityDescriptorEnum.Expression, prototype));
            return actionRegistry.createPerformAction(text, WRAP_ICON_URI, predicate, behavior);
        case ActionKindEnum.PERFORM_ord:
            return actionRegistry.createPerformAction(text, WRAP_ICON_URI, predicate, prototype);
        default:
            throw new IllegalArgumentException("not implemented yet");
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) QueriesEntityFactory(org.whole.lang.queries.factories.QueriesEntityFactory) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) ActionFactory(org.whole.lang.e4.ui.actions.ActionFactory)

Aggregations

IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)1 ActionFactory (org.whole.lang.e4.ui.actions.ActionFactory)1 IEntity (org.whole.lang.model.IEntity)1 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)1