use of com.centurylink.mdw.plugin.designer.model.Transition in project mdw-designer by CenturyLinkCloud.
the class ProcessCanvasWrapper method handleSelection.
private void handleSelection(MouseEvent mouseEvent) {
Graph lProcess = null;
if (isInstance())
lProcess = getProcessInstancePage().getProcess();
else
lProcess = getFlowchartPage().getProcess();
int mouseX = mouseEvent.getX();
int mouseY = mouseEvent.getY();
if (lProcess.zoom != 100) {
mouseX = mouseX * 100 / lProcess.zoom;
mouseY = mouseY * 100 / lProcess.zoom;
}
Object obj = null;
if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
if (isInstance())
obj = getProcessInstancePage().canvas.objectAt(lProcess, mouseX, mouseY, getProcessInstancePage().canvas.getGraphics());
else
obj = getFlowchartPage().canvas.objectAt(lProcess, mouseX, mouseY, getFlowchartPage().canvas.getGraphics());
} else {
obj = lProcess.objectAt(mouseX, mouseY, isInstance() ? getProcessInstancePage().canvas.getGraphics() : getFlowchartPage().canvas.getGraphics());
}
if (obj != null) {
DesignerProxy designerProxy = getProcess().getProject().getDesignerProxy();
// create the appropriate DesignerCanvasSelection
if (obj instanceof Node) {
ActivityImpl actImpl = getProcess().getProject().getActivityImpl(((Node) obj).nodet.getImplementorClassName());
Activity activity = new Activity((Node) obj, getProcess(), actImpl);
if (isInstance()) {
activity.setProcessInstance(getProcess().getProcessInstance());
List<ActivityInstanceVO> activityInstances = getProcess().getProcessInstance().getActivityInstances(activity.getId());
if (activityInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
// try embedded subprocess instances
for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) activityInstances.addAll(embeddedSubProcessInstance.getActivityInstances(activity.getId()));
}
activity.setInstances(activityInstances);
if (activity.isManualTask()) {
activity.setTaskInstances(getProcess().getMainTaskInstances(activity.getId()));
activity.setSubTaskInstances(getProcess().getSubTaskInstances(activity.getId()));
}
if (activity.isSubProcessInvoke()) {
// TODO: load subprocess instances when process instance
// id loaded (like manual task instances above)
List<ProcessInstanceVO> subProcessInstances = designerProxy.getSubProcessInstances(getProcess(), activity);
if (subProcessInstances.isEmpty() && getProcess().getEmbeddedSubProcessInstances() != null) {
for (ProcessInstanceVO embeddedSubProcessInstance : getProcess().getEmbeddedSubProcessInstances()) subProcessInstances.addAll(designerProxy.getSubProcessInstances(embeddedSubProcessInstance, activity));
}
activity.setSubProcessInstances(subProcessInstances);
}
} else {
if (activity.getLogicalId() == null)
activity.setLogicalId(lProcess.generateLogicalId("A"));
if (Node.ID_SEQUENCE.equals(getNodeIdType()) && activity.getSequenceId() == 0)
lProcess.assignSequenceIds();
}
designerCanvasSelection = activity;
} else if (obj instanceof Link) {
Transition transition = new Transition((Link) obj, getProcess());
if (isInstance())
transition.setInstances(getProcess().getProcessInstance().getTransitionInstances(transition.getId()));
designerCanvasSelection = transition;
} else if (obj instanceof SubGraph) {
EmbeddedSubProcess embeddedSubProcess = new EmbeddedSubProcess((SubGraph) obj, getProcess());
if (isInstance()) {
embeddedSubProcess.setSubProcessInstances(((SubGraph) obj).getInstances());
}
designerCanvasSelection = embeddedSubProcess;
} else if (obj instanceof TextNote) {
TextNote textNote = (TextNote) obj;
Note note = new Note(textNote, getProcess());
designerCanvasSelection = note;
} else {
designerCanvasSelection = getProcess();
}
} else {
designerCanvasSelection = getProcess();
}
designerCanvasSelection.addDirtyStateListener(this);
}
Aggregations