コード例 #1
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
コード例 #2
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