diff --git a/org.adempiere.base/src/org/compiere/model/GridField.java b/org.adempiere.base/src/org/compiere/model/GridField.java index b4b81afc84..316c5919fb 100644 --- a/org.adempiere.base/src/org/compiere/model/GridField.java +++ b/org.adempiere.base/src/org/compiere/model/GridField.java @@ -371,12 +371,12 @@ public class GridField // Mandatory if displayed return isDisplayed (checkContext); - } // isMandatory - - /** - * Is parameter Editable - checks if parameter is Read Only - * @param checkContext if true checks Context - * @return true, if editable + } // isMandatory + + /** + * Is parameter Editable - checks if parameter is Read Only + * @param checkContext if true checks Context + * @return true, if editable */ public boolean isEditablePara(boolean checkContext) { if (checkContext && m_vo.ReadOnlyLogic.length() > 0) @@ -454,10 +454,15 @@ public class GridField { boolean isAlwaysUpdatable = false; if (m_vo.AlwaysUpdatableLogic.startsWith("@SQL=")) { - isAlwaysUpdatable = Evaluator.parseSQLLogic(m_vo.AlwaysUpdatableLogic, m_vo.ctx, m_vo.WindowNo, + isAlwaysUpdatable = Evaluator.parseSQLLogic(m_vo.AlwaysUpdatableLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName); } else { - isAlwaysUpdatable = Evaluator.evaluateLogic(this, m_vo.AlwaysUpdatableLogic); + Evaluatee evaluatee = new Evaluatee() { + public String get_ValueAsString(String variableName) { + return GridField.this.get_ValueAsString(ctx, variableName); + } + }; + isAlwaysUpdatable = Evaluator.evaluateLogic(evaluatee, m_vo.AlwaysUpdatableLogic); if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " R/O(" + m_vo.AlwaysUpdatableLogic + ") => R/W-" + isAlwaysUpdatable); @@ -466,9 +471,6 @@ public class GridField return true; } - - - //check tab context if (checkContext && getGridTab() != null && ! "Y".equals(Env.getContext(Env.getCtx(), getWindowNo(), "_QUICK_ENTRY_MODE_"))) @@ -534,13 +536,18 @@ public class GridField { if (m_vo.ReadOnlyLogic.startsWith("@SQL=")) { - boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName); + boolean retValue = !Evaluator.parseSQLLogic(m_vo.ReadOnlyLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName); if (!retValue) return false; } else { - boolean retValue = !Evaluator.evaluateLogic(this, m_vo.ReadOnlyLogic); + Evaluatee evaluatee = new Evaluatee() { + public String get_ValueAsString(String variableName) { + return GridField.this.get_ValueAsString(ctx, variableName); + } + }; + boolean retValue = !Evaluator.evaluateLogic(evaluatee, m_vo.ReadOnlyLogic); if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + " R/O(" + m_vo.ReadOnlyLogic + ") => R/W-" + retValue); if (!retValue) return false; @@ -1261,6 +1268,50 @@ public class GridField return true; } // isDisplayed + /************************************************************************** + * Is the Displayed Grid Column Visible ? + * @param checkContext - check environment (requires correct row position) + * @return true, if visible + */ + public boolean isDisplayedGrid (boolean checkContext) + { + return isDisplayedGrid(m_vo.ctx, checkContext); + } + + /************************************************************************** + * Is the Displayed Grid Column Visible ? + * @param checkContext - check environment (requires correct row position) + * @return true, if visible + */ + public boolean isDisplayedGrid (final Properties ctx, boolean checkContext) + { + // ** static content ** + // not displayed + if (!m_vo.IsDisplayedGrid) + return false; + // no restrictions + if (m_vo.DisplayLogic.equals("")) + return true; + + // ** dynamic content ** + if (checkContext) + { + if (m_vo.DisplayLogic.startsWith("@SQL=")) { + return Evaluator.parseSQLLogic(m_vo.DisplayLogic, ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName); + } + Evaluatee evaluatee = new Evaluatee() { + public String get_ValueAsString(String variableName) { + return GridField.this.get_ValueAsString(ctx, variableName); + } + }; + boolean retValue = Evaluator.evaluateLogic(evaluatee, m_vo.DisplayLogic); + if (log.isLoggable(Level.FINEST)) log.finest(m_vo.ColumnName + + " (" + m_vo.DisplayLogic + ") => " + retValue); + return retValue; + } + return true; + } // isDisplayedGrid + /** * Get Variable Value (Evaluatee) * @param variableName name diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java index 4199572dbe..e54520b1b6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java @@ -327,6 +327,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt } else if (gridField.isHeading()) { component = createInvisibleComponent(); } else if (gridField.getDisplayType() == DisplayType.Button) { + // Each row renderer --- ctx per row wise GridRowCtx gridRowCtx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex); WButtonEditor editor = new WButtonEditor(gridField, rowIndex); editor.setValue(gridTab.getValue(rowIndex, gridField.getColumnName())); @@ -650,7 +651,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt } GridRowCtx ctx = new GridRowCtx(Env.getCtx(), gridTab, rowIndex); - if (! (gridPanelFields[i].isDisplayed(ctx, true) || gridPanelFields[i].isDisplayedGrid())){ + if (!gridPanelFields[i].isDisplayedGrid(ctx, true)){ // IDEMPIERE-2253 component.setVisible(false); } @@ -813,7 +814,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt Properties ctx = isDetailPane() ? new GridRowCtx(Env.getCtx(), gridTab) : gridPanelFields[i].getVO().ctx; //check context - if (!gridPanelFields[i].isDisplayed(ctx, true)){ + if (!gridPanelFields[i].isDisplayedGrid(ctx, true)){ // IDEMPIERE-2253 editor.getComponent().setVisible(false); }