コード例 #1
0
ファイル: WWorkflow.java プロジェクト: makezjdq/adempiere-1
  /**
   * Print the description for a workflow or a node.
   *
   * @param activeNode
   * @param wf
   * @param nodes
   * @param nodes_ID
   * @return table
   */
  private table printDescription(
      int activeNode, MWorkflow wf, MWFNode[] nodes, ArrayList nodes_ID) {
    // create new table
    table desTable = new table();

    String WFName = "";
    String WFDescription = "";

    // not started yet
    if (activeNode < 0) {
      WFName = wf.getName();
      WFDescription = wf.getHelp();
    }

    // started
    else {
      WFName = nodes[getIndex(activeNode, nodes_ID)].getName();
      WFDescription = nodes[getIndex(activeNode, nodes_ID)].getHelp();
    }

    // add info to the desciption table
    tr aRow = new tr();
    td aGrid = new td();
    aGrid.addElement(new h6(WFName));
    aGrid.addElement(new br());
    aGrid.addElement(WFDescription);
    desTable.addElement(aRow.addElement(aGrid));

    return desTable;
  } // printDescription
コード例 #2
0
ファイル: WProcessCtl.java プロジェクト: makezjdq/adempiere-1
 /**
  * ************************************************************************ Start Workflow.
  *
  * @param AD_Workflow_ID workflow
  * @return true if started
  */
 private boolean startWorkflow(int AD_Workflow_ID) {
   log.fine(AD_Workflow_ID + " - " + m_pi);
   boolean started = false;
   if (DB.isRemoteProcess()) {
     log.info("trying to running on the server");
     Server server = CConnection.get().getServer();
     try {
       if (server != null) { // 	See ServerBean
         log.info("running on the server");
         m_pi = server.workflow(m_wscctx, m_pi, AD_Workflow_ID);
         log.finest("server => " + m_pi);
         started = true;
       }
     } catch (Exception ex) {
       log.log(Level.SEVERE, "AppsServer error", ex);
       started = false;
     }
   }
   //	Run locally
   if (!started && !m_IsServerProcess) {
     log.info("running locally");
     MWorkflow wf = MWorkflow.get(m_wscctx, AD_Workflow_ID);
     MWFProcess wfProcess = null;
     if (m_pi.isBatch()) wfProcess = wf.start(m_pi); // 	may return null
     else wfProcess = wf.startWait(m_pi); // 	may return null
     started = wfProcess != null;
   }
   return started;
 } //  startWorkflow
コード例 #3
0
 public static int procesProduction(
     MProduction production, Timestamp movementDate, boolean mustBeStocked) {
   ProcessInfo pi = MWorkflow.runDocumentActionWorkflow(production, "CO");
   if (pi.isError()) {
     throw new RuntimeException(pi.getSummary());
   } else {
     if (production.isUseProductionPlan()) {
       Query planQuery =
           new Query(
               Env.getCtx(),
               I_M_ProductionPlan.Table_Name,
               "M_ProductionPlan.M_Production_ID=?",
               production.get_TrxName());
       List<MProductionPlan> plans =
           planQuery.setParameters(production.getM_Production_ID()).list();
       int linesCount = 0;
       for (MProductionPlan plan : plans) {
         MProductionLine[] lines = plan.getLines();
         linesCount += lines.length;
       }
       return linesCount;
     } else {
       return production.getLines().length;
     }
   }
 }
