Search in sources :

Example 1 with NewNodeOp

use of com.liferay.ide.kaleo.core.op.NewNodeOp in project liferay-ide by liferay.

the class NewNodeOpWizard method performPostDiagramNodeAdded.

protected void performPostDiagramNodeAdded() {
    NewNodeOp newNodeOp = element().nearest(NewNodeOp.class);
    CanTransition newNode = newNodeOp.adapt(CanTransition.class);
    CanTransition node = _diagramNodePart.getLocalModelElement().nearest(CanTransition.class);
    WorkflowDefinition workflowDefinition = node.nearest(WorkflowDefinition.class);
    if ((newNode != null) && (node != null)) {
        Value<String> newNodeName = newNode.getName();
        node.setName(newNodeName.content());
        if (newNodeOp.getConnectedNodes().size() > 0) {
            for (Node diagramNode : newNodeOp.getConnectedNodes()) {
                Value<String> nodeName = diagramNode.getName();
                String diagramNodeName = nodeName.content(true);
                if (diagramNode instanceof ConditionForOp) {
                    ElementList<Condition> conditions = workflowDefinition.getConditions();
                    Condition insertCondition = conditions.insert();
                    insertCondition.setName(diagramNodeName);
                } else if (diagramNode instanceof ForkForOp) {
                    ElementList<Fork> forks = workflowDefinition.getForks();
                    Fork insertFork = forks.insert();
                    insertFork.setName(diagramNodeName);
                } else if (diagramNode instanceof JoinForOp) {
                    ElementList<Join> joins = workflowDefinition.getJoins();
                    Join insertJoin = joins.insert();
                    insertJoin.setName(diagramNodeName);
                } else if (diagramNode instanceof JoinXorForOp) {
                    ElementList<JoinXor> joinXors = workflowDefinition.getJoinXors();
                    JoinXor insertJoinXor = joinXors.insert();
                    insertJoinXor.setName(diagramNodeName);
                } else if (diagramNode instanceof StateForOp) {
                    ElementList<State> states = workflowDefinition.getStates();
                    State insertState = states.insert();
                    insertState.setName(diagramNodeName);
                } else if (diagramNode instanceof TaskForOp) {
                    ElementList<Task> tasks = workflowDefinition.getTasks();
                    Task insertTask = tasks.insert();
                    insertTask.setName(diagramNodeName);
                }
                if (diagramNode instanceof ChooseDiagramNode || node instanceof Condition || node instanceof Fork || node instanceof State || node instanceof Task) {
                    Transition newTransition = node.getTransitions().insert();
                    newTransition.setName(diagramNodeName);
                    newTransition.setTarget(diagramNodeName);
                } else {
                    CanTransition canTransition = diagramNode.nearest(CanTransition.class);
                    ElementList<Transition> transition = canTransition.getTransitions();
                    Transition joinTransition = transition.insert();
                    joinTransition.setName(node.getName().content());
                    joinTransition.setTarget(node.getName().content());
                }
            }
        }
    }
    _actionHandler.postDiagramNodePartAdded(element(), newNode, node);
}
Also used : Task(com.liferay.ide.kaleo.core.model.Task) Fork(com.liferay.ide.kaleo.core.model.Fork) JoinXor(com.liferay.ide.kaleo.core.model.JoinXor) JoinXorForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.JoinXorForOp) ChooseDiagramNode(com.liferay.ide.kaleo.core.op.ChooseDiagramNode) Node(com.liferay.ide.kaleo.core.model.Node) StateForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.StateForOp) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) ElementList(org.eclipse.sapphire.ElementList) ForkForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.ForkForOp) ConditionForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.ConditionForOp) Condition(com.liferay.ide.kaleo.core.model.Condition) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) Join(com.liferay.ide.kaleo.core.model.Join) ChooseDiagramNode(com.liferay.ide.kaleo.core.op.ChooseDiagramNode) State(com.liferay.ide.kaleo.core.model.State) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) CanTransition(com.liferay.ide.kaleo.core.model.CanTransition) Transition(com.liferay.ide.kaleo.core.model.Transition) JoinForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.JoinForOp) TaskForOp(com.liferay.ide.kaleo.core.op.NewNodeOp.TaskForOp)

Example 2 with NewNodeOp

use of com.liferay.ide.kaleo.core.op.NewNodeOp in project liferay-ide by liferay.

the class NewNodeAddActionHandler method run.

