Пример #1
0
 /** Execute */
 public void execute() {
   //	Add Line
   if (m_node != null && m_AD_WF_NodeTo_ID > 0) {
     int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
     MWFNodeNext newLine = new MWFNodeNext(m_node, m_AD_WF_NodeTo_ID);
     newLine.setClientOrg(AD_Client_ID, 0);
     newLine.save();
     log.info("Add Line to " + m_node + " -> " + newLine);
     m_parent.load(m_wf.getAD_Workflow_ID(), true);
   }
   //	Delete Node
   else if (m_node != null && m_AD_WF_NodeTo_ID == -1) {
     log.info("Delete Node: " + m_node);
     m_node.delete(false);
     m_parent.load(m_wf.getAD_Workflow_ID(), true);
   }
   //	Delete Line
   else if (m_line != null) {
     log.info("Delete Line: " + m_line);
     m_line.delete(false);
     m_parent.load(m_wf.getAD_Workflow_ID(), true);
   } else log.severe("No Action??");
 } //	execute
Пример #2
0
  /**
   * ************************************************************************ Mouse Clicked. Pressed
   * - Released - Clicked.
   *
   * @param e event
   */
  public void mouseClicked(MouseEvent e) {
    if (m_readWrite && SwingUtilities.isRightMouseButton(e)) {
      int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
      if (e.getSource() == this && m_wf != null) {
        m_NewPopupMenu.show(this, e.getX(), e.getY());
      } else if (e.getSource() instanceof WFNode) {
        MWFNode node = ((WFNode) e.getSource()).getModel();
        m_LinePopupMenu = new JPopupMenu(node.getName());
        if (node.getAD_Client_ID() == AD_Client_ID) {
          String title = Msg.getMsg(Env.getCtx(), "DeleteNode") + ": " + node.getName();
          addMenuItem(m_LinePopupMenu, title, node, -1);
          m_LinePopupMenu.addSeparator();
        }
        MWFNode[] nodes = m_wf.getNodes(true, AD_Client_ID);
        MWFNodeNext[] lines = node.getTransitions(AD_Client_ID);
        //	Add New Line
        for (int n = 0; n < nodes.length; n++) {
          MWFNode nn = nodes[n];
          if (nn.getAD_WF_Node_ID() == node.getAD_WF_Node_ID()) continue; // 	same
          boolean found = false;
          for (int i = 0; i < lines.length; i++) {
            MWFNodeNext line = lines[i];
            if (nn.getAD_WF_Node_ID() == line.getAD_WF_Next_ID()) {
              found = true;
              break;
            }
          }
          if (!found) {
            String title =
                Msg.getMsg(Env.getCtx(), "AddLine") + ": " + node.getName() + " -> " + nn.getName();
            addMenuItem(m_LinePopupMenu, title, node, nn.getAD_WF_Node_ID());
          }
        }
        m_LinePopupMenu.addSeparator();
        //	Delete Lines
        for (int i = 0; i < lines.length; i++) {
          MWFNodeNext line = lines[i];
          if (line.getAD_Client_ID() != AD_Client_ID) continue;
          MWFNode next = MWFNode.get(Env.getCtx(), line.getAD_WF_Next_ID());
          String title =
              Msg.getMsg(Env.getCtx(), "DeleteLine")
                  + ": "
                  + node.getName()
                  + " -> "
                  + next.getName();
          addMenuItem(m_LinePopupMenu, title, line);
        }
        m_LinePopupMenu.show(this, e.getX(), e.getY());
      }
    }

    //	Selection
    else if (e.getSource() instanceof WFNode) {
      WFNode selected = (WFNode) e.getSource();
      log.fine(selected.toString());
      for (int i = 0; i < m_nodes.size(); i++) {
        WFNode node = (WFNode) m_nodes.get(i);
        if (selected.getAD_WF_Node_ID() == node.getAD_WF_Node_ID()) node.setSelected(true);
        else node.setSelected(false);
      }
    }
    m_dragged = false;
  } //	mouseClicked