* [ 1631888 ] Lazy loading of tab

This commit is contained in:
Heng Sin Low 2007-02-08 06:45:10 +00:00
parent 548b8a1c46
commit 5142683b28
2 changed files with 36 additions and 13 deletions

View File

@ -515,7 +515,8 @@ public final class APanel extends CPanel
{ {
boolean included = false; boolean included = false;
// MTab // MTab
GridTab gTab = m_mWorkbench.getMWindow(wb).getTab(tab); if (tab == 0) mWindow.initTab(0);
GridTab gTab = mWindow.getTab(tab);
Env.setContext(m_ctx, m_curWindowNo, tab, "TabLevel", Integer.toString(gTab.getTabLevel())); Env.setContext(m_ctx, m_curWindowNo, tab, "TabLevel", Integer.toString(gTab.getTabLevel()));
// Query first tab // Query first tab
if (tab == 0) if (tab == 0)
@ -557,7 +558,7 @@ public final class APanel extends CPanel
CompiereColor cc = mWindow.getColor(); CompiereColor cc = mWindow.getColor();
if (cc != null) if (cc != null)
gc.setBackgroundColor(cc); // set color on Window level gc.setBackgroundColor(cc); // set color on Window level
gc.initGrid(gTab, false, m_curWindowNo, this, mWindow); // will set color on Tab level gc.initGrid(gTab, false, m_curWindowNo, this, mWindow, (tab != 0)); // will set color on Tab level
// Timing: ca. 6-7 sec for first .2 for next // Timing: ca. 6-7 sec for first .2 for next
gc.addDataStatusListener(this); gc.addDataStatusListener(this);
gc.registerESCAction(aIgnore); // register Escape Key gc.registerESCAction(aIgnore); // register Escape Key
@ -1032,6 +1033,7 @@ public final class APanel extends CPanel
} }
else // Cur Tab Setting else // Cur Tab Setting
{ {
m_mWorkbench.getMWindow(0).initTab(m_curTabIndex);
m_curGC.activate(); m_curGC.activate();
m_curTab = m_curGC.getMTab(); m_curTab = m_curGC.getMTab();

View File

@ -253,6 +253,15 @@ public class GridController extends CPanel
/** Tree Panel (optional) */ /** Tree Panel (optional) */
private VTreePanel m_tree; private VTreePanel m_tree;
private APanel m_aPanel;
private boolean init;
public boolean initGrid (GridTab mTab, boolean onlyMultiRow,
int WindowNo, APanel aPanel, GridWindow mWindow)
{
return initGrid(mTab, onlyMultiRow, WindowNo, aPanel, mWindow, false);
}
/************************************************************************** /**************************************************************************
* Init Grid. * Init Grid.
@ -270,19 +279,31 @@ public class GridController extends CPanel
* @return true if initialized * @return true if initialized
*/ */
public boolean initGrid (GridTab mTab, boolean onlyMultiRow, public boolean initGrid (GridTab mTab, boolean onlyMultiRow,
int WindowNo, APanel aPanel, GridWindow mWindow) int WindowNo, APanel aPanel, GridWindow mWindow, boolean lazy)
{ {
log.config( "(" + mTab.toString() + ")"); log.config( "(" + mTab.toString() + ")");
m_mTab = mTab; m_mTab = mTab;
m_WindowNo = WindowNo; m_WindowNo = WindowNo;
m_onlyMultiRow = onlyMultiRow; m_onlyMultiRow = onlyMultiRow;
m_aPanel = aPanel;
setName("GC-" + mTab); setName("GC-" + mTab);
setTabLevel(m_mTab.getTabLevel());
if (!lazy)
init();
// log.config( "GridController.dynInit (" + mTab.toString() + ") - fini");
return true;
} // initGrid
private void init()
{
// Set up Multi Row Table // Set up Multi Row Table
vTable.setModel(m_mTab.getTableModel()); vTable.setModel(m_mTab.getTableModel());
// Update Table Info ------------------------------------------------- // Update Table Info -------------------------------------------------
int size = setupVTable (aPanel, m_mTab, vTable); int size = setupVTable (m_aPanel, m_mTab, vTable);
// Set Color on Tab Level // Set Color on Tab Level
// this.setBackgroundColor (mTab.getColor()); // this.setBackgroundColor (mTab.getColor());
@ -317,8 +338,8 @@ public class GridController extends CPanel
// Add to VPanel // Add to VPanel
vPanel.addField(vEditor, mField); vPanel.addField(vEditor, mField);
// APanel Listen to buttons // APanel Listen to buttons
if (mField.getDisplayType() == DisplayType.Button && aPanel != null) if (mField.getDisplayType() == DisplayType.Button && m_aPanel != null)
((JButton)vEditor).addActionListener (aPanel); ((JButton)vEditor).addActionListener (m_aPanel);
} }
} // for all fields } // for all fields
@ -365,16 +386,14 @@ public class GridController extends CPanel
// Update UI // Update UI
vTable.autoSize(true); vTable.autoSize(true);
setTabLevel(m_mTab.getTabLevel()); // Set initial presentation
if (m_onlyMultiRow || !m_mTab.isSingleRow())
// Set initial presentation
if (onlyMultiRow || !m_mTab.isSingleRow())
switchMultiRow(); switchMultiRow();
else else
switchSingleRow(); switchSingleRow();
// log.config( "GridController.dynInit (" + mTab.toString() + ") - fini");
return true; init = true;
} // initGrid }
/** /**
* Include Tab * Include Tab
@ -525,6 +544,8 @@ public class GridController extends CPanel
*/ */
public void activate () public void activate ()
{ {
if (!init) init();
// Tree to be initiated on second/.. tab // Tree to be initiated on second/.. tab
if (m_mTab.isTreeTab() && m_mTab.getTabNo() != 0) if (m_mTab.isTreeTab() && m_mTab.getTabNo() != 0)
{ {