Search in sources :

Example 6 with Link

use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.

the class CanvasCommon method mouseReleased.

protected void mouseReleased(MouseEvent arg0, Graph main_graph, String curr_link_type, DesignerPage page, boolean recordchange) {
    // if (main_graph.isReadonly()) return;
    int x = arg0.getX();
    int y = arg0.getY();
    if (main_graph.zoom != 100) {
        x = x * 100 / main_graph.zoom;
        y = y * 100 / main_graph.zoom;
    }
    Object obj = main_graph.objectAt(x, y, getGraphics());
    if (arg0.getButton() != 1) {
        if (arg0.isPopupTrigger() && obj != null) {
            JPopupMenu popup;
            if (obj instanceof Node) {
                popup = this.popup_activity;
                selected_obj = obj;
            } else if (obj instanceof Link) {
                popup = this.popup_transition;
                selected_obj = obj;
            } else
                popup = null;
            if (popup != null) {
                popup.show(this, arg0.getX(), arg0.getY());
            }
        }
        return;
    }
    if (dragging) {
        if (drag_to_create_link) {
            Node startnode = (Node) selected_obj;
            Node endnode = (obj != null && (obj instanceof Node)) ? (Node) obj : null;
            if (endnode != null && endnode.graph.equals(startnode.graph)) {
                int ctrl_pts = 2;
                String linktype = curr_link_type;
                if (endnode == startnode) {
                    linktype = Link.CURVE;
                } else if (linktype.equals(Link.CURVE)) {
                    ctrl_pts = 4;
                }
                Link conn = main_graph.addLink(startnode, endnode, EventType.FINISH, linktype, ctrl_pts, recordchange);
                selected_obj = conn;
            } else
                selected_obj = null;
        } else if (selected_obj instanceof Link && at_anchor >= 0) {
            Link link = (Link) selected_obj;
            Node node = (obj != null && (obj instanceof Node)) ? (Node) obj : null;
            if (link.to == link.from) {
                // a link to the node itself
                if (at_anchor == 0 && (node == null || node != link.from)) {
                    // move back to the node
                    moveBackFrom(link, main_graph.arrowstyle);
                }
            } else if (at_anchor == 0) {
                if (node == null || node == link.to) {
                    // move back to the node
                    moveBackFrom(link, main_graph.arrowstyle);
                } else if (node != link.from && node.graph.equals(link.from.graph)) {
                    // change 'from'
                    link.setFrom(node);
                }
            // else do nothing
            } else if (at_anchor == link.getNumberOfControlPoints() - 1) {
                if (node == null || node == link.from) {
                    // move back to the node
                    moveBackTo(link, main_graph.arrowstyle);
                } else if (node != link.to && node.graph.equals(link.to.graph)) {
                    // change 'to'
                    link.setTo(node);
                }
            // else do nothing
            } else {
                // a middle link
                if (link.isElbowType()) {
                    if (at_anchor == 1) {
                        moveBackFrom(link, main_graph.arrowstyle);
                    }
                    if (at_anchor == link.getNumberOfControlPoints() - 2) {
                        moveBackTo(link, main_graph.arrowstyle);
                    }
                }
            }
        } else if (selected_obj instanceof SubGraph) {
            mouseReleased_subgraph();
        } else if (selected_obj instanceof Node && at_anchor < 0) {
            // move node
            checkIfMoveIntoSubprocess((Node) selected_obj, x, y, page, recordchange);
        }
        repaint();
        dragging = false;
    // } else if (useLabelEditor && editing_obj!=null) {
    // labelEditor.setZoom(main_graph.zoom);
    // labelEditor.setVisible(true);
    // repaint();  // TODO do we need this?
    } else if (useLabelEditor && obj != null && at_anchor == -2) {
        if (obj instanceof Node) {
            if (!main_graph.isReadonly()) {
                openLabelEditor((Node) obj, main_graph.zoom);
            }
        } else if (obj instanceof Link) {
            if (!main_graph.isReadonly()) {
                openLabelEditor((Link) obj, main_graph.zoom);
            }
        }
    // else not possible (TextNote never has at_anchor==-2)
    } else if (useLabelEditor && obj instanceof TextNote || !useLabelEditor && textEditor != null) {
        if (!main_graph.isReadonly()) {
            openLabelEditor((TextNote) obj, main_graph.zoom);
        }
    } else if (marquee != null) {
        GraphFragment frag = new GraphFragment(main_graph, marquee);
        if (!frag.isEmpty()) {
            if (frag.isNode())
                selected_obj = frag.getOnlyNode();
            else if (frag.isSubGraph())
                selected_obj = frag.getOnlySubGraph();
            else
                selected_obj = frag;
        }
        marquee = null;
        repaint();
    }
    drag_to_create_link = false;
}
Also used : Node(com.centurylink.mdw.designer.display.Node) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) JPopupMenu(javax.swing.JPopupMenu) Link(com.centurylink.mdw.designer.display.Link)

