Search in sources :

Example 6 with TextNote

use of com.centurylink.mdw.designer.display.TextNote 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 7 with TextNote

use of com.centurylink.mdw.designer.display.TextNote 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 8 with TextNote

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

the class ProcessCanvasWrapper method addNote.

public void addNote(int x, int y) {
    TextNote note = getFlowchartPage().getProcess().addTextNote(x, y, "");
    getFlowchartPage().canvas.setSelectedObject(note);
    getFlowchartPage().canvas.requestFocus();
    getFlowchartPage().canvas.repaint();
}
Also used : TextNote(com.centurylink.mdw.designer.display.TextNote)

Example 9 with TextNote

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

the class FlowchartPage method addNote.

private void addNote() {
    if (!process.getProcessVO().isInRuleSet()) {
        showError("Notes can only be added to processes stored in RULE_SET table");
        return;
    }
    Rectangle rect = canvas.getVisibleRect();
    TextNote note = process.addTextNote(rect.x + 100, rect.y + 100, "Enter note content here");
    canvas.setSelectedObject(note);
    canvas.requestFocus();
    canvas.repaint();
}
Also used : Rectangle(java.awt.Rectangle) TextNote(com.centurylink.mdw.designer.display.TextNote)

Example 10 with TextNote

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

the class CanvasCommon method keyPressed.

protected void keyPressed(KeyEvent arg0, Graph main_graph, DesignerPage page, boolean recordchange) {
    if (useLabelEditor && arg0.getSource() == labelEditor) {
        return;
    }
    if (main_graph.isReadonly())
        return;
    int keycode = arg0.getKeyCode();
    char ch = arg0.getKeyChar();
    if (selected_obj != null) {
        if ((useLabelEditor && editing_obj != null) || (!useLabelEditor && textEditor != null)) {
        // do not need to do any thing - handled by editor
        } else if (selected_obj instanceof Node) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the node?")) {
                    main_graph.removeNode((Node) selected_obj, recordchange);
                    selected_obj = null;
                    repaint();
                }
            } else if (ch != KeyEvent.CHAR_UNDEFINED && !arg0.isControlDown()) {
                String label = ((Node) selected_obj).getName();
                if (label == null)
                    label = "";
                if (keycode != KeyEvent.VK_BACK_SPACE) {
                    label = label + ch;
                    updateLabel(selected_obj, label, main_graph);
                }
                openLabelEditor((Node) selected_obj, main_graph.zoom);
                repaint();
            } else {
                if (keycode == KeyEvent.VK_DOWN || keycode == KeyEvent.VK_UP || keycode == KeyEvent.VK_LEFT || keycode == KeyEvent.VK_RIGHT) {
                    handleArrowKey(keycode, arg0, (Node) selected_obj, main_graph);
                }
            }
        } else if (selected_obj instanceof Link) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the link?")) {
                    main_graph.removeLink((Link) selected_obj, recordchange);
                    selected_obj = null;
                    repaint();
                }
            } else if (ch != KeyEvent.CHAR_UNDEFINED) {
                String label = ((Link) selected_obj).getLabelAndEventType();
                if (label == null)
                    label = "";
                if (label.length() == 0)
                    ((Link) selected_obj).calcLinkLabelPosition();
                if (keycode != KeyEvent.VK_BACK_SPACE) {
                    label = label + ch;
                    updateLabel(selected_obj, label, main_graph);
                }
                openLabelEditor((Link) selected_obj, main_graph.zoom);
                repaint();
            } else {
                if (keycode == KeyEvent.VK_DOWN || keycode == KeyEvent.VK_UP || keycode == KeyEvent.VK_LEFT || keycode == KeyEvent.VK_RIGHT) {
                    if (at_anchor >= 0) {
                        Link link = (Link) selected_obj;
                        int x = link.getControlPointX(at_anchor);
                        int y = link.getControlPointY(at_anchor);
                        switch(keycode) {
                            case KeyEvent.VK_UP:
                                y--;
                                break;
                            case KeyEvent.VK_DOWN:
                                y++;
                                break;
                            case KeyEvent.VK_LEFT:
                                x--;
                                break;
                            case KeyEvent.VK_RIGHT:
                                x++;
                                break;
                        }
                        link.moveControlPoint(at_anchor, x, y, main_graph.arrowstyle);
                        arg0.consume();
                        repaint();
                    }
                }
            }
        } else if (selected_obj instanceof SubGraph) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the embedded process?")) {
                    main_graph.removeSubGraph((SubGraph) selected_obj);
                    selected_obj = null;
                    repaint();
                }
            }
        } else if (selected_obj instanceof GraphFragment) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the selected objects?")) {
                    GraphFragment frag = (GraphFragment) selected_obj;
                    for (Link l : frag.links) {
                        main_graph.removeLink(l, recordchange);
                    }
                    for (Node n : frag.nodes) {
                        main_graph.removeNode(n, recordchange);
                    }
                    for (SubGraph sg : frag.subgraphs) {
                        main_graph.removeSubGraph(sg);
                    }
                    selected_obj = null;
                    repaint();
                }
            }
        } else if (selected_obj instanceof TextNote) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the selected note?")) {
                    main_graph.removeTextNote((TextNote) selected_obj);
                    selected_obj = null;
                    repaint();
                }
            }
        }
    }
}
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) Link(com.centurylink.mdw.designer.display.Link)

Aggregations

TextNote (com.centurylink.mdw.designer.display.TextNote)13 SubGraph (com.centurylink.mdw.designer.display.SubGraph)9 Link (com.centurylink.mdw.designer.display.Link)8 Node (com.centurylink.mdw.designer.display.Node)8 Graph (com.centurylink.mdw.designer.display.Graph)5 GraphFragment (com.centurylink.mdw.designer.display.GraphFragment)5 Rectangle (java.awt.Rectangle)3 Label (com.centurylink.mdw.designer.display.Label)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 BasicStroke (java.awt.BasicStroke)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 Point (java.awt.Point)1 ImageIcon (javax.swing.ImageIcon)1