IDEMPIERE-6330 For zoom to level 2 tab, the parent level 1 tab will only retrieve 1 record (#2576)
This commit is contained in:
parent
edea913918
commit
6e1a7c3dc5
|
@ -506,7 +506,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
* Execute zoom to detail tab.
|
||||
* @param gTab GridTab of tab at tabIndex
|
||||
* @param query detail tab query
|
||||
* @param tabIndex
|
||||
* @param tabIndex target tab index
|
||||
* @return true if successfully zoom to detail tab
|
||||
*/
|
||||
private boolean doZoomToDetail(GridTab gTab, MQuery query, int tabIndex) {
|
||||
|
@ -521,24 +521,24 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
List<List<Object>> parentIds = DB.getSQLArrayObjectsEx(null, sql.toString());
|
||||
if (parentIds!=null && parentIds.size() > 0)
|
||||
{
|
||||
GridTab parentTab = null;
|
||||
//Tab Index:MQuery
|
||||
Map<Integer, MQuery>queryMap = new TreeMap<Integer, MQuery>();
|
||||
|
||||
for (List<Object>parentIdList : parentIds)
|
||||
{
|
||||
Object parentId = parentIdList.get(0);
|
||||
//Tab Index:(ColumnName,Value)
|
||||
Map<Integer, Object[]>parentMap = new TreeMap<Integer, Object[]>();
|
||||
int index = tabIndex;
|
||||
Object oldpid = parentId;
|
||||
GridTab currentTab = gTab;
|
||||
//walk backward to level 0 tab
|
||||
while (index > 0)
|
||||
{
|
||||
index--;
|
||||
GridTab pTab = gridWindow.getTab(index);
|
||||
if (pTab.getTabLevel() < currentTab.getTabLevel())
|
||||
{
|
||||
if (parentTab == null)
|
||||
parentTab = pTab;
|
||||
gridWindow.initTab(index);
|
||||
if (index > 0)
|
||||
{
|
||||
|
@ -572,17 +572,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
{
|
||||
GridTab pTab = gridWindow.getTab(entry.getKey());
|
||||
Object[] value = entry.getValue();
|
||||
MQuery pquery = queryMap.get(entry.getKey());
|
||||
if (pquery == null)
|
||||
{
|
||||
pquery = new MQuery(pTab.getAD_Table_ID());
|
||||
queryMap.put(entry.getKey(), pquery);
|
||||
pquery.addRestriction((String)value[0], "=", value[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
pquery.addRestriction((String)value[0], "=", value[1], null, null, false, 0);
|
||||
}
|
||||
MQuery pquery = new MQuery(pTab.getAD_Table_ID());
|
||||
queryMap.put(entry.getKey(), pquery);
|
||||
pquery.addRestriction((String)value[0], "=", value[1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,24 +591,63 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
tp.query();
|
||||
//update context
|
||||
if (pTab.getRowCount() > 0)
|
||||
{
|
||||
boolean pTabUpdateWindowContext = pTab != null ? pTab.isUpdateWindowContext(): false ;
|
||||
if (pTab != null && !pTabUpdateWindowContext)
|
||||
pTab.setUpdateWindowContext(true);
|
||||
pTab.setCurrentRow(0, false);
|
||||
if (pTab != null && !pTabUpdateWindowContext)
|
||||
pTab.setUpdateWindowContext(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tp.query();
|
||||
pTab.setQuery(entry.getValue());
|
||||
{
|
||||
//retrieve records of sub tab
|
||||
tp.query();
|
||||
//find sub tab row that match the stored query
|
||||
MQuery tabQuery = entry.getValue();
|
||||
int rowFound = -1;
|
||||
for(int i = 0; i < pTab.getRowCount(); i++)
|
||||
{
|
||||
Object tabValue = pTab.getValue(i, tabQuery.getColumnName(0));
|
||||
if (tabValue != null && tabQuery.getCode(0) != null)
|
||||
{
|
||||
//handle potential difference in numeric datatype, for e.g integer vs bigdecimal
|
||||
if (tabQuery.getColumnName(0).endsWith("_ID") && tabValue instanceof Number n1 && tabQuery.getCode(0) instanceof Number n2)
|
||||
{
|
||||
if (n1.intValue() == n2.intValue())
|
||||
{
|
||||
rowFound = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (tabValue.equals(tabQuery.getCode(0)))
|
||||
{
|
||||
rowFound = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rowFound == -1)
|
||||
{
|
||||
//fall back to execution of stored query
|
||||
pTab.setQuery(entry.getValue());
|
||||
tp.query();
|
||||
rowFound = 0;
|
||||
}
|
||||
//update context
|
||||
if (pTab.getRowCount() > 0) {
|
||||
pTab.setCurrentRow(0, false);
|
||||
boolean pTabUpdateWindowContext = pTab != null ? pTab.isUpdateWindowContext(): false ;
|
||||
if (pTab != null && !pTabUpdateWindowContext)
|
||||
pTab.setUpdateWindowContext(true);
|
||||
pTab.setCurrentRow(rowFound, false);
|
||||
if (pTab != null && !pTabUpdateWindowContext)
|
||||
pTab.setUpdateWindowContext(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//execute query for detail tab
|
||||
MQuery targetQuery = new MQuery(gTab.getAD_Table_ID());
|
||||
targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentTab.getRecord_ID());
|
||||
gTab.setQuery(targetQuery);
|
||||
IADTabpanel gc = null;
|
||||
gc = adTabbox.findADTabpanel(gTab);
|
||||
gc.createUI();
|
||||
|
|
Loading…
Reference in New Issue