use of com.centurylink.mdw.designer.display.Link 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);
}
use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.
the class FlowchartPage method markChangeType.
private void markChangeType(char changeType) {
Object obj = canvas.getSelectedObject();
if (obj instanceof Node) {
Node node = (Node) obj;
node.getChanges().setChangeType(changeType);
canvas.repaint();
} else if (obj instanceof Link) {
Link link = (Link) obj;
link.getChanges().setChangeType(changeType);
canvas.repaint();
}
}
use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.
the class RunTimeDesignerCanvas method getToolTipText.
public String getToolTipText(MouseEvent arg0) {
int x = arg0.getX();
int y = arg0.getY();
Graph process = page.getProcess();
if (process.zoom != 100) {
x = x * 100 / process.zoom;
y = y * 100 / process.zoom;
}
Object obj = objectAt(process, x, y, getGraphics());
if (obj != null && obj instanceof Node) {
Node node = (Node) obj;
List<ActivityInstanceVO> insts = node.getInstances();
if (insts != null) {
StringBuffer sb = new StringBuffer();
sb.append("<html>");
int k = 0;
for (ActivityInstanceVO one : node.getInstances()) {
sb.append(one.getId()).append(": ").append(one.getStartDate().toString()).append("<p>");
k++;
if (k >= 5)
break;
}
sb.append("</html>");
return sb.toString();
} else
return null;
} else if (obj != null && obj instanceof Link) {
Link link = (Link) obj;
List<WorkTransitionInstanceVO> insts = link.getInstances();
if (insts != null) {
StringBuffer sb = new StringBuffer();
int k = 0;
sb.append("<html>");
for (WorkTransitionInstanceVO one : link.getInstances()) {
sb.append(one.getTransitionInstanceID()).append(": ").append(one.getStartDate().toString()).append("<p>");
k++;
if (k >= 5)
break;
}
sb.append("</html>");
return sb.toString();
} else
return null;
} else
return null;
}
use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.
the class RunTimeDesignerCanvas method mouseClicked.
public void mouseClicked(MouseEvent arg0) {
if (arg0.getButton() != 1)
return;
if (arg0.getClickCount() != 2)
return;
Graph process = page.getProcess();
int x = arg0.getX();
int y = arg0.getY();
if (process.zoom != 100) {
x = x * 100 / process.zoom;
y = y * 100 / process.zoom;
}
Object obj = process.objectAt(x, y, getGraphics());
if (obj == null)
return;
if (obj instanceof Link) {
Link link = (Link) obj;
try {
List<WorkTransitionInstanceVO> workTransitionList;
Long linkId = new Long(link.conn.getWorkTransitionId());
if (link.from.graph instanceof SubGraph) {
workTransitionList = new ArrayList<WorkTransitionInstanceVO>();
SubGraph subgraph = (SubGraph) link.from.graph;
if (subgraph.getInstances() != null) {
for (ProcessInstanceVO inst : subgraph.getInstances()) {
List<WorkTransitionInstanceVO> coll1 = inst.getTransitionInstances(linkId);
workTransitionList.addAll(coll1);
}
}
} else {
workTransitionList = page.getProcessInstance().getTransitionInstances(linkId);
}
WorkTransitionsDialog workTransDialog = new WorkTransitionsDialog(page.frame);
workTransDialog.setWorkTransitionList(workTransitionList);
workTransDialog.setVisible(true);
} catch (Exception ex) {
ex.printStackTrace();
page.frame.setNewServer();
}
}
}
use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.
the class CanvasCommon method checkIfMoveIntoSubprocess.
private void checkIfMoveIntoSubprocess(Node node, int x, int y, DesignerPage page, boolean recordchange) {
if (node.graph instanceof SubGraph)
return;
Graph process = (Graph) node.graph;
for (Link l : process.links) {
if (l.from == node || l.to == node)
return;
}
for (SubGraph subgraph : process.subgraphs) {
if (subgraph.containsPoint(x, y)) {
boolean toSubproc = page.getConfirmation("Do you want to move the node into the subprocess?");
if (toSubproc) {
node.save_temp_vars();
process.removeNode(node, recordchange);
selected_obj = process.addNode(subgraph, node.nodet, 0, 0, recordchange, true);
}
break;
}
}
}
Aggregations