From bdf3c8a5ef00826cad9ea4543631fa3abbffa276 Mon Sep 17 00:00:00 2001 From: vpj-cd Date: Tue, 8 Dec 2009 01:06:37 +0000 Subject: [PATCH] Error in context when Key field is found in different tabs. https://sourceforge.net/tracker/index.php?func=detail&aid=2910358&group_id=176962&atid=879332 Error in context when IsActive field is found in different https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332 kind regards Victor Perez www.e-evolution.com --- base/src/org/compiere/model/GridField.java | 33 ++++++++++++----- base/src/org/compiere/model/GridTab.java | 38 ++++++++++++++++++-- base/src/org/compiere/model/GridTable.java | 42 ++++++++++++++++++++-- 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/base/src/org/compiere/model/GridField.java b/base/src/org/compiere/model/GridField.java index 6339175deb..548cba42c4 100644 --- a/base/src/org/compiere/model/GridField.java +++ b/base/src/org/compiere/model/GridField.java @@ -59,15 +59,22 @@ import org.compiere.util.Evaluator; * @author Teo Sarca, teo.sarca@gmail.com *
  • BF [ 2874646 ] GridField issue when a lookup is key * https://sourceforge.net/tracker/?func=detail&aid=2874646&group_id=176962&atid=879332 + * @author victor.perez@e-evolution.com,www.e-evolution.com + *
  • BF [ 2910358 ] Error in context when a field is found in different tabs. + * https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332 + *
  • BF [ 2910368 ] Error in context when IsActive field is found in different + * https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332 * @version $Id: GridField.java,v 1.5 2006/07/30 00:51:02 jjanke Exp $ */ public class GridField implements Serializable, Evaluatee { + + /** * */ - private static final long serialVersionUID = 1783359481690560938L; + private static final long serialVersionUID = 1124123543602986028L; /** * Field Constructor. @@ -416,8 +423,9 @@ public class GridField return false; } + //BF [ 2910368 ] // Always editable if Active - if (checkContext && "Y".equals(Env.getContext(m_vo.ctx, m_vo.WindowNo, "IsActive")) + if (checkContext && "Y".equals(Env.getContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, "IsActive")) && ( m_vo.ColumnName.equals("Processing") || m_vo.ColumnName.equals("PaymentRule") || m_vo.ColumnName.equals("DocAction") @@ -433,9 +441,9 @@ public class GridField // IsActive field is editable, if record not processed if (m_vo.ColumnName.equals("IsActive")) return true; - - // Record is not Active - if (checkContext && !Env.getContext(m_vo.ctx, m_vo.WindowNo, "IsActive").equals("Y")) + // BF [ 2910368 ] + // Record is not Active + if (checkContext && !Env.getContext(m_vo.ctx, m_vo.WindowNo,m_vo.TabNo, "IsActive").equals("Y")) return false; // ultimately visibility decides @@ -1284,9 +1292,14 @@ public class GridField { backupValue(); // teo_sarca [ 1699826 ] Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, - ((Boolean)newValue).booleanValue()); + ((Boolean)newValue).booleanValue()); Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, m_value==null ? null : (((Boolean)m_value) ? "Y" : "N")); + //BF [ 2910368 ] + if(m_vo.ColumnName.equals("IsActive")) + { + Env.setContext(m_vo.ctx, m_vo.WindowNo,m_vo.TabNo, m_vo.ColumnName, ((Boolean)newValue).booleanValue() ? "Y" : "N"); + } } else if (newValue instanceof Timestamp) { @@ -1300,8 +1313,12 @@ public class GridField backupValue(); // teo_sarca [ 1699826 ] Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, m_value==null ? null : m_value.toString()); - Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, - m_value==null ? null : m_value.toString()); + //BF [ 2910358 ] + if(isKey()) + { + Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, + m_value==null ? null : m_value.toString()); + } } // Does not fire, if same value diff --git a/base/src/org/compiere/model/GridTab.java b/base/src/org/compiere/model/GridTab.java index 52e85b411f..c95cb63bb2 100644 --- a/base/src/org/compiere/model/GridTab.java +++ b/base/src/org/compiere/model/GridTab.java @@ -84,7 +84,12 @@ import org.compiere.util.ValueNamePair; * https://sourceforge.net/tracker/?func=detail&aid=2874109&group_id=176962&atid=879332 *
  • BF [ 2905287 ] GridTab query is not build correctly * https://sourceforge.net/tracker/?func=detail&aid=2905287&group_id=176962&atid=879332 - * @author Victor Perez , e-Evolution.SC [1877902] Implement JSR 223 Scripting APIs to Callout + * @author Victor Perez , e-Evolution.SC + *
  • FR [1877902] Implement JSR 223 Scripting APIs to Callout + *
  • BF [ 2910358 ] Error in context when a field is found in different tabs. + * https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332 + *
  • BF [ 2910368 ] Error in context when IsActive field is found in different + * https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332 * @author Carlos Ruiz, qss FR [1877902] * @see http://sourceforge.net/tracker/?func=detail&atid=879335&aid=1877902&group_id=176962 to FR [1877902] * @author Cristina Ghita, www.arhipac.ro FR [2870645] Set null value for an ID @@ -94,6 +99,7 @@ import org.compiere.util.ValueNamePair; */ public class GridTab implements DataStatusListener, Evaluatee, Serializable { + /** * */ @@ -619,10 +625,16 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } else { - String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); + //BF [ 2910358 ] + //String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); + String value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),lc); + //BF [ 2910358 ] // explicit parent link defined if ( m_parentColumnName.length() > 0 ) - value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); + { + // value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); + value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),m_parentColumnName); + } // Same link value? if (refresh) @@ -3027,4 +3039,24 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable } return list; } + + //BF [ 2910358 ] + /** + * get Parent Tab No + * @return Tab No + */ + private int getParentTabNo() + { + int tabNo = m_vo.TabNo; + int currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); + int parentLevel = currentLevel-1; + if (parentLevel < 0) + return tabNo; + while (parentLevel != currentLevel) + { + tabNo--; + currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); + } + return tabNo; + } } // GridTab diff --git a/base/src/org/compiere/model/GridTable.java b/base/src/org/compiere/model/GridTable.java index ecff883d16..88b63a7b44 100644 --- a/base/src/org/compiere/model/GridTable.java +++ b/base/src/org/compiere/model/GridTable.java @@ -73,14 +73,21 @@ import org.compiere.util.ValueNamePair; *
  • BF [ 1943682 ] Copy Record should not copy IsApproved and IsGenerated *
  • BF [ 1949543 ] Window freeze if there is a severe exception *
  • BF [ 1984310 ] GridTable.getClientOrg() doesn't work for AD_Client/AD_Org + * @author victor.perez@e-evolution.com,www.e-evolution.com + *
  • BF [ 2910358 ] Error in context when a field is found in different tabs. + * https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332 + *
  • BF [ 2910368 ] Error in context when IsActive field is found in different + * https://sourceforge.net/tracker/?func=detail&aid=2910368&group_id=176962&atid=879332 */ public class GridTable extends AbstractTableModel implements Serializable { + + /** * */ - private static final long serialVersionUID = 4071601543088224064L; + private static final long serialVersionUID = 4273775926021737068L; /** * JDBC Based Buffered Table @@ -115,6 +122,8 @@ public class GridTable extends AbstractTableModel private boolean m_withAccessControl; private boolean m_readOnly = true; private boolean m_deleteable = true; + + public static final String CTX_KeyColumnName = "KeyColumnName"; // /** Rowcount */ @@ -291,8 +300,16 @@ public class GridTable extends AbstractTableModel select.append(" FROM ").append(m_tableName); m_SQL_Select = select.toString(); m_SQL_Count = "SELECT COUNT(*) FROM " + m_tableName; - // - + //BF [ 2910358 ] + //Restore the Original Value for Key Column Name based in Tab Context Value + String parentKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), CTX_KeyColumnName); + String valueKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), parentKey); + + if(valueKey != null && valueKey.length() > 0) + { + Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey); + } + StringBuffer where = new StringBuffer(""); // WHERE if (m_whereClause.length() > 0) @@ -3227,4 +3244,23 @@ public class GridTable extends AbstractTableModel // @TODO: configurable aggressive - compare each column with the DB return false; } + + /** + * get Parent Tab No + * @return Tab No + */ + private int getParentTabNo() + { + int tabNo = m_TabNo; + int currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel); + int parentLevel = currentLevel-1; + if (parentLevel < 0) + return tabNo; + while (parentLevel != currentLevel) + { + tabNo--; + currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel); + } + return tabNo; + } }