コード例 #1
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
 public ChangeVO updateRow(
     int windowNo,
     int AD_Tab_ID,
     int queryResultID,
     int relRowNo,
     Map<String, String> context,
     boolean force) {
   if (context == null || context.size() == 0)
     return new ChangeVO(true, Msg.translate(m_context, "NoContext"));
   ArrayList<String[]> data = m_results.get(queryResultID);
   if (data == null || data.size() == 0)
     return new ChangeVO(true, Msg.translate(m_context, "CachedDataNotFound"));
   UITab tab = getTab(AD_Tab_ID);
   if (tab == null) {
     log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
     return new ChangeVO(true, Msg.translate(m_context, "@NotFound@ @AD_Tab_ID@=" + AD_Tab_ID));
   }
   CContext ctx = new CContext(m_context.entrySet());
   ctx.addWindow(windowNo, context);
   ChangeVO retValue;
   if (force) retValue = tab.saveRow(ctx, windowNo, false, null);
   else retValue = tab.saveRow(ctx, windowNo, false, data.get(relRowNo));
   if (retValue.hasError()) return retValue;
   // Update Results
   String[] dataRow = retValue.rowData.clone();
   data.set(relRowNo, dataRow);
   postProcessChangeVO(retValue, windowNo, context, dataRow, tab);
   retValue.trxInfo = GridTab.getTrxInfo(tab.getTableName(), ctx, windowNo, tab.getTabNo());
   if (retValue.isRefreshAll()) {}
   return retValue;
 }
コード例 #2
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
  /**
   * Save (Insert new) Row of Tab
   *
   * @param windowNo relative window
   * @param AD_Tab_ID tab
   * @param curRow insert after relative row number in results
   * @param context current (relevant) context of new row
   * @return error message or null
   */
  public ChangeVO insertRow(
      int windowNo, int AD_Tab_ID, int queryResultID, int curRow, Map<String, String> context) {
    if (context == null || context.size() == 0) return new ChangeVO(true, "No Context");
    UITab tab = getTab(AD_Tab_ID);
    if (tab == null) {
      log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
      return new ChangeVO(true, "@NotFound@ @AD_Tab_ID@=" + AD_Tab_ID);
    }

    log.info("Line Amt:" + context.get("LineNetAmt"));
    CContext ctx = new CContext(m_context.entrySet());
    ctx.addWindow(windowNo, context);
    ChangeVO retValue = tab.saveRow(ctx, windowNo, true);
    if (retValue.hasError()) return retValue;
    // Update Results
    ArrayList<String[]> data = m_results.get(queryResultID);
    if (data == null) retValue.addError("Data Not Found");
    else {
      String[] dataRow = retValue.rowData;
      if (curRow >= data.size()) data.add(dataRow);
      else data.add(curRow, dataRow);
      retValue.trxInfo = GridTab.getTrxInfo(tab.getTableName(), ctx, windowNo, tab.getTabNo());
    }
    return retValue;
  } // insertRow
コード例 #3
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
 /**
  * Get Lookup Data for Field in context
  *
  * @param AD_Field_ID field
  * @param context context
  * @param refresh requery
  * @return lookup pair array
  */
 public ArrayList<NamePair> getLookupData(
     int windowNo, int AD_Field_ID, Map<String, String> context, boolean refresh) {
   UIField field = getField(AD_Field_ID, windowNo);
   if (field == null) {
     log.warning("Cannot find AD_Field_ID=" + AD_Field_ID);
     return null;
   }
   CContext ctx = new CContext(m_context.entrySet());
   ctx.addWindow(windowNo, context);
   if (field.isLookup() || field.isButtonLookup()) return field.getAllLookupData(ctx, windowNo);
   else log.warning("No Lookup: " + field.getColumnName());
   return null;
 } // getLookupData
