* [ 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;
// 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()));
// Query first tab
if (tab == 0)
@ -557,7 +558,7 @@ public final class APanel extends CPanel
CompiereColor cc = mWindow.getColor();
if (cc != null)
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
gc.addDataStatusListener(this);
gc.registerESCAction(aIgnore); // register Escape Key
@ -1032,6 +1033,7 @@ public final class APanel extends CPanel
}
else // Cur Tab Setting
{
m_mWorkbench.getMWindow(0).initTab(m_curTabIndex);
m_curGC.activate();
m_curTab = m_curGC.getMTab();

View File

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