示例#1
0
  /* (non-Javadoc)
   * @see edu.ku.brc.af.prefs.GenericPrefsPanel#savePrefs()
   */
  @Override
  public void savePrefs() {
    AppPreferences prefs = AppPreferences.getRemote();

    FormViewObj fvo = (FormViewObj) form;

    ValSpinner dueSpinner = fvo.getCompById("OVERDUETIME");
    if (dueSpinner != null) {
      Integer val = (Integer) dueSpinner.getValue();
      if (val != null) {
        prefs.putInt(DUEINMONTHS, val);
      }
    }

    ValComboBox shipMeth = fvo.getCompById("SHIPMETH");
    if (shipMeth != null) {
      String method = (String) shipMeth.getValue();
      if (method != null) {
        prefs.put(LoanGiftShipmentBusRules.SHIPMETHOD, method);
      }
    }

    ValComboBoxFromQuery shippedBy = fvo.getCompById("SHIPPEDBY");
    if (shippedBy != null) {
      Agent agent = (Agent) shippedBy.getValue();
      if (agent != null) {
        prefs.putInt(LoanGiftShipmentBusRules.SHIPPEDBY, agent.getAgentId());
      } else {
        prefs.remove(LoanGiftShipmentBusRules.SHIPPEDBY);
      }
    }
  }
示例#2
0
  /** Create the UI for the panel */
  protected void createUI() {
    createForm("Preferences", "LoansPrefs");
    AppPreferences prefs = AppPreferences.getRemote();

    Integer dueInMonths = prefs.getInt(DUEINMONTHS, 6);
    String shippingMethod = prefs.get(LoanGiftShipmentBusRules.SHIPMETHOD, null);
    Integer shippedByAgentId = prefs.getInt(LoanGiftShipmentBusRules.SHIPPEDBY, null);

    FormViewObj fvo = (FormViewObj) form;

    ValSpinner dueSpinner = fvo.getCompById("OVERDUETIME");
    if (dueSpinner != null) {
      dueSpinner.setValue(dueInMonths);
    }

    ValComboBox shipMeth = fvo.getCompById("SHIPMETH");
    if (shipMeth != null) {
      shipMeth.setValue(shippingMethod, null);
    }

    ValComboBoxFromQuery shippedBy = fvo.getCompById("SHIPPEDBY");
    if (shippedBy != null && shippedByAgentId != null) {
      DataProviderSessionIFace session = null;
      try {
        session = DataProviderFactory.getInstance().createSession();
        Agent agent = session.get(Agent.class, shippedByAgentId);
        shippedBy.setValue(agent, null);

      } catch (Exception ex) {
        edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
        edu.ku.brc.exceptions.ExceptionTracker.getInstance()
            .capture(ValComboBoxFromQuery.class, ex);
        ex.printStackTrace();

      } finally {
        if (session != null) {
          session.close();
        }
      }
    }
  }