/**
   * Action Listener
   *
   * @param e event
   */
  public void actionPerformed(ActionEvent e) {
    log.info(e.toString());

    //	Add new Node
    if (e.getSource() == m_NewMenuNode) {
      log.info("Create New Node");
      String nameLabel = Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Name"));
      String name =
          JOptionPane.showInputDialog(
              this,
              nameLabel, //	message
              Msg.getMsg(Env.getCtx(), "CreateNewNode"), // 	title
              JOptionPane.QUESTION_MESSAGE);
      if (name != null && name.length() > 0) {
        int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
        MWFNode node = new MWFNode(m_wf, name, name);
        node.setClientOrg(AD_Client_ID, 0);
        node.save();
        m_parent.load(m_wf.getAD_Workflow_ID(), true);
      }
    }
    //	Add/Delete Line
    else if (e.getSource() instanceof WFPopupItem) {
      WFPopupItem item = (WFPopupItem) e.getSource();
      item.execute();
    }
  } //	actionPerformed
Example #2
0
  /** Answer Button */
  private void cmd_button() {
    log.config("Activity=" + m_activity);
    if (m_activity == null) return;
    //
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserWindow.equals(node.getAction())) {
      int AD_Window_ID = node.getAD_Window_ID(); // Explicit Window
      String ColumnName = m_activity.getPO().get_TableName() + "_ID";
      int Record_ID = m_activity.getRecord_ID();
      MQuery query = MQuery.getEqualQuery(ColumnName, Record_ID);
      boolean IsSOTrx = m_activity.isSOTrx();
      //
      log.info(
          "Zoom to AD_Window_ID=" + AD_Window_ID + " - " + query + " (IsSOTrx=" + IsSOTrx + ")");

      AEnv.zoom(AD_Window_ID, query);
    } else if (MWFNode.ACTION_UserForm.equals(node.getAction())) {
      int AD_Form_ID = node.getAD_Form_ID();

      Window form = ADForm.openForm(AD_Form_ID);
      AEnv.showWindow(form);
    } else if (MWFNode.ACTION_SmartBrowse.equals(node.getAction())) {
      int AD_Browse_ID = node.getAD_Browse_ID();

      Window browse = WBrowser.openBrowse(AD_Browse_ID);
      AEnv.showWindow(browse);
    } else log.log(Level.SEVERE, "No User Action:" + node.getAction());
  } //	cmd_button
Example #3
0
  /** Display. Fill Editors */
  public void display(int index) {
    log.fine("Index=" + index);
    //
    m_activity = resetDisplay(index);
    //	Nothing to show
    if (m_activity == null) {
      return;
    }
    //	Display Activity
    fNode.setText(m_activity.getNodeName());
    fDescription.setValue(m_activity.getNodeDescription());
    fHelp.setValue(m_activity.getNodeHelp());
    //
    fHistory.setContent(HISTORY_DIV_START_TAG + m_activity.getHistoryHTML() + "</div>");

    //	User Actions
    MWFNode node = m_activity.getNode();
    if (MWFNode.ACTION_UserChoice.equals(node.getAction())) {
      if (m_column == null) m_column = node.getColumn();
      if (m_column != null && m_column.get_ID() != 0) {
        fAnswerList.removeAllItems();
        int dt = m_column.getAD_Reference_ID();
        if (dt == DisplayType.YesNo) {
          ValueNamePair[] values = MRefList.getList(Env.getCtx(), 319, false); // 	_YesNo
          for (int i = 0; i < values.length; i++) {
            fAnswerList.appendItem(values[i].getName(), values[i].getValue());
          }
          fAnswerList.setVisible(true);
        } else if (dt == DisplayType.List) {
          ValueNamePair[] values =
              MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false);
          for (int i = 0; i < values.length; i++) {
            fAnswerList.appendItem(values[i].getName(), values[i].getValue());
          }
          fAnswerList.setVisible(true);
        } else //	other display types come here
        {
          fAnswerText.setText("");
          fAnswerText.setVisible(true);
        }
      }
    }
    //	--
    else if (MWFNode.ACTION_UserWindow.equals(node.getAction())
        || MWFNode.ACTION_UserForm.equals(node.getAction())) {
      fAnswerButton.setLabel(node.getName());
      fAnswerButton.setTooltiptext(node.getDescription());
      fAnswerButton.setVisible(true);
    } else log.log(Level.SEVERE, "Unknown Node Action: " + node.getAction());

    statusBar.setStatusDB((m_index + 1) + "/" + m_activities.length);
    statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFActivities"));
  } //	display
