public void onEvent(Event e) throws Exception {
    if (m_setting) return;
    //	Update Assignment
    ListItem listItem = fResource.getSelectedItem();
    KeyNamePair resource =
        listItem != null
            ? new KeyNamePair((Integer) listItem.getValue(), listItem.getLabel())
            : null;
    if (resource != null) {
      int S_Resource_ID = resource.getKey();
      m_mAssignment.setS_Resource_ID(S_Resource_ID);
    }

    Calendar date = new GregorianCalendar();
    getDateAndTimeFrom(date);

    Timestamp assignDateFrom = new Timestamp(date.getTimeInMillis());
    if (assignDateFrom != null) m_mAssignment.setAssignDateFrom(assignDateFrom);
    if (fQty.getValue() != null) {
      BigDecimal qty = fQty.getValue();
      m_mAssignment.setQty(qty);
    }
    m_mAssignment.setName((String) fName.getValue());
    m_mAssignment.setDescription((String) fDescription.getValue());

    //	Resource - Look up UOM
    if (e.getTarget() == fResource) {
      Object o = m_lookup.get(fResource.getSelectedItem());
      if (o == null) lUOM.setValue(" ? ");
      else lUOM.setValue(o.toString());
    }

    //	Zoom - InfoResource
    else if (e.getTarget().getId().equals("Zoom")) {
      InfoSchedule is = new InfoSchedule(m_mAssignment, true);
      if (is.getMResourceAssignment() != null) {
        m_mAssignment = is.getMResourceAssignment();
        //	setDisplay();
        detach();
      }
      is = null;
    }

    //	cancel - return
    else if (e.getTarget().getId().equals("Cancel")) {
      m_cancel = true;
      detach();
    }

    //	delete - delete and return
    else if (e.getTarget().getId().equals("Delete")) {
      if (m_mAssignment.delete(true)) {
        m_mAssignment = null;
        detach();
      } else FDialog.error(0, this, "ResourceAssignmentNotDeleted");
    }

    //	OK - Save
    else if (e.getTarget().getId().equals("Ok")) {
      if (cmd_save()) detach();
    }
  }
Beispiel #2
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