Search in sources :

Example 11 with WorkflowObject

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");
                }
            }
        }
    }
}
Also used : DataInput(org.vcell.workflow.DataInput) com.mxgraph.model.mxICell(com.mxgraph.model.mxICell) DataOutput(org.vcell.workflow.DataOutput) Task(org.vcell.workflow.Task) com.mxgraph.model.mxCell(com.mxgraph.model.mxCell) com.mxgraph.util.mxEventObject(com.mxgraph.util.mxEventObject) WorkflowObject(org.vcell.workflow.WorkflowObject) DataObject(org.vcell.workflow.DataObject) WorkflowObject(org.vcell.workflow.WorkflowObject)

Aggregations

WorkflowObject (org.vcell.workflow.WorkflowObject)11 DataInput (org.vcell.workflow.DataInput)7 DataOutput (org.vcell.workflow.DataOutput)6 Task (org.vcell.workflow.Task)6 Image (cbit.vcell.VirtualMicroscopy.Image)3 ROI (cbit.vcell.VirtualMicroscopy.ROI)3 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)3 ImageTimeSeries (org.vcell.vmicro.workflow.data.ImageTimeSeries)3 DataObject (org.vcell.workflow.DataObject)3 WorkflowDataSource (org.vcell.workflow.WorkflowDataSource)3 com.mxgraph.model.mxCell (com.mxgraph.model.mxCell)2 com.mxgraph.model.mxICell (com.mxgraph.model.mxICell)2 com.mxgraph.util.mxEventObject (com.mxgraph.util.mxEventObject)2 WindowAdapter (java.awt.event.WindowAdapter)2 WindowListener (java.awt.event.WindowListener)2 ProfileData (org.vcell.optimization.ProfileData)2 Workflow (org.vcell.workflow.Workflow)2 WorkflowParameter (org.vcell.workflow.WorkflowParameter)2 ImageException (cbit.image.ImageException)1 ExpressionException (cbit.vcell.parser.ExpressionException)1