Enhance to allow zooming to any level ( tested zooming from gl journal to the period tab in the calendar-year-period window )

Link to SF Tracker: http://sourceforge.net/support/tracker.php?aid=2887701
This commit is contained in:
Heng Sin Low 2010-02-01 10:40:13 +00:00
parent f06f95ad72
commit ca187b22b7
2 changed files with 147 additions and 59 deletions

View File

@ -1144,5 +1144,15 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
public boolean isGridView() {
return listPanel.isVisible();
}
public IADTabpanel findEmbeddedPanel(GridTab gTab) {
IADTabpanel panel = null;
for(EmbeddedPanel ep : includedPanel) {
if (ep.tabPanel.getGridTab().equals(gTab)) {
return ep.tabPanel;
}
}
return panel;
}
}

View File

@ -24,6 +24,7 @@ import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.TreeMap;
import java.util.Vector;
import java.util.logging.Level;
@ -294,11 +295,23 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
m_onlyCurrentRows = embeddedTabindex < 0 && gridWindow.isTransaction();
MQuery detailQuery = null;
/**
* Window Tabs
*/
if (embeddedTabindex < 0)
{
if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null
&& query.getZoomValue() instanceof Integer && (Integer)query.getZoomValue() > 0)
{
if (!query.getZoomTableName().equalsIgnoreCase(gridWindow.getTab(0).getTableName()))
{
detailQuery = query;
query = new MQuery();
query.addRestriction("1=2");
}
}
int tabSize = gridWindow.getTabCount();
for (int tab = 0; tab < tabSize; tab++)
@ -331,7 +344,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
toolbar.enableHistoryRecords(true);
}
if (zoomToDetailTab(query))
if (detailQuery != null && zoomToDetailTab(detailQuery))
{
return true;
}
@ -363,21 +376,92 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
gTab = gridWindow.getTab(tab);
if (gTab.isSortTab())
continue;
if (gTab.getTabLevel() == 1 && gTab.getTableName().equalsIgnoreCase(query.getZoomTableName()))
if (gTab.getTableName().equalsIgnoreCase(query.getZoomTableName()))
{
if (doZoomToDetail(gTab, query, tab)) {
return true;
}
}
}
}
}
return false;
}
private boolean doZoomToDetail(GridTab gTab, MQuery query, int tabIndex) {
GridField[] fields = gTab.getFields();
for (GridField field : fields)
{
if (field.getColumnName().equalsIgnoreCase(query.getZoomColumnName()))
{
if (query.getZoomValue() != null && query.getZoomValue() instanceof Integer)
gridWindow.initTab(tabIndex);
int parentId = DB.getSQLValue(null, "SELECT " + gTab.getLinkColumnName() + " FROM " + gTab.getTableName() + " WHERE " + query.getWhereClause());
if (parentId > 0)
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
Map<Integer, Object[]>parentMap = new TreeMap<Integer, Object[]>();
int index = tabIndex;
int oldpid = parentId;
GridTab currentTab = gTab;
while (index > 0)
{
IADTabpanel tp = adTab.findADTabpanel(gTab);
index--;
GridTab pTab = gridWindow.getTab(index);
if (pTab.getTabLevel() < currentTab.getTabLevel())
{
gridWindow.initTab(index);
if (index > 0)
{
if (pTab.getLinkColumnName() != null && pTab.getLinkColumnName().trim().length() > 0)
{
int pid = DB.getSQLValue(null, "SELECT " + pTab.getLinkColumnName() + " FROM " + pTab.getTableName() + " WHERE " + currentTab.getLinkColumnName() + " = ?", oldpid);
if (pid > 0)
{
parentMap.put(index, new Object[]{currentTab.getLinkColumnName(), oldpid});
oldpid = pid;
currentTab = pTab;
}
else
{
parentMap.clear();
break;
}
}
}
else
{
parentMap.put(index, new Object[]{currentTab.getLinkColumnName(), oldpid});
}
}
}
for(Map.Entry<Integer, Object[]> entry : parentMap.entrySet())
{
GridTab pTab = gridWindow.getTab(entry.getKey());
Object[] value = entry.getValue();
MQuery pquery = new MQuery(pTab.getAD_Table_ID());
pquery.addRestriction((String)value[0], "=", value[1]);
pTab.setQuery(pquery);
IADTabpanel tp = adTab.findADTabpanel(pTab);
tp.createUI();
tp.query();
}
MQuery targetQuery = new MQuery(gTab.getAD_Table_ID());
targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId);
gTab.setQuery(targetQuery);
IADTabpanel gc = null;
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
gc = adTab.findADTabpanel(gTab);
}
else
{
ADTabpanel parent = (ADTabpanel)includedMap.get(gTab.getAD_Tab_ID());
gc = parent.findEmbeddedPanel(gTab);
}
gc.createUI();
gc.query(false, 0, 0);
GridTable table = gTab.getTableModel();
int count = table.getRowCount();
for(int i = 0; i < count; i++)
@ -387,24 +471,18 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
setActiveTab(tab);
}
gTab.setCurrentRow(i);
return true;
}
}
setActiveTab(gridWindow.getTabIndex(gTab));
}
else
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
setActiveTab(tab);
IADTabpanel parent = includedMap.get(gTab.getAD_Tab_ID());
int pindex = gridWindow.getTabIndex(parent.getGridTab());
if (pindex >= 0)
setActiveTab(pindex);
}
gTab.setCurrentRow(i);
return true;
}
break;
}
}
}
}
}