Search in sources :

Example 1 with Expression

use of org.whole.lang.workflows.model.Expression in project whole by wholeplatform.

the class ChooseModelsDialog method open.

@Override
public int open() {
    int status = super.open();
    if (status == Dialog.OK) {
        WorkflowsEntityFactory wef = WorkflowsEntityFactory.instance;
        Tuple tuple = QueriesEntityFactory.instance.createTuple(0);
        for (Object element : getResult()) try {
            IEntity model = getPersistenceKit().readModel(new IFilePersistenceProvider((IFile) element));
            tuple.wAdd(createStageUpFragment(QueriesEntityDescriptorEnum.Expression, model));
        } catch (Exception e) {
        }
        Variable variable = wef.createVariable("selectedModels");
        Expression fragment = createSameStageFragment(Expression, tuple);
        Assign assign = wef.createAssign(variable, fragment);
        assignments.wAdd(assign);
    }
    return status;
}
Also used : WorkflowsEntityFactory(org.whole.lang.workflows.factories.WorkflowsEntityFactory) Variable(org.whole.lang.workflows.model.Variable) IEntity(org.whole.lang.model.IEntity) Expression(org.whole.lang.workflows.model.Expression) Expression(org.whole.lang.workflows.reflect.WorkflowsEntityDescriptorEnum.Expression) IFilePersistenceProvider(org.whole.lang.codebase.IFilePersistenceProvider) Assign(org.whole.lang.workflows.model.Assign) Tuple(org.whole.lang.queries.model.Tuple)

Example 2 with Expression

use of org.whole.lang.workflows.model.Expression in project whole by wholeplatform.

the class WorkflowsInterpreterVisitor method visit.