Example 7 with Link

use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.

the class FlowchartPage method actionPerformed.

public void actionPerformed(ActionEvent event) {
    String cmd = event.getActionCommand();
    if (cmd.equals(Constants.ACTION_DELETE)) {
        if (process.isReadonly()) {
            return;
        }
        if (canvas.getSelectedObject() != null) {
            if (canvas.getSelectedObject() instanceof Node) {
                if (getConfirmation("Are you sure you want to delete the node?")) {
                    process.removeNode((Node) canvas.getSelectedObject(), this.recordchange);
                }
            } else if (canvas.getSelectedObject() instanceof Link) {
                if (getConfirmation("Are you sure you want to delete the link?")) {
                    process.removeLink((Link) canvas.getSelectedObject(), this.recordchange);
                }
            } else if (canvas.getSelectedObject() instanceof SubGraph) {
                if (getConfirmation("Are you sure you want to delete the handler?")) {
                    process.removeSubGraph((SubGraph) canvas.getSelectedObject());
                }
            } else if (canvas.getSelectedObject() instanceof GraphFragment) {
                if (getConfirmation("Are you sure you want to delete the selected objects?")) {
                    GraphFragment frag = (GraphFragment) canvas.getSelectedObject();
                    for (Link l : frag.links) {
                        process.removeLink(l, recordchange);
                    }
                    for (Node n : frag.nodes) {
                        process.removeNode(n, recordchange);
                    }
                    for (SubGraph sg : frag.subgraphs) {
                        // TODO record changes
                        process.removeSubGraph(sg);
                    }
                }
            } else if (canvas.getSelectedObject() instanceof TextNote) {
                if (getConfirmation("Are you sure you want to delete the note?")) {
                    process.removeTextNote((TextNote) canvas.getSelectedObject());
                }
            }
            canvas.setSelectedObject(null);
            canvas.repaint();
        }
    } else if (cmd.equals(Constants.ACTION_TIPMODE)) {
        JCheckBox tipMode = (JCheckBox) event.getSource();
        showtip = tipMode.isSelected();
    } else if (cmd.equals(ACTION_RECORD_CHANGES)) {
        JCheckBox checkbox = (JCheckBox) event.getSource();
        recordchange = checkbox.isSelected();
    } else if (cmd.equals(ACTION_SHOW_ID)) {
        if (process != null) {
            JComboBox showId = (JComboBox) event.getSource();
            process.setNodeIdType((String) showId.getSelectedItem());
            canvas.repaint();
        }
    // else during init
    } else if (cmd.equals(Constants.ACTION_START)) {
        showStartProcessDialog(null);
    } else if (cmd.equals(ACTION_RUN_ACTIVITY)) {
        if (model.canExecuteProcess(process.getProcessVO())) {
            Node node = (Node) canvas.getSelectedObject();
            showStartProcessDialog(node);
        } else
            this.showError("You are not authorized to run processes");
    } else if (cmd.equals(ACTION_ARROWTYPE)) {
        JComboBox arrowType = (JComboBox) event.getSource();
        ImageIcon arrowTypeIcon = (ImageIcon) arrowType.getSelectedItem();
        setArrowStyle(arrowTypeIcon.getDescription());
    } else if (cmd.equals(ACTION_NODETYPE)) {
        JComboBox nodeType = (JComboBox) event.getSource();
        ImageIcon nodeTypeIcon = (ImageIcon) nodeType.getSelectedItem();
        setNodeStyle(nodeTypeIcon.getDescription());
    } else if (cmd.equals(ACTION_ZOOM)) {
        int zoomLevel = Graph.zoomLevels[zoomWidget.getSelectedIndex()];
        canvas.zoom(process, zoomLevel);
    } else if (cmd.equals(ACTION_ALL_LINK_STYLE_CHANGE)) {
        process.changeAllLinkStyle(this.linktype);
        canvas.repaint();
    } else if (cmd.equals(ACTION_COMMIT_CHANGES)) {
        if (process.isReadonly()) {
            return;
        }
        if (getConfirmation("This will commit recorded changes. Proceed?")) {
            process.commitChanges();
            canvas.repaint();
        }
    } else if (cmd.equals(ACTION_MARK_AS_NEW)) {
        markChangeType(Changes.NEW);
    } else if (cmd.equals(ACTION_MARK_AS_DELETED)) {
        markChangeType(Changes.DELETE);
    } else if (cmd.equals(ACTION_MARK_AS_NOCHANGE)) {
        markChangeType(Changes.NONE);
    } else if (cmd.equals(ACTION_LINEUP_HORIZONTAL)) {
        lineUpActivities(false);
    } else if (cmd.equals(ACTION_LINEUP_VERTICAL)) {
        lineUpActivities(true);
    } else if (cmd.equals(ACTION_ADD_NOTE)) {
        if (process.isReadonly()) {
            return;
        }
        addNote();
    } else {
        super.actionPerformed(event);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) ImageIcon(javax.swing.ImageIcon) JComboBox(javax.swing.JComboBox) Node(com.centurylink.mdw.designer.display.Node) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link) Point(java.awt.Point)

