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:36:39 +00:00
parent 47022f6791
commit f06f95ad72
3 changed files with 350 additions and 263 deletions

View File

@ -33,7 +33,9 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
import java.util.Vector;
import java.util.logging.Level;
@ -664,6 +666,7 @@ public final class APanel extends CPanel
Dimension windowSize = m_mWorkbench.getWindowSize();
MQuery detailQuery = null;
/**
* WorkBench Loop
*/
@ -740,6 +743,16 @@ public final class APanel extends CPanel
// initial user query for single workbench tab
if (m_mWorkbench.getWindowCount() == 1)
{
if (query != null && query.getZoomTableName() != null && query.getZoomColumnName() != null
&& query.getZoomValue() instanceof Integer && (Integer)query.getZoomValue() > 0)
{
if (!query.getZoomTableName().equalsIgnoreCase(gTab.getTableName()))
{
detailQuery = query;
query = new MQuery();
query.addRestriction("1=2");
}
}
isCancel = false; //Goodwill
query = initialQuery (query, gTab);
if (isCancel) return false; //Cancel opening window
@ -879,7 +892,7 @@ public final class APanel extends CPanel
else
revalidate();
if (zoomToDetailTab(query)) {
if (detailQuery != null && zoomToDetailTab(detailQuery)) {
return true;
}
@ -903,26 +916,93 @@ public final class APanel extends CPanel
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)
m_mWorkbench.getMWindow(0).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)
{
m_mWorkbench.getMWindow(0).initTab(tab);
int index = tabPanel.findTabindex(gTab);
if (index >= 0)
index--;
GridTab pTab = m_mWorkbench.getMWindow(0).getTab(index);
if (pTab.getTabLevel() < currentTab.getTabLevel())
{
GridController gc = (GridController) tabPanel.getComponentAt(index);
m_mWorkbench.getMWindow(0).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 = m_mWorkbench.getMWindow(0).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);
GridController gc = (GridController) tabPanel.getComponentAt(entry.getKey());
gc.activate();
gc.query(false, 0, 0);
}
MQuery targetQuery = new MQuery(gTab.getAD_Table_ID());
targetQuery.addRestriction(gTab.getLinkColumnName(), "=", parentId);
gTab.setQuery(targetQuery);
GridController gc = null;
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
int target = tabPanel.findTabindex(gTab);
gc = (GridController) tabPanel.getComponentAt(target);
}
else
{
GridController parent = includedMap.get(gTab.getAD_Tab_ID());
gc = parent.findChild(gTab);
}
gc.activate();
gc.query(false, 0, 0);
GridTable table = gTab.getTableModel();
int count = table.getRowCount();
for(int i = 0; i < count; i++)
@ -932,28 +1012,18 @@ public final class APanel extends CPanel
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
int index = tabPanel.findTabindex(gTab);
if (index >= 0)
tabPanel.setSelectedIndex(index);
}
gTab.navigate(i);
return true;
}
}
tabPanel.setSelectedIndex(tabPanel.findTabindex(gTab));
}
else
{
if (!includedMap.containsKey(gTab.getAD_Tab_ID()))
{
int index = tabPanel.findTabindex(gTab);
if (index >= 0)
tabPanel.setSelectedIndex(index);
GridController parent = includedMap.get(gTab.getAD_Tab_ID());
int pindex = tabPanel.findTabindex(parent.getMTab());
if (pindex >= 0)
tabPanel.setSelectedIndex(pindex);
}
gTab.navigate(i);
return true;
}
break;
}
}
}
}
}

View File

@ -667,6 +667,20 @@ public class GridController extends CPanel
}
}
public GridController findChild(GridTab gTab)
{
GridController gc = null;
for (GridSynchronizer s : synchronizerList )
{
if (s.getChild().getMTab().equals(gTab))
{
gc = s.getChild();
break;
}
}
return gc;
}
/**
* Register ESC Actions
* - overwrite VTable's Keystrokes assignment for ESC

View File

@ -73,4 +73,7 @@ public class GridSynchronizer implements PropertyChangeListener, StateChangeList
child.query (false, 0, role.getMaxQueryRecords());
}
public GridController getChild() {
return child;
}
}