@Override
public void visit(Unparse entity) {
    try {
        entity.getGrammar().accept(this);
        IEntity grammarOrUri = getResult();
        if (!EntityUtils.isData(grammarOrUri)) {
            stagedVisit(grammarOrUri);
            grammarOrUri = ((Grammar) grammarOrUri).getUri();
        }
        String grammarUri = grammarOrUri.wStringValue();
        entity.getModel().accept(this);
        IEntity model = getResult();
        Expression text = entity.getText();
        Appendable appendable = new StringBuilder();
        boolean hasAppendable = false;
        String variableName = null;
        if (Matcher.matchImpl(WorkflowsEntityDescriptorEnum.Variable, text)) {
            variableName = ((Variable) text).getValue();
            if (getBindings().wIsSet(variableName)) {
                try {
                    appendable = (Appendable) getBindings().wGetValue(variableName);
                    hasAppendable = true;
                } catch (Exception e) {
                    throw new IllegalArgumentException("The text of an Unparse activity must be an Appendable", e);
                }
            }
        } else if (EntityUtils.isNotResolver(text)) {
            text.accept(this);
            appendable = (Appendable) getResultValue();
            hasAppendable = true;
        }
        // TODO if (EntityUtils.isImpl(entity.getNt())) {
        GrammarsUtils.unparse(model, appendable, grammarUri);
        IEntity resultEntity = hasAppendable ? BindingManagerFactory.instance.createValue(appendable) : BindingManagerFactory.instance.createValue(appendable.toString());
        if (variableName != null && !getBindings().wIsSet(variableName))
            getBindings().wDef(variableName, resultEntity);
        setResult(resultEntity);
    } catch (Exception e) {
        throw IWholeRuntimeException.asWholeException(e, entity, getBindings());
    }
}
Also used : IEntity(org.whole.lang.model.IEntity) Expression(org.whole.lang.workflows.model.Expression) MissingVariableException(org.whole.lang.visitors.MissingVariableException) IOException(java.io.IOException) IWholeRuntimeException(org.whole.lang.exceptions.IWholeRuntimeException) VisitException(org.whole.lang.visitors.VisitException) ParseException(org.whole.lang.parsers.ParseException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 3 with Expression

use of org.whole.lang.workflows.model.Expression in project whole by wholeplatform.

the class CreateJavaClassInstancePart method refreshVisuals.

@Override
protected void refreshVisuals() {
    CreateJavaClassInstance entity = getModelEntity();
    Expression e = entity.getConstructor();
    String name = Matcher.matchImpl(WorkflowsEntityDescriptorEnum.StringLiteral, e) ? e.wStringValue() : "?";
    int endIndex = name.indexOf('(');
    if (endIndex > 0)
        name = name.substring(0, endIndex);
    getFigure().setConstructorName(name);
    super.refreshVisuals();
}
Also used : Expression(org.whole.lang.workflows.model.Expression) CreateJavaClassInstance(org.whole.lang.workflows.model.CreateJavaClassInstance)

Example 4 with Expression

use of org.whole.lang.workflows.model.Expression in project whole by wholeplatform.

the class ChangeValueDialogFactory method createDialog.

public Dialog createDialog(Shell shell, String title, String message, Assignments assignments, IBindingManager bindings) {
    Assign assign = (Assign) assignments.wGet(0);
    Expression expression = assign.getExpression();
    IEntity entity = BehaviorUtils.evaluate(expression, 0, bindings);
    assign.wSet(expression, entity);
    IEclipseContext params = EclipseContextFactory.create();
    params.set("dialogTitle", title);
    params.set("dialogMessage", message);
    params.set("dialogEntity", entity);
    IEclipseContext context = (IEclipseContext) bindings.wGetValue("eclipse#eclipseContext");
    IImportAsModelDialogFactory factory = ContextInjectionFactory.make(DisabledImportAsModelDialogFactory.class, context);
    params.set(IImportAsModelDialogFactory.class, factory);
    return ContextInjectionFactory.make(ChangeValueDialog.class, context, params);
}
Also used : Expression(org.whole.lang.workflows.model.Expression) IEntity(org.whole.lang.model.IEntity) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IImportAsModelDialogFactory(org.whole.lang.ui.dialogs.IImportAsModelDialogFactory) Assign(org.whole.lang.workflows.model.Assign)

Example 5 with Expression

use of org.whole.lang.workflows.model.Expression in project whole by wholeplatform.

the class InvokeJavaClassMethodPart method refreshVisuals.

@Override
protected void refreshVisuals() {
    InvokeJavaClassMethod entity = getModelEntity();
    Expression e = entity.getMethod();
    String name = Matcher.matchImpl(WorkflowsEntityDescriptorEnum.StringLiteral, e) ? e.wStringValue() : "?";
    int endIndex = name.indexOf('(');
    if (endIndex > 0)
        name = name.substring(0, endIndex);
    getFigure().setMethodName(name);
    super.refreshVisuals();
}
Also used : InvokeJavaClassMethod(org.whole.lang.workflows.model.InvokeJavaClassMethod) Expression(org.whole.lang.workflows.model.Expression)

Aggregations

Expression (org.whole.lang.workflows.model.Expression)7 IEntity (org.whole.lang.model.IEntity)4 IEclipseContext (org.eclipse.e4.core.contexts.IEclipseContext)2 Assign (org.whole.lang.workflows.model.Assign)2 IOException (java.io.IOException)1 ActionsEntityFactory (org.whole.lang.actions.factories.ActionsEntityFactory)1 GroupAction (org.whole.lang.actions.model.GroupAction)1 IFilePersistenceProvider (org.whole.lang.codebase.IFilePersistenceProvider)1 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)1 IWholeRuntimeException (org.whole.lang.exceptions.IWholeRuntimeException)1 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)1 ParseException (org.whole.lang.parsers.ParseException)1 Tuple (org.whole.lang.queries.model.Tuple)1 ReplaceWithResourceAction (org.whole.lang.ui.actions.ReplaceWithResourceAction)1 ReplaceWithResourceAndPersistenceAction (org.whole.lang.ui.actions.ReplaceWithResourceAndPersistenceAction)1 IImportAsModelDialogFactory (org.whole.lang.ui.dialogs.IImportAsModelDialogFactory)1 MissingVariableException (org.whole.lang.visitors.MissingVariableException)1 VisitException (org.whole.lang.visitors.VisitException)1 WorkflowsEntityFactory (org.whole.lang.workflows.factories.WorkflowsEntityFactory)1 CreateJavaClassInstance (org.whole.lang.workflows.model.CreateJavaClassInstance)1