/** * Reload depending fields * * @author Yamel Senih, [email protected], ERPCyA http://www.erpcya.com 30/08/2014, 20:39:26 * @param m_FieldChanged * @return void */ public void changeDepending(GridField m_FieldChanged) { // if (!hasDependants(m_FieldChanged.getColumnName())) return; // ArrayList<GridField> list = getDependantFields(m_FieldChanged.getColumnName()); for (int index = 0; index < list.size(); index++) { GridField m_DependentField = list.get(index); // Valid Null if (m_DependentField == null) continue; LogM.log( m_ctx, getClass(), Level.FINE, "Callout process dependent child [" + m_FieldChanged.getColumnName() + " --> " + m_DependentField.getColumnName() + "]"); // Get Field Meta-Data InfoField fieldMD = m_DependentField.getField(); if (fieldMD == null) continue; // Load if (DisplayType.isLookup(fieldMD.DisplayType)) { if (fieldMD.DisplayType != DisplayType.SEARCH && m_DependentField instanceof VLookupSpinner) { VLookupSpinner spinner = (VLookupSpinner) m_DependentField; Object oldValue = spinner.getValue(); spinner.load(true); // set old value spinner.setValueNoReload(oldValue); } } } }
/** * 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; }
/** * 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; }