use of com.liferay.ide.kaleo.core.model.Condition 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);
}
use of com.liferay.ide.kaleo.core.model.Condition in project liferay-ide by liferay.
the class ConditionNodeAddActionHandler method postDiagramNodePartAdded.
@Override
public void postDiagramNodePartAdded(NewNodeOp op, CanTransition newNodeFromWizard, CanTransition newNode) {
Condition newConditionNodeFromWizard = op.nearest(NewConditionNodeOp.class).getNewConditionNode();
Condition newCondition = newNode.nearest(Condition.class);
newCondition.setScriptLanguage(newConditionNodeFromWizard.getScriptLanguage().content());
newCondition.setScript(KaleoUI.getDefaultScriptForType(newCondition.getScriptLanguage().content(), Condition.TYPE.getSimpleName()));
}
use of com.liferay.ide.kaleo.core.model.Condition in project liferay-ide by liferay.
the class NodeNameListener method handleTypedEvent.
@Override
protected void handleTypedEvent(PropertyContentEvent event) {
Property property = event.property();
Element element = property.element();
WorkflowDefinition workflow = element.adapt(WorkflowDefinition.class);
Map<String, String> eventInfo = new HashMap<>();
event.fillTracingInfo(eventInfo);
String oldName = eventInfo.get("before");
if (oldName == null) {
oldName = _lastNodeNames.get(property);
}
String newName = eventInfo.get("after");
List<Transition> allTransitions = new ArrayList<>();
if (workflow != null) {
ElementList<Condition> allConditions = workflow.getConditions();
ElementList<Fork> allForks = workflow.getForks();
ElementList<Join> allJoins = workflow.getJoins();
ElementList<State> allStates = workflow.getStates();
ElementList<Task> allTasks = workflow.getTasks();
for (Condition condition : allConditions) {
ElementList<Transition> conditionTransitions = condition.getTransitions();
for (Transition transition : conditionTransitions) {
allTransitions.add(transition);
}
}
for (Fork fork : allForks) {
ElementList<Transition> forkTransitions = fork.getTransitions();
for (Transition transition : forkTransitions) {
allTransitions.add(transition);
}
}
for (Join join : allJoins) {
ElementList<Transition> joinTransitions = join.getTransitions();
for (Transition transition : joinTransitions) {
allTransitions.add(transition);
}
}
for (State state : allStates) {
ElementList<Transition> stateTransitions = state.getTransitions();
for (Transition transition : stateTransitions) {
allTransitions.add(transition);
}
}
for (Task task : allTasks) {
ElementList<Transition> taskTransitions = task.getTransitions();
for (Transition transition : taskTransitions) {
allTransitions.add(transition);
}
}
}
for (Transition transition : allTransitions) {
String targetName = transition.getTarget().toString();
if (targetName.equals(oldName)) {
if (newName != null) {
transition.setTarget(newName);
if (_lastNodeNames.containsKey(property)) {
_lastNodeNames.remove(property);
}
} else {
_lastNodeNames.put(property, oldName);
}
}
}
}
Aggregations