Exemple #1
0
 /**
  * valid and save data
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 25/02/2014, 14:07:20
  * @see https://adempiere.atlassian.net/browse/SPIN-5
  * @return
  * @return boolean
  */
 public boolean save() {
   boolean ok = true;
   m_Record_ID = Env.getTabRecord_ID(m_TabParam.getActivityNo(), m_TabParam.getTabNo());
   m_KeyColums = Env.getTabKeyColumns(m_TabParam.getActivityNo(), m_TabParam.getTabNo());
   //	Error
   if (model == null) {
     m_ErrorMsg = "@NoModelClass@";
     return false;
   }
   //	Get Values
   for (GridField vField : m_fields) {
     if ((vField.isMandatory() || vField.isParent())
         && vField.isEmpty()
         && !PO.isSkipColumn(vField.getColumnName())) {
       m_ErrorMsg = "@MustFillField@ \"@" + vField.getName() + "@\"";
       //	Set ok to false
       ok = false;
       break;
     }
     //	Changed
     if (!vField.isChanged(model.isNew()) && !(vField instanceof VLookupSpinner)) continue;
     //	Set to model
     model.set_Value(vField.getColumnName(), vField.getValue());
     //	Set on Context
     DisplayType.setContextValue(
         m_ctx,
         m_TabParam.getActivityNo(),
         m_TabParam.getTabNo(),
         vField.getField(),
         vField.getValue());
     //
   }
   //	Set Record Identifier
   model.set_Value(m_TabInfo.getTableKeyName(), m_Record_ID[0]);
   //	No saved
   if (!ok) return ok;
   //	Save
   ok = modelSave();
   //	Return
   return ok;
 }
Exemple #2
0
 /**
  * Load Data from Model
  *
  * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 19/05/2014, 13:55:23
  * @param model
  * @return boolean
  */
 public boolean loadData() {
   LogM.log(m_ctx, getClass(), Level.FINE, "loadData()");
   if (model == null) return false;
   //	Get Record Identifier
   int m_Record_ID = model.getID();
   //
   for (GridField vField : m_fields) {
     //
     if (m_Record_ID <= 0) {
       //	Set value to parent field
       if (vField.isParent() || vField.getSPS_Column_ID() == m_TabInfo.getTabSPS_Column_ID()) {
         vField.setValue(
             DisplayType.getContextValue(
                 m_ctx,
                 m_TabParam.getActivityNo(),
                 m_TabParam.getParentTabNo(),
                 vField.getField()));
       } else {
         //	Set Default Value
         String defaultValue = vField.getDefaultValue();
         Object value = null;
         if (defaultValue != null && defaultValue.length() > 0) {
           value =
               DisplayType.parseValue(
                   Env.parseContext(
                       m_ctx,
                       m_TabParam.getActivityNo(),
                       m_TabParam.getParentTabNo(),
                       defaultValue,
                       false,
                       null),
                   vField.getDisplayType());
         } else {
           value = model.get_Value(vField.getColumnIndex());
         }
         //	Set Value
         vField.setValue(value);
       }
     } else {
       //	Set Value from Model
       vField.setValue(model.get_Value(vField.getColumnIndex()));
     }
     //	Set Current Values
     DisplayType.setContextValue(
         m_ctx,
         m_TabParam.getActivityNo(),
         m_TabParam.getTabNo(),
         vField.getField(),
         vField.getValue());
     //	Refresh Display
     changeDisplayDepending(vField);
   }
   //	Set ID to Context
   Env.setContext(
       m_TabParam.getActivityNo(),
       m_TabParam.getTabNo(),
       m_TabInfo.getTableKeyName(),
       m_Record_ID);
   Env.setContext(m_TabParam.getActivityNo(), m_TabInfo.getTableKeyName(), m_Record_ID);
   //	Return
   return true;
 }