Search in sources :

Example 1 with Transition

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);
}
Also used : EmbeddedSubProcess(com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) Node(com.centurylink.mdw.designer.display.Node) Activity(com.centurylink.mdw.plugin.designer.model.Activity) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ActivityImpl(com.centurylink.mdw.plugin.designer.model.ActivityImpl) Note(com.centurylink.mdw.plugin.designer.model.Note) TextNote(com.centurylink.mdw.designer.display.TextNote) Transition(com.centurylink.mdw.plugin.designer.model.Transition) JSONObject(org.json.JSONObject) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) Link(com.centurylink.mdw.designer.display.Link)

Aggregations

Graph (com.centurylink.mdw.designer.display.Graph)1 Link (com.centurylink.mdw.designer.display.Link)1 Node (com.centurylink.mdw.designer.display.Node)1 SubGraph (com.centurylink.mdw.designer.display.SubGraph)1 TextNote (com.centurylink.mdw.designer.display.TextNote)1 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)1 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)1 Activity (com.centurylink.mdw.plugin.designer.model.Activity)1 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)1 EmbeddedSubProcess (com.centurylink.mdw.plugin.designer.model.EmbeddedSubProcess)1 Note (com.centurylink.mdw.plugin.designer.model.Note)1 Transition (com.centurylink.mdw.plugin.designer.model.Transition)1 JSONObject (org.json.JSONObject)1