use of com.centurylink.mdw.designer.display.Node 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.Node in project mdw-designer by CenturyLinkCloud.
the class FlowchartPage method lineUpActivities.
private void lineUpActivities(boolean vertical) {
Object selectedObj = canvas.getSelectedObject();
if (selectedObj == null || !(selectedObj instanceof GraphFragment)) {
this.showError("You need to select at least 2 activities to line up");
return;
}
GraphFragment marquee = (GraphFragment) selectedObj;
if (marquee.nodes.size() < 2) {
this.showError("You need to select at least 2 activities to line up");
return;
}
if (vertical) {
Node topmost = null;
for (Node n : marquee.nodes) {
if (topmost == null || n.y < topmost.y)
topmost = n;
}
for (Node n : marquee.nodes) {
if (n == topmost)
continue;
if (topmost != null)
n.x = topmost.x + topmost.w / 2 - n.w / 2;
process.recalcLinkPosition(n, process.arrowstyle);
}
canvas.repaint();
} else {
Node leftmost = null;
for (Node n : marquee.nodes) {
if (leftmost == null || n.x < leftmost.x)
leftmost = n;
}
for (Node n : marquee.nodes) {
if (n == leftmost)
continue;
if (leftmost != null)
n.y = leftmost.y + leftmost.h / 2 - n.h / 2;
process.recalcLinkPosition(n, process.arrowstyle);
}
canvas.repaint();
}
}
use of com.centurylink.mdw.designer.display.Node in project mdw-designer by CenturyLinkCloud.
the class ProcessInstanceUpdater method updateActivityInstance.
private void updateActivityInstance(ProcessInstancePage procInstPage, Long procId, Long procInstId, String timestr, String id, String msg) {
ProcessInstanceVO procInst = procInstPage.getProcessInstance();
if (!isShowingThisInstance(procInst.getId()))
showInstance(procInstPage);
int k = id.indexOf('.');
String actId = id.substring(0, k);
String actInstId = id.substring(k + 1);
Node node;
if (!procInst.getId().equals(procInstId)) {
// embedded process
node = this.findNodeInSubgraph(procInstPage.getProcess(), new Long(actId));
procInst = this.findEmbeddedProcessInstance(procInstPage.getProcess(), procInstId);
} else {
node = procInstPage.getProcess().findNode(new Long(actId));
}
if (node != null) {
ActivityInstanceVO actInst = null;
for (ActivityInstanceVO ai : procInst.getActivities()) {
if (ai.getId().toString().equals(actInstId)) {
actInst = ai;
break;
}
}
if (actInst == null) {
actInst = new ActivityInstanceVO();
procInst.getActivities().add(actInst);
actInst.setId(new Long(actInstId));
actInst.setDefinitionId(new Long(actId));
actInst.setOwnerId(procInst.getId());
actInst.setStartDate(timestr);
actInst.setStatusCode(WorkStatus.STATUS_IN_PROGRESS);
node.addInstance(actInst, false);
}
if (msg.startsWith(WorkStatus.LOGMSG_COMPLETE)) {
actInst.setEndDate(timestr);
actInst.setStatusCode(WorkStatus.STATUS_COMPLETED);
node.setInstanceStatus(actInst);
} else if (msg.startsWith(WorkStatus.LOGMSG_START)) {
// do nothing - already loaded by code above or by full load
} else if (msg.startsWith(WorkStatus.LOGMSG_FAILED)) {
actInst.setEndDate(timestr);
actInst.setStatusCode(WorkStatus.STATUS_FAILED);
node.setInstanceStatus(actInst);
} else if (msg.startsWith(WorkStatus.LOGMSG_SUSPEND)) {
actInst.setStatusCode(WorkStatus.STATUS_WAITING);
node.setInstanceStatus(actInst);
} else if (msg.startsWith(WorkStatus.LOGMSG_HOLD)) {
actInst.setStatusCode(WorkStatus.STATUS_HOLD);
node.setInstanceStatus(actInst);
} else {
// System.out.println("How to handle activity message '" + msg +"'?");
}
Rectangle aRect = new java.awt.Rectangle(node.x - 10, node.y - 10, node.w + 20, node.h + 30);
procInstPage.canvas.scrollRectToVisible(aRect);
} else {
System.out.println("Cannot find node with ID " + actId);
}
procInstPage.repaint();
}
use of com.centurylink.mdw.designer.display.Node 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.Node in project mdw-designer by CenturyLinkCloud.
the class RunTimeDesignerCanvas method mouseDragged.
public void mouseDragged(MouseEvent arg0) {
Graph process = page.getProcess();
// if (process.isReadonly()) return;
if (selected_obj != null) {
int x = arg0.getX();
int y = arg0.getY();
if (process.zoom != 100) {
x = x * 100 / process.zoom;
y = y * 100 / process.zoom;
}
if (selected_obj instanceof Node) {
moveNode(x, y);
} else if (selected_obj instanceof SubGraph) {
moveSubgraph(x, y);
} else if (selected_obj instanceof Graph) {
moveGraphLabel(x, y);
}
repaint();
}
}
Aggregations