コード例 #4
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
  /**
   * Field Changed
   *
   * @param windowNo relative window
   * @param AD_Field_ID field
   * @param AD_Tab_ID tab
   * @param oldValue old field value
   * @param newValue new field value
   * @param context record context
   * @return Field Change VO
   */
  public ChangeVO fieldChanged(
      int windowNo,
      int AD_Field_ID,
      int AD_Tab_ID,
      String oldValue,
      String newValue,
      Map<String, String> context) {
    // Same Values
    if (oldValue == null || oldValue.equals(Null.NULLString)) oldValue = "";
    if (newValue == null || newValue.equals(Null.NULLString)) newValue = "";
    if (oldValue.equals(newValue)) return null;
    //
    UITab tab = getTab(AD_Tab_ID);
    if (tab == null) {
      log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
      return null;
    }
    UIField field = getField(AD_Field_ID, windowNo);
    if (field == null) {
      log.warning("Cannot find AD_Field_ID=" + AD_Field_ID);
      return null;
    }

    CContext ctx = new CContext(m_context.entrySet());
    ctx.addWindow(windowNo, context);
    CContext origCtx = new CContext(m_context.entrySet());
    origCtx.addWindow(windowNo, context);
    ChangeVO change = null;
    try {
      // reset the thread active flag, in case the thread is reused later on
      CThreadUtil.setCalloutActive(false);
      change =
          tab.fieldChanged(
              origCtx, ctx, new ArrayList<UIField>(5), windowNo, field, oldValue, newValue);
      CThreadUtil.setCalloutActive(false);
      ctx.setContext(windowNo, field.getColumnName(), change.newConfirmedFieldValue);
    } catch (Exception e) {
      log.severe("fieldChange error:" + field.getColumnName() + e.getMessage());
    } finally {
      CThreadUtil.setCalloutActive(false);
    }

    return change;
  } // fieldChanged
コード例 #5
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
 /**
  * Create new Row with Default values. The new Row is not saved in Results
  *
  * @param windowNo relative window
  * @param AD_Tab_ID tab
  * @param context record context for parent columns and other variables
  * @return array of field values or null if error. You get the columnNames via String[] columns =
  *     uiTab.getColumnNames();
  */
 public ChangeVO newRow(int windowNo, int AD_Tab_ID, Map<String, String> context) {
   UITab tab = getTab(AD_Tab_ID);
   if (tab == null) {
     log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
     return null;
   }
   CContext ctx = new CContext(m_context.entrySet());
   ctx.addWindow(windowNo, context);
   ctx.setIsSOTrx(windowNo, tab.isSOTrx());
   ChangeVO change = tab.newRow(ctx, windowNo);
   /**
    * Very likely not needed if (change.changedDropDowns == null) change.changedDropDowns = new
    * HashMap<String,ArrayList<NamePair>>(); for(UIField f:tab.getFields()) { if
    * (f.isDependentValue()) change.changedDropDowns.put(f.getColumnName(),
    * getLookupValues(windowNo, f.getAD_Field_ID(), change.changedFields)); }
    */
   tab.canUpdate(ctx, windowNo, change);
   return change;
 } // newRow
