Search in sources :

Example 11 with Link

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);
}
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)

Example 12 with Link

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();
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Link(com.centurylink.mdw.designer.display.Link)

Example 13 with Link

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;
}
Also used : WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) ActivityInstanceVO(com.centurylink.mdw.model.value.work.ActivityInstanceVO) Node(com.centurylink.mdw.designer.display.Node) ArrayList(java.util.ArrayList) List(java.util.List) Link(com.centurylink.mdw.designer.display.Link)

Example 14 with Link

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();
        }
    }
}
Also used : WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO)

Example 15 with Link

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;
        }
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link)

Aggregations

Link (com.centurylink.mdw.designer.display.Link)18 SubGraph (com.centurylink.mdw.designer.display.SubGraph)15 Node (com.centurylink.mdw.designer.display.Node)14 Graph (com.centurylink.mdw.designer.display.Graph)9 TextNote (com.centurylink.mdw.designer.display.TextNote)8 GraphFragment (com.centurylink.mdw.designer.display.GraphFragment)7 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)3 WorkTransitionInstanceVO (com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO)3 Rectangle (java.awt.Rectangle)3 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)2 Graphics2D (java.awt.Graphics2D)2 Label (com.centurylink.mdw.designer.display.Label)1 Selectable (com.centurylink.mdw.designer.display.Selectable)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 BasicStroke (java.awt.BasicStroke)1 Dimension (java.awt.Dimension)1