コード例 #4
0
  /**
   * 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
コード例 #5
0
ファイル: WWorkflow.java プロジェクト: makezjdq/adempiere-1
  /**
   * Execute the M_Command and update the .
   *
   * @param m_command
   * @param wf
   * @param activeNode
   * @param nodes
   * @param nodes_ID
   * @param sess
   */
  private void executeCommand(
      String m_command,
      int j_command,
      MWorkflow wf,
      int activeNode,
      MWFNode[] nodes,
      ArrayList nodes_ID,
      HttpSession sess) {
    if (j_command != 0) {
      sess.setAttribute(ACTIVE_NODE, new Integer(j_command));
      return;
    }

    debug(m_command, "m_command in executeCommand");
    // check first or last node
    boolean isFirst = wf.isFirst(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    boolean isLast = wf.isLast(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));

    boolean notReady = false;
    int updatedActiveNode = activeNode;

    if (activeNode < 0) notReady = true;

    if (notReady) {
      updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();

    } else {
      if (m_command.equals(NEXT)) {
        if (notReady) updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();
        else updatedActiveNode = wf.getNext(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
      } // next
      if (m_command.equals(BACK)) {
        if (notReady) updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();
        else
          updatedActiveNode = wf.getPrevious(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
      } // back
      if (m_command.equals(FIRST)) updatedActiveNode = ((Integer) nodes_ID.get(0)).intValue();

      if (m_command.equals(LAST))
        updatedActiveNode = wf.getLast(0, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    } // ready

    // update
    sess.setAttribute(ACTIVE_NODE, new Integer(updatedActiveNode));
  } // executeCommand
コード例 #6
0
ファイル: WWorkflow.java プロジェクト: makezjdq/adempiere-1
  /**
   * 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
コード例 #7
0
ファイル: WWorkflow.java プロジェクト: makezjdq/adempiere-1
  /**
   * Print the control panel.
   *
   * @param activeNode
   * @param wf
   * @param nodes
   * @param nodes_ID
   * @return form
   */
  private form printControlPanel(
      int activeNode, MWorkflow wf, MWFNode[] nodes, ArrayList nodes_ID) {
    // create a new form
    form myForm = new form(FORM_ACTION, form.METHOD_POST, form.ENC_DEFAULT);
    myForm.addElement(new input("hidden", M_Command, ""));
    myForm.addElement(new input("hidden", J_Command, ""));
    myForm.setTarget(TARGET_WINDOW);
    myForm.setName(FORM_NAME);

    // test fist or last node

    boolean isFirst = wf.isFirst(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));
    boolean isLast = wf.isLast(activeNode, Env.getContextAsInt(ctx, "#AD_Client_ID"));

    // get AD_Window_ID for the first and last node
    int First_Window_ID = wf.getFirstNode().getAD_Window_ID();
    int Last_Window_ID = nodes[nodes.length - 1].getAD_Window_ID();

    int Back_Window_ID = 0;
    int Next_Window_ID = 0;
    int index = 0;

    // WUtil.debug(""+activeNode,"activeNode");
    if (!isFirst) {
      index = activeNode >= 0 ? getIndex(activeNode, nodes_ID) - 1 : 0;
      // WUtil.debug(""+index,"index");
      Back_Window_ID = nodes[index].getAD_Window_ID();
    }
    if (!isLast) {
      index = activeNode >= 0 ? getIndex(activeNode, nodes_ID) + 1 : 0;
      Next_Window_ID = nodes[index].getAD_Window_ID();
    }
    boolean enableFirst = true;
    boolean enableBack = true;
    boolean enableNext = true;
    boolean enableLast = true;

    if (isFirst) {
      enableBack = false;
      enableFirst = false;
    }
    if (isLast) {
      enableNext = false;
      enableLast = false;
    }

    td firstImage = new td();
    td backImage = new td();
    td nextImage = new td();
    td lastImage = new td();

    // first
    String url = "'WWindow?AD_Window_ID=" + First_Window_ID + "'";
    // String
    // url=WebEnv.getBaseDirectory("WWindow")+"?AD_Window_ID="+First_Window_ID+"&Target_Window=win_"+First_Window_ID+"'";
    String Target_Window = "'WWindow" + First_Window_ID + "'";
    String parameters = url + "," + Target_Window;
    String js_command = "popUp(" + parameters + ");submit()";
    firstImage.addElement(createControlButtonImage("Start", js_command, enableFirst));
    // back
    url = "'WWindow?AD_Window_ID=" + Back_Window_ID + "'";
    //
    // url=WebEnv.getBaseDirectory("WWindow")+"?AD_Window_ID="+Back_Window_ID+"&Target_Window=win_"+Back_Window_ID+"'";
    Target_Window = "'WWindow" + Back_Window_ID + "'";
    parameters = url + "," + Target_Window;
    js_command = "popUp(" + parameters + ");submit()";
    backImage.addElement(createControlButtonImage("Back", js_command, enableBack));

    // next
    url = "'WWindow?AD_Window_ID=" + Next_Window_ID + "'";
    // url=WebEnv.getBaseDirectory("WWindow")+"?AD_Window_ID="+Next_Window_ID+"&Target_Window=win_"+Next_Window_ID+"'";
    Target_Window = "'WWindow" + Next_Window_ID + "'";
    parameters = url + "," + Target_Window;
    js_command = "popUp(" + parameters + ");submit()";
    nextImage.addElement(createControlButtonImage("Next", js_command, enableNext));

    // last
    url = "'WWindow?AD_Window_ID=" + Last_Window_ID + "'";
    // url=WebEnv.getBaseDirectory("WWindow")+"?AD_Window_ID="+Last_Window_ID+"&Target_Window=win_"+Last_Window_ID+"'";
    Target_Window = "'WWindow" + Last_Window_ID + "'";
    parameters = url + "," + Target_Window;
    js_command = "popUp(" + parameters + ");submit()";
    lastImage.addElement(createControlButtonImage("End", js_command, enableLast));

    tr aRow = new tr();
    aRow.addElement(firstImage);
    aRow.addElement(backImage);
    aRow.addElement(nextImage);
    aRow.addElement(lastImage);

    // add the table to the form
    myForm.addElement(new table().addElement(aRow));

    return myForm;
  } // printControlPanel
コード例 #8
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