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