Peer review for:

[2904737] - fix BOM back compatibility
[2910358] - Error in context when Key field is found in different tabs.
[2910368] - Error in context when IsActive field is found in different
[2871039] - Tax Rate Parent window not working
Guarantee backward compatibility with previous approach
Added method to get tab context variables without defaulting to window or login variable (required safety measure)
Some refactorings to improve reading and performance
Reactivate hidden tabs - and move back BOM & Formula window to manufacturing menu
This commit is contained in:
Carlos Ruiz 2009-12-10 01:07:52 +00:00
parent 02678a408d
commit 68ae89d149
6 changed files with 121 additions and 43 deletions

View File

@ -69,8 +69,6 @@ import org.compiere.util.Evaluator;
public class GridField public class GridField
implements Serializable, Evaluatee implements Serializable, Evaluatee
{ {
/** /**
* *
*/ */
@ -1295,11 +1293,6 @@ public class GridField
((Boolean)newValue).booleanValue()); ((Boolean)newValue).booleanValue());
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
m_value==null ? null : (((Boolean)m_value) ? "Y" : "N")); 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) else if (newValue instanceof Timestamp)
{ {
@ -1313,12 +1306,8 @@ public class GridField
backupValue(); // teo_sarca [ 1699826 ] backupValue(); // teo_sarca [ 1699826 ]
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
m_value==null ? null : m_value.toString()); m_value==null ? null : m_value.toString());
//BF [ 2910358 ] Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
if(isKey())
{
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
m_value==null ? null : m_value.toString()); m_value==null ? null : m_value.toString());
}
} }
// Does not fire, if same value // Does not fire, if same value

View File

@ -99,7 +99,6 @@ import org.compiere.util.ValueNamePair;
*/ */
public class GridTab implements DataStatusListener, Evaluatee, Serializable public class GridTab implements DataStatusListener, Evaluatee, Serializable
{ {
/** /**
* *
*/ */
@ -625,15 +624,17 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
} }
else else
{ {
//BF [ 2910358 ] String value = null;
//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 ) if ( m_parentColumnName.length() > 0 )
{ {
// value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); // explicit parent link defined
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, this.getParentTabNo(),m_parentColumnName); value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getParentTabNo(), m_parentColumnName, true);
if (value == null || value.length() == 0)
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_parentColumnName, true); // back compatibility
} else {
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, getParentTabNo(), lc, true);
if (value == null || value.length() == 0)
value = Env.getContext(m_vo.ctx, m_vo.WindowNo, lc, true); // back compatibility
} }
// Same link value? // Same link value?
@ -3048,15 +3049,15 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
private int getParentTabNo() private int getParentTabNo()
{ {
int tabNo = m_vo.TabNo; int tabNo = m_vo.TabNo;
int currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); int currentLevel = m_vo.TabLevel;
int parentLevel = currentLevel-1; int parentLevel = currentLevel-1;
if (parentLevel < 0) if (parentLevel < 0)
return tabNo; return tabNo;
while (parentLevel != currentLevel) while (parentLevel != currentLevel)
{ {
tabNo--; tabNo--;
currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel); currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
} }
return tabNo; return tabNo;
} }
} // GridTab } // GridTab

View File

