daniel
2012-04-14
1.modify org.compiere.model.GridTab.java
public boolean isReadOnly() { if (m_vo.IsReadOnly) return true; // hengsin, make detail readonly when parent is empty if (m_parentNeedSave) return true; // no restrictions if (m_vo.ReadOnlyLogic == null || m_vo.ReadOnlyLogic.equals("")) return m_vo.IsReadOnly; // ** dynamic content ** uses get_ValueAsString boolean retValue = Evaluator.evaluateLogic(this, m_vo.ReadOnlyLogic); + setFieldsReadOnly(retValue); log.finest(m_vo.Name + " (" + m_vo.ReadOnlyLogic + ") => " + retValue); return retValue; } // isReadOnly +private void setFieldsReadOnly(boolean readonly) { + for (int f = 0; f < m_vo.getFields().size(); f++) { + GridFieldVO voF = (GridFieldVO) m_vo.getFields().get(f); + if (voF != null) { + if (readonly) { + voF.IsReadOnly = true; + } + } + } + }
2.modify org.compiere.util.Evaluator
private static boolean evaluateLogicTuple (Evaluatee source, String logic) ..... if (first.indexOf('@') != -1) // variable { first = first.replace ('@', ' ').trim (); // strip 'tag' firstEval = source.get_ValueAsString (first); // replace with it's value + if(firstEval.equals(null)||firstEval.equals("")){ + return false; + } } .....
daniel
2012-04-14
hope everyone provide a better way
daniel
2012-04-15
public GridTab(GridTabVO vo, GridWindow w, boolean virtual) {
m_window = w;
m_vo = vo;
+ readOnlyList = new ArrayList();
// Create MTable
m_mTable = new GridTable(m_vo.ctx, m_vo.AD_Table_ID, m_vo.TableName,
m_vo.WindowNo, m_vo.TabNo, true, virtual);
m_mTable.setReadOnly(m_vo.IsReadOnly || m_vo.IsView);
m_mTable.setDeleteable(m_vo.IsDeleteable);
// Load Tab
// initTab(false);
} // GridTab
/* Value Object /
private GridTabVO m_vo;
+ List readOnlyList;
private void setFields(boolean readonly) {
if (readonly) {
for (int f = 0; f < m_vo.getFields().size(); f++) {
GridFieldVO voF = (GridFieldVO) m_vo.getFields().get(f); if (voF != null) { voF.IsReadOnly = readonly; } } } else { for (int f = 0; f < m_vo.getFields().size(); f++) { GridFieldVO voF = (GridFieldVO) m_vo.getFields().get(f); if (voF != null) { voF.IsReadOnly = readOnlyList.get(f); } } } }
xolali
2012-05-10
Hi,
Thanks for the code, was just looking thru' this issue today.. your changes look good. Will fix and add to my repository
xolali