* [ 1631888 ] Lazy loading of tab

This commit is contained in:
Heng Sin Low 2007-02-08 06:44:56 +00:00
parent b44d933df4
commit 548b8a1c46
3 changed files with 96 additions and 58 deletions

View File

@ -122,7 +122,7 @@ public class GridField
return;
log.config("(" + m_vo.ColumnName + ")");
if (DisplayType.isLookup(m_vo.displayType))
if (DisplayType.isLookup(m_vo.displayType) && m_vo.IsDisplayed)
{
if (m_vo.lookupInfo == null)
{
@ -673,6 +673,7 @@ public class GridField
// cannot be validated
if (!isLookup()
|| m_lookup == null
|| m_lookup.containsKey(m_value))
return true;
// it's not null, a lookup and does not have the key

View File

@ -68,7 +68,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
m_mTable.setDeleteable(m_vo.IsDeleteable);
// Load Tab
// if (vo.TabNo == 0)
initTab(false);
//initTab(false);
// else
// {
// m_loader = new Loader();
@ -169,6 +169,11 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
log.config ("fini");
} // waitLoadComplete
public boolean isLoadComplete()
{
return m_loadComplete;
}
/**
* Initialize Tab with record from AD_Tab_v
* @param async async
@ -219,8 +224,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
m_Chats.clear();
m_Chats = null;
//
m_vo.Fields.clear();
m_vo.Fields = null;
m_vo.getFields().clear();
//m_vo.Fields = null;
m_vo = null;
} // dispose
@ -234,13 +239,13 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
{
log.fine("#" + m_vo.TabNo);
if (m_vo.Fields == null)
if (m_vo.getFields() == null)
return false;
// Add Fields
for (int f = 0; f < m_vo.Fields.size(); f++)
for (int f = 0; f < m_vo.getFields().size(); f++)
{
GridFieldVO voF = (GridFieldVO)m_vo.Fields.get(f);
GridFieldVO voF = (GridFieldVO)m_vo.getFields().get(f);
// Add Fields to Table
if (voF != null)
{
@ -359,6 +364,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
*/
public GridTable getTableModel()
{
if (!m_loadComplete) initTab(false);
return m_mTable;
} // getTableModel
@ -482,6 +488,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
*/
public void query (boolean onlyCurrentRows, int onlyCurrentDays, int maxRows)
{
if (!m_loadComplete) initTab(false);
log.fine("#" + m_vo.TabNo
+ " - Only Current Rows=" + onlyCurrentRows
+ ", Days=" + onlyCurrentDays + ", Detail=" + isDetail());

View File

@ -119,55 +119,64 @@ public class GridWindow implements Serializable
GridTab mTab = new GridTab(mTabVO);
Env.setContext(mTabVO.ctx, mTabVO.WindowNo, mTabVO.TabNo,
"KeyColumnName", mTab.getKeyColumnName());
// Set Link Column
if (mTab.getLinkColumnName().length() == 0)
{
ArrayList parents = mTab.getParentColumnNames();
// No Parent - no link
if (parents.size() == 0)
;
// Standard case
else if (parents.size() == 1)
mTab.setLinkColumnName((String)parents.get(0));
else
{
// More than one parent.
// Search prior tabs for the "right parent"
// for all previous tabs
for (int i = 0; i < m_tabs.size(); i++)
{
// we have a tab
GridTab tab = (GridTab)m_tabs.get(i);
String tabKey = tab.getKeyColumnName(); // may be ""
// look, if one of our parents is the key of that tab
for (int j = 0; j < parents.size(); j++)
{
String parent = (String)parents.get(j);
if (parent.equals(tabKey))
{
mTab.setLinkColumnName(parent);
break;
}
// The tab could have more than one key, look into their parents
if (tabKey.equals(""))
for (int k = 0; k < tab.getParentColumnNames().size(); k++)
if (parent.equals(tab.getParentColumnNames().get(k)))
{
mTab.setLinkColumnName(parent);
break;
}
} // for all parents
} // for all previous tabs
} // parents.size > 1
} // set Link column
mTab.setLinkColumnName(null); // overwrites, if AD_Column_ID exists
//
m_tabs.add(mTab);
}
} // for all tabs
return true;
} // loadTabData
public void initTab(int index)
{
GridTab mTab = m_tabs.get(index);
if (mTab.isLoadComplete()) return;
mTab.initTab(false);
// Set Link Column
if (mTab.getLinkColumnName().length() == 0)
{
ArrayList parents = mTab.getParentColumnNames();
// No Parent - no link
if (parents.size() == 0)
;
// Standard case
else if (parents.size() == 1)
mTab.setLinkColumnName((String)parents.get(0));
else
{
// More than one parent.
// Search prior tabs for the "right parent"
// for all previous tabs
for (int i = 0; i < m_tabs.size(); i++)
{
// we have a tab
GridTab tab = (GridTab)m_tabs.get(i);
String tabKey = tab.getKeyColumnName(); // may be ""
// look, if one of our parents is the key of that tab
for (int j = 0; j < parents.size(); j++)
{
String parent = (String)parents.get(j);
if (parent.equals(tabKey))
{
mTab.setLinkColumnName(parent);
break;
}
// The tab could have more than one key, look into their parents
if (tabKey.equals(""))
for (int k = 0; k < tab.getParentColumnNames().size(); k++)
if (parent.equals(tab.getParentColumnNames().get(k)))
{
mTab.setLinkColumnName(parent);
break;
}
} // for all parents
} // for all previous tabs
} // parents.size > 1
} // set Link column
mTab.setLinkColumnName(null); // overwrites, if AD_Column_ID exists
//
}
/**
* Get Window Icon
* @return Icon for Window
@ -369,6 +378,7 @@ public class GridWindow implements Serializable
if (getHelp().length() != 0)
center.addElement(new p().addElement(getHelp()));
center.addElement(new a().setName("Tabs").addElement(new h3("Tabs").addAttribute("ALIGN", "left")));
// Links to Tabs
int size = getTabCount();
p p = new p();
@ -376,7 +386,8 @@ public class GridWindow implements Serializable
{
GridTab tab = getTab(i);
if (i > 0)
p.addElement(" - ");
p.addElement(" | ");
//p.addElement(" - ");
p.addElement(new a("#Tab"+i).addElement(tab.getName()));
}
center.addElement(p)
@ -386,11 +397,19 @@ public class GridWindow implements Serializable
for (int i = 0; i < size; i++)
{
table table = new table("1", "5", "5", "100%", null);
table.setBorder("1px").setCellSpacing(0);
GridTab tab = getTab(i);
table tabHeader = new table();
tabHeader.setBorder("0").setCellPadding(0).setCellSpacing(0);
tabHeader.addElement(new tr()
.addElement(new td().addElement(new a().setName("Tab" + i)
.addElement(new h2(Msg.getMsg(Env.getCtx(), "Tab") + ": " + tab.getName()))))
.addElement(new td().addElement(WebDoc.NBSP).addElement(WebDoc.NBSP))
.addElement(new a("#Tabs").addElement("..").addAttribute("title", "Up one level")));
tr tr = new tr()
.addElement(new th()
.addElement(new a().setName("Tab" + i)
.addElement(new h2(Msg.getMsg(Env.getCtx(), "Tab") + ": " + tab.getName()))));
.addElement(tabHeader));
if (tab.getDescription().length() != 0)
tr.addElement(new th()
.addElement(new i(tab.getDescription())));
@ -404,6 +423,9 @@ public class GridWindow implements Serializable
td.addElement(new p().addElement(tab.getHelp()));
// Links to Fields
p = new p();
p.addElement(new a().setName("Fields"+i).addElement(new h4("Fields").addAttribute("ALIGN", "left")));
if (!tab.isLoadComplete())
this.initTab(i);
for (int j = 0; j < tab.getFieldCount(); j++)
{
GridField field = tab.getField(j);
@ -411,7 +433,8 @@ public class GridWindow implements Serializable
if (hdr != null && hdr.length() > 0)
{
if (j > 0)
p.addElement(" - ");
p.addElement(" | ");
//p.addElement(" - ");
p.addElement(new a("#Field" + i + j, hdr));
}
}
@ -425,10 +448,16 @@ public class GridWindow implements Serializable
String hdr = field.getHeader();
if (hdr != null && hdr.length() > 0)
{
td = new td().setColSpan(2)
.addElement(new a().setName("Field" + i + j)
.addElement(new h3(Msg.getMsg(Env.getCtx(), "Field") + ": " + hdr))
);
table fieldHeader = new table();
fieldHeader.setBorder("0").setCellPadding(0).setCellSpacing(0);
fieldHeader.addElement(new tr()
.addElement(new td().addElement(new a().setName("Field" + i + j)
.addElement(new h3(Msg.getMsg(Env.getCtx(), "Field") + ": " + hdr)))
.addElement(new td().addElement(WebDoc.NBSP).addElement(WebDoc.NBSP))
.addElement(new strong().addElement(new a("#Fields"+i).addElement("..").addAttribute("title", "Up one level")))));
td = new td().setColSpan(2).addElement(fieldHeader);
if (field.getDescription().length() != 0)
td.addElement(new i(field.getDescription()));
//