Search in sources :

Example 1 with ElementList

use of org.eclipse.sapphire.ElementList in project liferay-ide by liferay.

the class RoleNamePossibleValuesMetaService method initIfNecessary.

protected void initIfNecessary(Object object) {
    if (object instanceof WorkflowDefinition) {
        for (WorkflowNode node : ((WorkflowDefinition) object).getDiagramNodes()) {
            Assignable assignable = node.nearest(Assignable.class);
            if (assignable != null) {
                for (Role role : assignable.getRoles()) {
                    Value<String> roleName = role.getName();
                    String name = roleName.content(false);
                    if (!CoreUtil.isNullOrEmpty(name)) {
                        _originalRoleNames.add(name);
                    }
                }
            }
        }
    } else if (object instanceof AssignableOp) {
        ElementList<RoleName> roleNames = ((AssignableOp) object).getRoleNames();
        for (RoleName roleName : roleNames) {
            Value<String> nameValue = roleName.getName();
            String name = nameValue.content(false);
            if (!CoreUtil.isNullOrEmpty(name)) {
                _originalRoleNames.add(name);
            }
        }
    }
}
Also used : Role(com.liferay.ide.kaleo.core.model.Role) AssignableOp(com.liferay.ide.kaleo.core.op.AssignableOp) RoleName(com.liferay.ide.kaleo.core.model.RoleName) Value(org.eclipse.sapphire.Value) WorkflowDefinition(com.liferay.ide.kaleo.core.model.WorkflowDefinition) ElementList(org.eclipse.sapphire.ElementList) WorkflowNode(com.liferay.ide.kaleo.core.model.WorkflowNode) Assignable(com.liferay.ide.kaleo.core.model.Assignable)

Example 2 with ElementList

use of org.eclipse.sapphire.ElementList 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 3 with ElementList

use of org.eclipse.sapphire.ElementList in project liferay-ide by liferay.

the class QNamesPossibleValuesService method compute.

/**
 * (non-Javadoc)
 *
 * @see org.eclipse.sapphire.modeling.PossibleValuesService#fillPossibleValues(java.
 *      util.SortedSet)
 */
@Override
protected void compute(Set<String> values) {
    Element Element = context(Element.class);
    // values.add( param( "0" ) );
    PortletApp portletApp = context(Element.class).nearest(PortletApp.class);
    if (Element instanceof EventDefinitionRef) {
        ElementList<EventDefinition> eventDefs = portletApp.getEventDefinitions();
        for (EventDefinition eventDefinition : eventDefs) {
            if ((eventDefinition.getNamespaceURI().content() != null) && (eventDefinition.getLocalPart().content() != null)) {
                values.add(getQName(eventDefinition.getNamespaceURI().content(false), eventDefinition.getLocalPart().content()));
            }
        }
    } else if (Element instanceof SupportedPublicRenderParameter) {
        ElementList<PublicRenderParameter> publicRenderParameters = portletApp.getPublicRenderParameters();
        for (PublicRenderParameter publicRenderParam : publicRenderParameters) {
            if ((publicRenderParam.getNamespaceURI().content() != null) && (publicRenderParam.getLocalPart().content() != null)) {
                values.add(getQName(publicRenderParam.getNamespaceURI().content(false), publicRenderParam.getLocalPart().content()));
            }
        }
    }
}
Also used : EventDefinitionRef(com.liferay.ide.portlet.core.model.EventDefinitionRef) Element(org.eclipse.sapphire.Element) ElementList(org.eclipse.sapphire.ElementList) EventDefinition(com.liferay.ide.portlet.core.model.EventDefinition) SupportedPublicRenderParameter(com.liferay.ide.portlet.core.model.SupportedPublicRenderParameter) SupportedPublicRenderParameter(com.liferay.ide.portlet.core.model.SupportedPublicRenderParameter) PublicRenderParameter(com.liferay.ide.portlet.core.model.PublicRenderParameter) PortletApp(com.liferay.ide.portlet.core.model.PortletApp)

Aggregations

ElementList (org.eclipse.sapphire.ElementList)3 WorkflowDefinition (com.liferay.ide.kaleo.core.model.WorkflowDefinition)2 Assignable (com.liferay.ide.kaleo.core.model.Assignable)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 Role (com.liferay.ide.kaleo.core.model.Role)1 RoleName (com.liferay.ide.kaleo.core.model.RoleName)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 WorkflowNode (com.liferay.ide.kaleo.core.model.WorkflowNode)1 AssignableOp (com.liferay.ide.kaleo.core.op.AssignableOp)1 ChooseDiagramNode (com.liferay.ide.kaleo.core.op.ChooseDiagramNode)1 NewNodeOp (com.liferay.ide.kaleo.core.op.NewNodeOp)1 ConditionForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.ConditionForOp)1 ForkForOp (com.liferay.ide.kaleo.core.op.NewNodeOp.ForkForOp)1