Example #4
0
  /**
   * Load workflw and initialize the session attributes.
   *
   * @param ctx
   * @param AD_Workflow_ID
   * @param sess
   */
  private void loadWorkflow(Properties ctx, int AD_Workflow_ID, HttpSession sess) {

    MWorkflow wf = new MWorkflow(ctx, AD_Workflow_ID, null);
    // get the MWFNode in order
    MWFNode[] nodes = wf.getNodes(true, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    MWFNode wfn = null;
    ArrayList nodes_ID = new ArrayList();
    for (int i = 0; i < nodes.length; i++) {
      wfn = nodes[i];
      nodes_ID.add(new Integer(wfn.getAD_WF_Node_ID()));
    } // for
    int imageMap[][] = generateImageMap(nodes_ID);
    // printMap(imageMap);
    // set session attribtes
    sess.setAttribute(WORKFLOW, wf);
    sess.setAttribute(NODES, nodes);
    sess.setAttribute(NODES_ID, nodes_ID);
    sess.setAttribute(IMAGE_MAP, imageMap);
    sess.setAttribute(ACTIVE_NODE, new Integer(-999));
  } // loadWorkflow
 /** 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
Example #6
0
  /** Save */
  public void onOK() {
    log.config("Activity=" + m_activity);
    if (m_activity == null) {
      Clients.showBusy(null, false);
      return;
    }
    int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
    String textMsg = fTextMsg.getValue();
    //
    MWFNode node = m_activity.getNode();

    Object forward = null; // fForward.getValue();

    // ensure activity is ran within a transaction - [ 1953628 ]
    Trx trx = null;
    try {
      trx = Trx.get(Trx.createTrxName("FWFA"), true);
      m_activity.set_TrxName(trx.getTrxName());

      if (forward != null) {
        log.config("Forward to " + forward);
        int fw = ((Integer) forward).intValue();
        if (fw == AD_User_ID || fw == 0) {
          log.log(Level.SEVERE, "Forward User="******"CannotForward");
          trx.rollback();
          trx.close();
          return;
        }
      }
      //	User Choice - Answer
      else if (MWFNode.ACTION_UserChoice.equals(node.getAction())) {
        if (m_column == null) m_column = node.getColumn();
        //	Do we have an answer?
        int dt = m_column.getAD_Reference_ID();
        String value = fAnswerText.getText();
        if (dt == DisplayType.YesNo || dt == DisplayType.List) {
          ListItem li = fAnswerList.getSelectedItem();
          if (li != null) value = li.getValue().toString();
        }
        if (value == null || value.length() == 0) {
          FDialog.error(m_WindowNo, this, "FillMandatory", Msg.getMsg(Env.getCtx(), "Answer"));
          trx.rollback();
          trx.close();
          return;
        }
        //
        log.config("Answer=" + value + " - " + textMsg);
        try {
          m_activity.setUserChoice(AD_User_ID, value, dt, textMsg);
        } catch (Exception e) {
          log.log(Level.SEVERE, node.getName(), e);
          FDialog.error(m_WindowNo, this, "Error", e.toString());
          trx.rollback();
          trx.close();
          return;
        }
      }
      //	User Action
      else {
        log.config("Action=" + node.getAction() + " - " + textMsg);
        try {
          // ensure activity is ran within a transaction
          m_activity.setUserConfirmation(AD_User_ID, textMsg);
        } catch (Exception e) {
          log.log(Level.SEVERE, node.getName(), e);
          FDialog.error(m_WindowNo, this, "Error", e.toString());
          trx.rollback();
          trx.close();
          return;
        }
      }

      trx.commit();
    } finally {
      Clients.showBusy(null, false);
      if (trx != null) trx.close();
    }

    //	Next
    loadActivities();
    display(-1);
  } //	onOK
  /**
   * ************************************************************************ 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