IDEMPIERE-1230 Detail pane always created for level 1 tab even when there's no child tab. Further optimization and fixed a event ordering bug in my previous revision for this ticket.

This commit is contained in:
Heng Sin Low 2013-08-01 21:47:30 +08:00
parent 92580221f7
commit e32e543324
1 changed files with 32 additions and 24 deletions

View File

@ -446,7 +446,7 @@ public class CompositeADTabbox extends AbstractADTabbox
headerTab.setDetailPaneMode(false); headerTab.setDetailPaneMode(false);
getBreadCrumb().getFirstChild().setVisible(false); getBreadCrumb().getFirstChild().setVisible(false);
Events.postEvent(new Event(ON_POST_TAB_SELECTION_CHANGED_EVENT, layout, oldIndex > newIndex)); Events.sendEvent(new Event(ON_POST_TAB_SELECTION_CHANGED_EVENT, layout, oldIndex > newIndex));
} }
private void onPostTabSelectionChanged(Boolean back) { private void onPostTabSelectionChanged(Boolean back) {
@ -460,19 +460,13 @@ public class CompositeADTabbox extends AbstractADTabbox
int tabLevel = tabPanel.getTabLevel(); int tabLevel = tabPanel.getTabLevel();
ADTabListModel.ADTabLabel tabLabel = tabLabelList.get(i); ADTabListModel.ADTabLabel tabLabel = tabLabelList.get(i);
if ((tabLevel - currentLevel) == 1 || (tabLevel == 0 && currentLevel == 0)) { if ((tabLevel - currentLevel) == 1 || (tabLevel == 0 && currentLevel == 0)) {
if (tabPanel.isActivated() && !tabPanel.isGridView()) {
tabPanel.switchRowPresentation();
}
if (tabPanel.getParent() != null) tabPanel.detach();
tabIndex++; tabIndex++;
Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.TRUE}; Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.TRUE};
list.add(value); list.add(value);
tabPanel.setDetailPaneMode(true);
} else if (tabLevel > currentLevel ){ } else if (tabLevel > currentLevel ){
tabIndex++; tabIndex++;
Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.FALSE}; Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.FALSE};
list.add(value); list.add(value);
tabPanel.setDetailPaneMode(true);
} else { } else {
break; break;
} }
@ -483,21 +477,13 @@ public class CompositeADTabbox extends AbstractADTabbox
if (detailPane == null) { if (detailPane == null) {
detailPane = createDetailPane(); detailPane = createDetailPane();
} }
for (Object[] value : list) { detailPane.setAttribute("detailpane.tablist", list);
Boolean b = (Boolean) value[3];
if (b.booleanValue())
detailPane.setADTabpanel((Integer)value[0], (IADTabpanel)value[1], (ADTabLabel)value[2]);
else
detailPane.setADTabpanel((Integer)value[0], (IADTabpanel)value[1], (ADTabLabel)value[2], false);
}
if (detailPane.getTabcount() > 0) {
detailPane.setVflex("true"); detailPane.setVflex("true");
detailPane.setSelectedIndex(0);
if (headerTab.getDetailPane() == null) { if (headerTab.getDetailPane() == null) {
headerTab.setDetailPane(detailPane); headerTab.setDetailPane(detailPane);
} }
} }
}
Events.echoEvent(new Event(ON_TAB_SELECTION_CHANGED_ECHO_EVENT, layout, back)); Events.echoEvent(new Event(ON_TAB_SELECTION_CHANGED_ECHO_EVENT, layout, back));
} }
@ -507,10 +493,32 @@ public class CompositeADTabbox extends AbstractADTabbox
if (headerTab instanceof ADTabpanel) { if (headerTab instanceof ADTabpanel) {
DetailPane detailPane = headerTab.getDetailPane(); DetailPane detailPane = headerTab.getDetailPane();
if (detailPane != null && detailPane.getTabcount() > 0) { if (detailPane != null) {
@SuppressWarnings("unchecked")
List<Object[]> list = (List<Object[]>) detailPane.removeAttribute("detailpane.tablist");
if (list != null && !list.isEmpty()) {
int currentLevel = headerTab.getTabLevel();
for (Object[] value : list) {
int tabIndex = (Integer) value[0];
IADTabpanel tabPanel = (IADTabpanel) value[1];
ADTabLabel tabLabel = (ADTabLabel) value[2] ;
Boolean enable = (Boolean) value[3];
int tabLevel = tabPanel.getTabLevel();
if ((tabLevel - currentLevel) == 1 || (tabLevel == 0 && currentLevel == 0)) {
if (tabPanel.isActivated() && !tabPanel.isGridView()) {
tabPanel.switchRowPresentation();
}
if (tabPanel.getParent() != null) tabPanel.detach();
}
tabPanel.setDetailPaneMode(true);
detailPane.setADTabpanel(tabIndex, tabPanel, tabLabel, enable.booleanValue());
}
detailPane.setSelectedIndex(0);
activateDetailIfVisible(); activateDetailIfVisible();
} }
} }
}
updateBreadCrumb(); updateBreadCrumb();
getBreadCrumb().getFirstChild().setVisible(true); getBreadCrumb().getFirstChild().setVisible(true);