Example 8 with Link

use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.

the class ProcessInstanceUpdater method updateTransitionInstance.

private void updateTransitionInstance(ProcessInstancePage procInstPage, Long procId, Long procInstId, String timestr, String id, String msg) {
    ProcessInstanceVO procInst = procInstPage.getProcessInstance();
    if (!isShowingThisInstance(procInst.getId()))
        this.showInstance(procInstPage);
    int k = id.indexOf('.');
    String transId = id.substring(0, k);
    String transInstId = id.substring(k + 1);
    Link link;
    if (!procInst.getId().equals(procInstId)) {
        // embedded process
        link = findLinkInSubgraph(procInstPage.getProcess(), new Long(transId));
        procInst = this.findEmbeddedProcessInstance(procInstPage.getProcess(), procInstId);
    } else {
        link = procInstPage.getProcess().findLink(new Long(transId));
    }
    if (link != null) {
        WorkTransitionInstanceVO transInst = null;
        for (WorkTransitionInstanceVO ti : procInst.getTransitions()) {
            if (ti.getTransitionInstanceID().toString().equals(transInstId)) {
                transInst = ti;
                break;
            }
        }
        // Date time = df.parse(timestr);
        if (transInst == null) {
            transInst = new WorkTransitionInstanceVO();
            procInst.getTransitions().add(transInst);
            transInst.setTransitionID(new Long(transId));
            transInst.setTransitionInstanceID(new Long(transInstId));
            transInst.setProcessInstanceID(procInst.getId());
            transInst.setStartDate(timestr);
            transInst.setEndDate(timestr);
            transInst.setStatusCode(WorkTransitionStatus.STATUS_COMPLETED);
            link.addInstance(transInst);
        }
    } else {
        System.out.println("Cannot find link with ID " + transId);
    }
    procInstPage.repaint();
}
Also used : WorkTransitionInstanceVO(com.centurylink.mdw.model.value.work.WorkTransitionInstanceVO) ProcessInstanceVO(com.centurylink.mdw.model.value.process.ProcessInstanceVO) Link(com.centurylink.mdw.designer.display.Link)

Example 9 with Link

use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.

the class RunTimeDesignerCanvas method paintComponent.

/*
     * (non-Javadoc)
     *
     * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
     */
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graph process = page.getProcess();
    if (process != null) {
        if (g instanceof Graphics2D) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
            if (process.zoom != 100) {
                double scale = process.zoom / 100.0;
                g2d.scale(scale, scale);
            }
        }
        draw_graph(g, process, true);
        if (page.frame != null && !page.frame.isVisible() && selected_obj != null) {
            if (selected_obj instanceof Node) {
                drawSelectionBox(g, (Node) selected_obj);
            } else if (selected_obj instanceof Link) {
                drawSelectionBox(g, (Link) selected_obj);
            } else if (selected_obj instanceof SubGraph) {
                drawSelectionBox(g, (SubGraph) selected_obj);
            } else if (selected_obj instanceof Graph) {
                drawSelectionBox(g, (Graph) selected_obj);
            }
        }
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Node(com.centurylink.mdw.designer.display.Node) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link) Graphics2D(java.awt.Graphics2D)

Example 10 with Link

use of com.centurylink.mdw.designer.display.Link in project mdw-designer by CenturyLinkCloud.

the class RunTimeDesignerCanvas method mouseReleased.

public void mouseReleased(MouseEvent arg0) {
    if (arg0.getButton() == 1)
        return;
    if (!arg0.isPopupTrigger())
        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 Selectable) {
    // JPopupMenu popup = this.popup_activity; // TODO
    // if (popup!=null) popup.show(this, arg0.getX(), arg0.getY());
    } else if (obj instanceof Link) {
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Selectable(com.centurylink.mdw.designer.display.Selectable) 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