@ -82,8 +82,6 @@ import org.compiere.util.ValueNamePair;
public class GridTable extends AbstractTableModel public class GridTable extends AbstractTableModel
implements Serializable implements Serializable
{ {
/** /**
* *
*/ */
@ -122,8 +120,6 @@ public class GridTable extends AbstractTableModel
private boolean m_withAccessControl; private boolean m_withAccessControl;
private boolean m_readOnly = true; private boolean m_readOnly = true;
private boolean m_deleteable = true; private boolean m_deleteable = true;
public static final String CTX_KeyColumnName = "KeyColumnName";
// //
/** Rowcount */ /** Rowcount */
@ -302,12 +298,13 @@ public class GridTable extends AbstractTableModel
m_SQL_Count = "SELECT COUNT(*) FROM " + m_tableName; m_SQL_Count = "SELECT COUNT(*) FROM " + m_tableName;
//BF [ 2910358 ] //BF [ 2910358 ]
//Restore the Original Value for Key Column Name based in Tab Context Value //Restore the Original Value for Key Column Name based in Tab Context Value
String parentKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), CTX_KeyColumnName); int parentTabNo = getParentTabNo();
String valueKey = Env.getContext(m_ctx, m_WindowNo, getParentTabNo(), parentKey); String parentKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, GridTab.CTX_KeyColumnName, true);
String valueKey = Env.getContext(m_ctx, m_WindowNo, parentTabNo, parentKey, true);
if(valueKey != null && valueKey.length() > 0) String currKey = Env.getContext(m_ctx, m_WindowNo, parentKey);
if (valueKey != null && valueKey.length() > 0 && parentKey != null && parentKey.length() > 0 && ! currKey.equals(valueKey))
{ {
Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey); Env.setContext(m_ctx, m_WindowNo, parentKey, valueKey);
} }
StringBuffer where = new StringBuffer(""); StringBuffer where = new StringBuffer("");
@ -3256,11 +3253,11 @@ public class GridTable extends AbstractTableModel
int parentLevel = currentLevel-1; int parentLevel = currentLevel-1;
if (parentLevel < 0) if (parentLevel < 0)
return tabNo; return tabNo;
while (parentLevel != currentLevel) while (parentLevel != currentLevel)
{ {
tabNo--; tabNo--;
currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel); currentLevel = Env.getContextAsInt(m_ctx, m_WindowNo, tabNo, GridTab.CTX_TabLevel);
} }
return tabNo; return tabNo;
} }
} }

View File

@ -531,6 +531,31 @@ public final class Env
return s; return s;
} // getContext } // getContext
/**
* Get Value of Context for Window & Tab,
* if not found global context if available.
* If TabNo is TAB_INFO only tab's context will be checked.
* @param ctx context
* @param WindowNo window no
* @param TabNo tab no
* @param context context key
* @param onlyTab if true, no window value is searched
* @return value or ""
*/
public static String getContext (Properties ctx, int WindowNo, int TabNo, String context, boolean onlyTab)
{
if (ctx == null || context == null)
throw new IllegalArgumentException ("Require Context");
String s = ctx.getProperty(WindowNo+"|"+TabNo+"|"+context);
// If TAB_INFO, don't check Window and Global context - teo_sarca BF [ 2017987 ]
if (TAB_INFO == TabNo)
return s != null ? s : "";
//
if (s == null && ! onlyTab)
return getContext(ctx, WindowNo, context, false);
return s;
} // getContext
/** /**
* Get Context and convert it to an integer (0 if error) * Get Context and convert it to an integer (0 if error)
* @param ctx context * @param ctx context

View File

@ -0,0 +1,33 @@
-- Dec 9, 2009 7:28:02 PM COT
-- BF [2904737] - fix BOM back compatibility
UPDATE AD_Tab SET IsActive='Y',Updated=TO_DATE('2009-12-09 19:28:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53286
;
-- Dec 9, 2009 7:28:06 PM COT
UPDATE AD_Tab SET IsActive='Y',Updated=TO_DATE('2009-12-09 19:28:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53287
;
-- Dec 9, 2009 7:28:42 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=0, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53023
;
-- Dec 9, 2009 7:28:42 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=1, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53024
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=2, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53025
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=3, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53026
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=4, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53027
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=5, Updated=SysDate WHERE AD_Tree_ID=10 AND Node_ID=53028
;

View File

@ -0,0 +1,33 @@
-- Dec 9, 2009 7:28:02 PM COT
-- BF [2904737] - fix BOM back compatibility
UPDATE AD_Tab SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-09 19:28:02','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53286
;
-- Dec 9, 2009 7:28:06 PM COT
UPDATE AD_Tab SET IsActive='Y',Updated=TO_TIMESTAMP('2009-12-09 19:28:06','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Tab_ID=53287
;
-- Dec 9, 2009 7:28:42 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=0, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53023
;
-- Dec 9, 2009 7:28:42 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=1, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53024
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=2, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53025
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=3, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53026
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=4, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53027
;
-- Dec 9, 2009 7:28:43 PM COT
UPDATE AD_TreeNodeMM SET Parent_ID=53022, SeqNo=5, Updated=CURRENT_TIMESTAMP WHERE AD_Tree_ID=10 AND Node_ID=53028
;