BF [ 3007342 ] Included tab context conflict issue
Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=3007342
This commit is contained in:
parent
6b469af96f
commit
db2c6d7ec3
|
@ -64,6 +64,8 @@ import org.compiere.util.Evaluator;
|
|||
* https://sourceforge.net/tracker/?func=detail&aid=2910358&group_id=176962&atid=879332
|
||||
* <li>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
|
||||
* <li>BF [ 3007342 ] Included tab context conflict issue
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=3007342&group_id=176962&atid=879332
|
||||
* @version $Id: GridField.java,v 1.5 2006/07/30 00:51:02 jjanke Exp $
|
||||
*/
|
||||
public class GridField
|
||||
|
@ -435,8 +437,7 @@ public class GridField
|
|||
|
||||
// Record is Processed ***
|
||||
if (checkContext
|
||||
&& (Env.getContext(m_vo.ctx, m_vo.WindowNo, "Processed").equals("Y")
|
||||
|| Env.getContext(m_vo.ctx, m_vo.WindowNo, "Processing").equals("Y")))
|
||||
&& ("Y".equals(get_ValueAsString("Processed")) || "Y".equals(get_ValueAsString("Processing"))) )
|
||||
return false;
|
||||
|
||||
// IsActive field is editable, if record not processed
|
||||
|
@ -798,7 +799,7 @@ public class GridField
|
|||
*/
|
||||
public String get_ValueAsString (String variableName)
|
||||
{
|
||||
return Env.getContext (m_vo.ctx, m_vo.WindowNo, variableName, true);
|
||||
return Env.getContext (m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, variableName, false, true);
|
||||
} // get_ValueAsString
|
||||
|
||||
|
||||
|
@ -1305,23 +1306,32 @@ public class GridField
|
|||
else if (m_value instanceof Boolean)
|
||||
{
|
||||
backupValue(); // teo_sarca [ 1699826 ]
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
|
||||
((Boolean)m_value).booleanValue());
|
||||
if (!isParentTabField())
|
||||
{
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
|
||||
((Boolean)m_value).booleanValue());
|
||||
}
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
|
||||
m_value==null ? null : (((Boolean)m_value) ? "Y" : "N"));
|
||||
}
|
||||
else if (m_value instanceof Timestamp)
|
||||
{
|
||||
backupValue(); // teo_sarca [ 1699826 ]
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, (Timestamp)m_value);
|
||||
if (!isParentTabField())
|
||||
{
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, (Timestamp)m_value);
|
||||
}
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName,
|
||||
m_value==null ? null : m_value.toString().substring(0, m_value.toString().indexOf(".")));
|
||||
}
|
||||
else
|
||||
{
|
||||
backupValue(); // teo_sarca [ 1699826 ]
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName,
|
||||
m_value==null ? null : m_value.toString());
|
||||
if (!isParentTabField())
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
@ -1531,6 +1541,7 @@ public class GridField
|
|||
sb.append("(Key)");
|
||||
if (isParentColumn())
|
||||
sb.append("(Parent)");
|
||||
sb.append(", IsDisplayed="+m_vo.IsDisplayed);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
} // toString
|
||||
|
@ -1668,7 +1679,7 @@ public class GridField
|
|||
*/
|
||||
private final void backupValue() {
|
||||
if (!m_isBackupValue) {
|
||||
m_backupValue = Env.getContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName);
|
||||
m_backupValue = get_ValueAsString(m_vo.ColumnName);
|
||||
if (CLogMgt.isLevelFinest())
|
||||
log.finest("Backup " + m_vo.WindowNo + "|" + m_vo.ColumnName + "=" + m_backupValue);
|
||||
m_isBackupValue = true;
|
||||
|
@ -1681,9 +1692,18 @@ public class GridField
|
|||
*/
|
||||
public void restoreValue() {
|
||||
if (m_isBackupValue) {
|
||||
if (CLogMgt.isLevelFinest())
|
||||
log.finest("Restore " + m_vo.WindowNo + "|" + m_vo.ColumnName + "=" + m_backupValue);
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, m_backupValue);
|
||||
if (isParentTabField())
|
||||
{
|
||||
if (CLogMgt.isLevelFinest())
|
||||
log.finest("Restore " + m_vo.WindowNo + "|" + m_vo.TabNo + "|" + m_vo.ColumnName + "=" + m_backupValue);
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, m_vo.ColumnName, m_backupValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CLogMgt.isLevelFinest())
|
||||
log.finest("Restore " + m_vo.WindowNo + "|" + m_vo.ColumnName + "=" + m_backupValue);
|
||||
Env.setContext(m_vo.ctx, m_vo.WindowNo, m_vo.ColumnName, m_backupValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1793,4 +1813,27 @@ public class GridField
|
|||
{
|
||||
return m_gridTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columnName
|
||||
* @return true if columnName also exist in parent tab
|
||||
*/
|
||||
private boolean isParentTabField(String columnName)
|
||||
{
|
||||
if (m_gridTab == null)
|
||||
return false;
|
||||
GridTab parentTab = m_gridTab.getParentTab();
|
||||
if (parentTab == null)
|
||||
return false;
|
||||
return parentTab.getField(columnName) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return true if this field (m_vo.ColumnName) also exist in parent tab
|
||||
*/
|
||||
private boolean isParentTabField()
|
||||
{
|
||||
return isParentTabField(m_vo.ColumnName);
|
||||
}
|
||||
} // MField
|
||||
|
|
|
@ -84,6 +84,8 @@ import org.compiere.util.ValueNamePair;
|
|||
* https://sourceforge.net/tracker/?func=detail&aid=2874109&group_id=176962&atid=879332
|
||||
* <li>BF [ 2905287 ] GridTab query is not build correctly
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=2905287&group_id=176962&atid=879332
|
||||
* <li>BF [ 3007342 ] Included tab context conflict issue
|
||||
* https://sourceforge.net/tracker/?func=detail&aid=3007342&group_id=176962&atid=879332
|
||||
* @author Victor Perez , e-Evolution.SC
|
||||
* <li>FR [1877902] Implement JSR 223 Scripting APIs to Callout
|
||||
* <li>BF [ 2910358 ] Error in context when a field is found in different tabs.
|
||||
|
@ -1473,7 +1475,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
*/
|
||||
public String get_ValueAsString (String variableName)
|
||||
{
|
||||
return Env.getContext (m_vo.ctx, m_vo.WindowNo, variableName, true);
|
||||
return Env.getContext (m_vo.ctx, m_vo.WindowNo, m_vo.TabNo, variableName, false, true);
|
||||
} // get_ValueAsString
|
||||
|
||||
/**
|
||||
|
@ -3076,5 +3078,13 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
|
|||
currentLevel = Env.getContextAsInt(m_vo.ctx, m_vo.WindowNo, tabNo, GridTab.CTX_TabLevel);
|
||||
}
|
||||
return tabNo;
|
||||
}
|
||||
}
|
||||
|
||||
public GridTab getParentTab()
|
||||
{
|
||||
int parentTabNo = getParentTabNo();
|
||||
if (parentTabNo < 0 || parentTabNo == m_vo.TabNo)
|
||||
return null;
|
||||
return m_window.getTab(parentTabNo);
|
||||
}
|
||||
} // GridTab
|
||||
|
|
|
@ -544,6 +544,24 @@ public final class Env
|
|||
* @return value or ""
|
||||
*/
|
||||
public static String getContext (Properties ctx, int WindowNo, int TabNo, String context, boolean onlyTab)
|
||||
{
|
||||
final boolean onlyWindow = onlyTab ? true : false;
|
||||
return getContext(ctx, WindowNo, TabNo, context, onlyTab, onlyWindow);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @param onlyWindow if true, no global context will be searched
|
||||
* @return value or ""
|
||||
*/
|
||||
public static String getContext (Properties ctx, int WindowNo, int TabNo, String context, boolean onlyTab, boolean onlyWindow)
|
||||
{
|
||||
if (ctx == null || context == null)
|
||||
throw new IllegalArgumentException ("Require Context");
|
||||
|
@ -553,7 +571,7 @@ public final class Env
|
|||
return s != null ? s : "";
|
||||
//
|
||||
if (s == null && ! onlyTab)
|
||||
return getContext(ctx, WindowNo, context, false);
|
||||
return getContext(ctx, WindowNo, context, onlyWindow);
|
||||
return s;
|
||||
} // getContext
|
||||
|
||||
|
|
Loading…
Reference in New Issue