use of org.vcell.workflow.WorkflowObject in project vcell by virtualcell.
the class WorkflowJGraphProxy method removeCells.
private void removeCells(mxEventObject event) {
// remove an existing connection
Object[] cells = (Object[]) event.getProperty("cells");
// remove edges first
for (Object cellObject : cells) {
if (cellObject instanceof mxCell) {
mxCell cell = (mxCell) cellObject;
if (cell.isEdge()) {
mxICell source = cell.getSource();
mxICell target = cell.getTarget();
if ((source instanceof WorkflowObjectCell) && (source instanceof WorkflowObjectCell)) {
WorkflowObject workflowSourceObject = ((WorkflowObjectCell) source).workflowObject;
WorkflowObject workflowTargetObject = ((WorkflowObjectCell) target).workflowObject;
if (workflowSourceObject instanceof DataOutput && workflowTargetObject instanceof DataInput) {
DataOutput output = (DataOutput) workflowSourceObject;
DataInput input = (DataInput) workflowTargetObject;
if (context.getWorkflow().getConnectorSource(input) == output) {
context.getWorkflow().removeConnector(output, input);
System.out.println("removed edge from " + workflowSourceObject.getPath() + " to " + workflowTargetObject.getPath());
} else {
System.out.println("can't remove edge, edge from " + output.getPath() + " to " + input.getPath() + " not found in workflow");
}
} else {
System.out.println("can't remove edge, edge from " + source.getId() + " to " + target.getId() + " not found in workflow");
}
}
}
}
}
// remove tasks next
for (Object cellObject : cells) {
if (cellObject instanceof mxCell) {
mxCell cell = (mxCell) cellObject;
if (!cell.isEdge() && cell instanceof WorkflowObjectCell) {
WorkflowObject workflowObject = ((WorkflowObjectCell) cell).workflowObject;
if (workflowObject instanceof Task) {
context.getWorkflow().removeTask((Task) workflowObject);
System.out.println("removed task " + workflowObject.getPath());
} else {
System.out.println("can't remove non-edge cell " + cell.getId() + " not a task in this workflow");
}
}
}
}
}
Aggregations