コード例 #6
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
  public Boolean savePreferences(Map<String, String> ctx) {
    CContext cContext = getContext();
    MUser user = MUser.get(cContext);
    MUserPreference preference = user.getPreference();
    String printerName = ctx.get("PrinterName");
    if (printerName != null && printerName.trim().equalsIgnoreCase("")) {
      cContext.setPrinterName(printerName);
      preference.setPrinterName(printerName);
    }
    String autoCommit = ctx.get("AutoCommit");
    if (autoCommit != null) {
      cContext.setAutoCommit(autoCommit.trim().equalsIgnoreCase("Y"));
      preference.setIsAutoCommit(autoCommit.trim().equalsIgnoreCase("Y"));
    }
    String showAdvanced = ctx.get("#ShowAdvanced");
    if (showAdvanced != null) {
      cContext.setContext("#ShowAdvanced", showAdvanced);
      preference.setIsShowAdvanced(showAdvanced.trim().equalsIgnoreCase("Y"));
    }
    String showAccounting = ctx.get("#ShowAcct");
    if (showAccounting != null) {
      cContext.setContext("#ShowAcct", showAccounting);
      preference.setIsShowAcct(showAccounting.trim().equalsIgnoreCase("Y"));
    }
    String showTranslation = ctx.get("#ShowTrl");
    if (showTranslation != null) {
      cContext.setContext("#ShowTrl", showTranslation);
      preference.setIsShowTrl(showTranslation.trim().equalsIgnoreCase("Y"));
    }
    String uiTheme = ctx.get("#UITheme");
    if (uiTheme != null && !uiTheme.trim().equalsIgnoreCase("")) {
      cContext.setContext("#UITheme", uiTheme);
      preference.setUITheme(uiTheme);
    }

    String printPreview = ctx.get("#PrintPreview");
    if (printPreview != null) {
      cContext.setPrintPreview(printPreview.equalsIgnoreCase("Y"));
      Ini.setProperty(Ini.P_PRINTPREVIEW, printPreview.equalsIgnoreCase("Y"));
      Ini.saveProperties(Ini.isClient());
    }

    String date = ctx.get("#Date");
    cContext.setContext("#Date", date);

    return preference.save();
  }
コード例 #7
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
 /**
  * Refresh current row of Tab
  *
  * @param windowNo relative window
  * @param AD_Tab_ID tab
  * @param relRowNo relative row number in results
  * @param context current (relevant) context of new row
  * @return error message or null
  */
 public ChangeVO refreshRow(
     int windowNo, int AD_Tab_ID, int queryResultID, int relRowNo, Map<String, String> context) {
   if (context == null || context.size() == 0) return new ChangeVO(true, "No Context");
   UITab tab = getTab(AD_Tab_ID);
   if (tab == null) {
     log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
     return new ChangeVO(true, "@NotFound@ @AD_Tab_ID@=" + AD_Tab_ID);
   }
   CContext ctx = new CContext(m_context.entrySet());
   ctx.addWindow(windowNo, context);
   ChangeVO retValue = tab.refreshRow(ctx, windowNo);
   if (retValue.hasError()) return retValue;
   // Update Results
   ArrayList<String[]> data = m_results.get(queryResultID);
   if (data == null) retValue.addError("Data Not Found");
   else {
     String[] dataRow = retValue.rowData.clone();
     data.set(relRowNo, dataRow);
     postProcessChangeVO(retValue, windowNo, context, dataRow, tab);
     retValue.trxInfo = GridTab.getTrxInfo(tab.getTableName(), ctx, windowNo, tab.getTabNo());
   }
   return retValue;
 } // refreshRow
コード例 #8
0
ファイル: GwtServer.java プロジェクト: WilkerDiaz/Compiere
 /**
  * Delete existing Row
  *
  * @param windowNo relative window
  * @param AD_Tab_ID tab
  * @param relRowNo relative row number in results
  * @return error message or null
  */
 public ChangeVO deleteRow(int windowNo, int AD_Tab_ID, int queryResultID, int relRowNo) {
   UITab tab = getTab(AD_Tab_ID);
   if (tab == null) {
     log.config("Not found AD_Tab_ID=" + AD_Tab_ID);
     return new ChangeVO(true, "@NotFound@ @AD_Tab_ID@=" + AD_Tab_ID);
   }
   ArrayList<String[]> data = m_results.get(queryResultID);
   if (data == null) return new ChangeVO(true, "Data Not Found");
   String[] rowData = data.get(relRowNo);
   // Copy Data into Context
   Map<String, String> context = new HashMap<String, String>();
   String[] columns = tab.getColumnNames();
   for (int i = 0; i < columns.length; i++) {
     String column = columns[i];
     context.put(column, rowData[i]);
   }
   CContext ctx = new CContext(m_context.entrySet());
   ctx.addWindow(windowNo, context);
   ChangeVO retValue = tab.deleteRow(ctx, windowNo);
   if (retValue.hasError()) return retValue;
   // Update Results
   data.remove(relRowNo);
   return retValue;
 } // deleteRow