Search in sources :

Example 6 with Expression

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

the class WorkflowsIDEContentAssistVisitor method chooseResource.

protected boolean chooseResource(IEntity entity) {
    Object customAction = null;
    if (WorkflowsUtils.isResourceInPersistenceActivity(entity)) {
        PersistenceActivity parent = (PersistenceActivity) entity.wGetParent();
        Expression expression = parent.getPersistence();
        IPersistenceKit persistenceKit = Matcher.match(WorkflowsEntityDescriptorEnum.StringLiteral, expression) ? (ReflectionFactory.hasPersistenceKit(expression.wStringValue()) ? ReflectionFactory.getPersistenceKit(expression.wStringValue()) : null) : ReflectionFactory.getDefaultPersistenceKit();
        customAction = new ReplaceWithResourceAndPersistenceAction((IEclipseContext) getBindings().wGetValue("eclipse#eclipseContext"), WorkflowsEntityDescriptorEnum.StringLiteral, entity.wStringValue(), persistenceKit, "Select resource...") {

            protected boolean isLoading(IEntity entity) {
                return Matcher.match(WorkflowsEntityDescriptorEnum.LoadModel, entity.wGetParent());
            }

            protected ResourceKind getResourceKind(IEntity selectedEntity) {
                switch(selectedEntity.wGetParent().wGet(WorkflowsFeatureDescriptorEnum.resourceKind).wEnumValue().getOrdinal()) {
                    default:
                    case ResourceKindEnum.WORKSPACE_ord:
                        return ResourceKind.WORKSPACE;
                    case ResourceKindEnum.FILE_SYSTEM_ord:
                        return ResourceKind.FILE_SYSTEM;
                    case ResourceKindEnum.CLASSPATH_ord:
                        return ResourceKind.CLASSPATH;
                    case ResourceKindEnum.URL_ord:
                        return ResourceKind.URL;
                }
            }

            protected void performReplacePersistence(IEntity parent) {
                ((PersistenceActivity) parent).setPersistence(WorkflowsEntityFactory.instance.createStringLiteral(persistenceKit.getId()));
            }
        };
    } else if (WorkflowsUtils.isResourceInArtifactsActivity(entity)) {
        customAction = new ReplaceWithResourceAction((IEclipseContext) getBindings().wGetValue("eclipse#eclipseContext"), WorkflowsEntityDescriptorEnum.StringLiteral, entity.wStringValue(), "Select resource...") {

            protected boolean isLoading(IEntity entity) {
                return Matcher.match(WorkflowsEntityDescriptorEnum.LoadArtifacts, entity.wGetParent());
            }

            protected ResourceKind getResourceKind(IEntity selectedEntity) {
                switch(selectedEntity.wGetParent().wGet(WorkflowsFeatureDescriptorEnum.rootResourceKind).wEnumValue().getOrdinal()) {
                    default:
                    case ResourceKindEnum.WORKSPACE_ord:
                        return ResourceKind.WORKSPACE;
                    case ResourceKindEnum.FILE_SYSTEM_ord:
                        return ResourceKind.FILE_SYSTEM;
                    case ResourceKindEnum.CLASSPATH_ord:
                        return ResourceKind.CLASSPATH;
                    case ResourceKindEnum.URL_ord:
                        return ResourceKind.URL;
                }
            }
        };
    } else
        return false;
    ActionsEntityFactory aef = ActionsEntityFactory.instance;
    GroupAction customGroup = aef.createGroupAction();
    customGroup.setFillStrategy(aef.createFlat());
    customGroup.getText().setValue("workflows.custom");
    customGroup.setActions(aef.createActions(aef.createCustomAction(customAction)));
    return EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, customGroup) : mergeResult(customGroup);
}
Also used : ReplaceWithResourceAction(org.whole.lang.ui.actions.ReplaceWithResourceAction) GroupAction(org.whole.lang.actions.model.GroupAction) PersistenceActivity(org.whole.lang.workflows.model.PersistenceActivity) ReplaceWithResourceAndPersistenceAction(org.whole.lang.ui.actions.ReplaceWithResourceAndPersistenceAction) Expression(org.whole.lang.workflows.model.Expression) IEntity(org.whole.lang.model.IEntity) IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit) ActionsEntityFactory(org.whole.lang.actions.factories.ActionsEntityFactory)

Example 7 with Expression

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

the class InvokeJavaInstanceMethodPart method refreshVisuals.

@Override
protected void refreshVisuals() {
    InvokeJavaInstanceMethod 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 : Expression(org.whole.lang.workflows.model.Expression) InvokeJavaInstanceMethod(org.whole.lang.workflows.model.InvokeJavaInstanceMethod)

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