Fixed a NPE for included tab reported from field testing.

This commit is contained in:
Heng Sin Low 2008-12-17 07:49:50 +00:00
parent 3aaae7d448
commit d5ab7a2341
1 changed files with 36 additions and 20 deletions

View File

@ -243,7 +243,7 @@ DataStatusListener, IADTabpanel
col.setWidth("2%"); col.setWidth("2%");
columns.appendChild(col); columns.appendChild(col);
Rows rows = new Rows(); Rows rows = grid.newRows();
GridField fields[] = gridTab.getFields(); GridField fields[] = gridTab.getFields();
org.zkoss.zul.Row row = new Row(); org.zkoss.zul.Row row = new Row();
@ -292,6 +292,14 @@ DataStatusListener, IADTabpanel
rows.appendChild(row); rows.appendChild(row);
includedTabFooter.put(field.getIncluded_Tab_ID(), (Groupfoot)row); includedTabFooter.put(field.getIncluded_Tab_ID(), (Groupfoot)row);
for (EmbeddedPanel ep : includedPanel) {
if (ep.adTabId == field.getIncluded_Tab_ID()) {
ep.group = includedTab.get(ep.adTabId);
createEmbeddedPanelUI(ep);
break;
}
}
row = new Row(); row = new Row();
continue; continue;
} }
@ -465,7 +473,6 @@ DataStatusListener, IADTabpanel
if (rowList != null) if (rowList != null)
rowList.add(row); rowList.add(row);
} }
grid.appendChild(rows);
//create tree //create tree
if (gridTab.isTreeTab() && tree != null) { if (gridTab.isTreeTab() && tree != null) {
@ -899,36 +906,29 @@ DataStatusListener, IADTabpanel
EmbeddedPanel ep = new EmbeddedPanel(); EmbeddedPanel ep = new EmbeddedPanel();
ep.tabPanel = tabPanel; ep.tabPanel = tabPanel;
ep.adTabId = adTabId; ep.adTabId = adTabId;
ep.tabIndex = tabIndex;
ep.gridWindow = gridWindow;
includedPanel.add(ep); includedPanel.add(ep);
Group group = includedTab.get(adTabId); Group group = includedTab.get(adTabId);
ep.group = group;
if (tabPanel instanceof ADTabpanel) { if (tabPanel instanceof ADTabpanel) {
ADTabpanel atp = (ADTabpanel) tabPanel; ADTabpanel atp = (ADTabpanel) tabPanel;
atp.listPanel.setPageSize(-1); atp.listPanel.setPageSize(-1);
} }
if (group != null) {
ADWindowPanel panel = new ADWindowPanel(ctx, windowNo, gridWindow, tabIndex, tabPanel); ADWindowPanel panel = new ADWindowPanel(ctx, windowNo, gridWindow, tabIndex, tabPanel);
ep.windowPanel = panel; ep.windowPanel = panel;
org.zkoss.zul.Row row = new Row();
row.setSpans("5");
grid.getRows().insertBefore(row, includedTabFooter.get(adTabId));
panel.createPart(row);
panel.getComponent().setWidth("100%"); if (group != null) {
panel.getComponent().setStyle("position: relative"); createEmbeddedPanelUI(ep);
panel.getComponent().setHeight("400px");
Label title = new Label(gridWindow.getTab(tabIndex).getName());
group.appendChild(title);
group.appendChild(panel.getToolbar());
panel.getStatusBar().setZclass("z-group-foot");
panel.initPanel(-1, null);
if (active) if (active)
activateChild(true, ep); activateChild(true, ep);
} }
} }
class EmbeddedPanel { class EmbeddedPanel {
Group group;
GridWindow gridWindow;
int tabIndex;
ADWindowPanel windowPanel; ADWindowPanel windowPanel;
IADTabpanel tabPanel; IADTabpanel tabPanel;
int adTabId; int adTabId;
@ -943,5 +943,21 @@ DataStatusListener, IADTabpanel
panel.tabPanel.query(false, 0, 0); panel.tabPanel.query(false, 0, 0);
} }
} }
private void createEmbeddedPanelUI(EmbeddedPanel ep) {
org.zkoss.zul.Row row = new Row();
row.setSpans("5");
grid.getRows().insertBefore(row, includedTabFooter.get(ep.adTabId));
ep.windowPanel.createPart(row);
ep.windowPanel.getComponent().setWidth("100%");
ep.windowPanel.getComponent().setStyle("position: relative");
ep.windowPanel.getComponent().setHeight("400px");
Label title = new Label(ep.gridWindow.getTab(ep.tabIndex).getName());
ep.group.appendChild(title);
ep.group.appendChild(ep.windowPanel.getToolbar());
ep.windowPanel.getStatusBar().setZclass("z-group-foot");
ep.windowPanel.initPanel(-1, null);
}
} }