@Override
public Object run(Presentation context) {
    Object retval = null;
    if (canRunWizard(context)) {
        NewNodeOp op = createOp(context);
        WorkflowDefinition oldWorkflowDefinition = (WorkflowDefinition) getModelElement();
        WorkflowDefinition newWorkflowDefinition = op.getWorkflowDefinition().content(true);
        newWorkflowDefinition.copy(oldWorkflowDefinition);
        // When WorkflowDefinition.getSchemaVersion(),
        // VersionedSchemaDefaultValueService.compute()
        // can't get the version, always returns the default value, directly
        // set the schema version here.
        newWorkflowDefinition.setSchemaVersion(oldWorkflowDefinition.getSchemaVersion().content());
        NewNodeOpWizard wizard = createNewNodeWizard(op, this, context);
        WorkflowDefinitionEditor definitionEditor = context.part().adapt(WorkflowDefinitionEditor.class);
        op.setUseNodeWizards(definitionEditor.isNodeWizardsEnabled());
        runWizard(context, wizard);
        definitionEditor.setNodeWizardsEnabled(op.isUseNodeWizards().content());
    } else {
        retval = insertDiagramPart(context, true);
    }
    return retval;
}
Also used : NewNodeOpWizard(com.liferay.ide.kaleo.ui.wizard.NewNodeOpWizard) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) WorkflowDefinitionEditor(com.liferay.ide.kaleo.ui.editor.WorkflowDefinitionEditor)

Example 3 with NewNodeOp

use of com.liferay.ide.kaleo.core.op.NewNodeOp in project liferay-ide by liferay.

the class EmailAddressValidationService method _getSchemaVersion.

private Version _getSchemaVersion() {
    Version schemaVersion = new Version(KaleoCore.DEFAULT_KALEO_VERSION);
    if (context(WorkflowDefinition.class) != null) {
        WorkflowDefinition workflowDefinition = context(WorkflowDefinition.class);
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewNodeOp.class) != null) {
        NewNodeOp newNodeOp = context(NewNodeOp.class);
        ElementHandle<WorkflowDefinition> workflowDef = newNodeOp.getWorkflowDefinition();
        WorkflowDefinition workflowDefinition = workflowDef.content();
        Value<Version> version = workflowDefinition.getSchemaVersion();
        schemaVersion = version.content();
    } else if (context(NewWorkflowDefinitionOp.class) != null) {
        NewWorkflowDefinitionOp newWorkflowDenitionOp = context(NewWorkflowDefinitionOp.class);
        ReferenceValue<String, IProject> opProject = newWorkflowDenitionOp.getProject();
        IProject project = opProject.target();
        ILiferayProject liferayProj = LiferayCore.create(project);
        ILiferayPortal portal = liferayProj.adapt(ILiferayPortal.class);
        if (portal != null) {
            schemaVersion = new Version(portal.getVersion());
        }
    }
    return schemaVersion;
}
Also used : Version(org.eclipse.sapphire.Version) ILiferayProject(com.liferay.ide.core.ILiferayProject) NewNodeOp(com.liferay.ide.kaleo.core.op.NewNodeOp) ReferenceValue(org.eclipse.sapphire.ReferenceValue) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementHandle(org.eclipse.sapphire.ElementHandle) NewWorkflowDefinitionOp(com.liferay.ide.kaleo.core.op.NewWorkflowDefinitionOp) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Aggregations

WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)3 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)3 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)1 ILiferayProject (com.liferay.ide.core.ILiferayProject)1 CanTransition (com.liferay.ide.kaleo.core.model.CanTransition)1 Condition (com.liferay.ide.kaleo.core.model.Condition)1 Fork (com.liferay.ide.kaleo.core.model.Fork)1 Join (com.liferay.ide.kaleo.core.model.Join)1 JoinXor (com.liferay.ide.kaleo.core.model.JoinXor)1 Node (com.liferay.ide.kaleo.core.model.Node)1 State (com.liferay.ide.kaleo.core.model.State)1 Task (com.liferay.ide.kaleo.core.model.Task)1 Transition (com.liferay.ide.kaleo.core.model.Transition)1 ChooseDiagramNode (com.liferay.ide.kaleo.core.op.ChooseDiagramNode)1 ConditionForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.ConditionForOp)1 ForkForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.ForkForOp)1 JoinForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.JoinForOp)1 JoinXorForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.JoinXorForOp)1 StateForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.StateForOp)1 TaskForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.TaskForOp)1