IDEMPIERE-1230 Detail pane always created for level 1 tab even when there's no child tab.

This commit is contained in:
Heng Sin Low 2013-08-01 17:18:14 +08:00
parent a4007bf19d
commit 92580221f7
1 changed files with 48 additions and 17 deletions

View File

@ -61,6 +61,8 @@ public class CompositeADTabbox extends AbstractADTabbox
public static final String AD_TABBOX_ON_EDIT_DETAIL_ATTRIBUTE = "ADTabbox.onEditDetail"; public static final String AD_TABBOX_ON_EDIT_DETAIL_ATTRIBUTE = "ADTabbox.onEditDetail";
private static final String ON_POST_TAB_SELECTION_CHANGED_EVENT = "onPostTabSelectionChanged"; private static final String ON_POST_TAB_SELECTION_CHANGED_EVENT = "onPostTabSelectionChanged";
private static final String ON_TAB_SELECTION_CHANGED_ECHO_EVENT = "onTabSelectionChangedEcho";
public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged"; public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged";
@ -215,6 +217,13 @@ public class CompositeADTabbox extends AbstractADTabbox
onPostTabSelectionChanged((Boolean)event.getData()); onPostTabSelectionChanged((Boolean)event.getData());
} }
}); });
layout.addEventListener(ON_TAB_SELECTION_CHANGED_ECHO_EVENT, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
onTabSelectionChangedEcho((Boolean)event.getData());
}
});
BreadCrumb breadCrumb = getBreadCrumb(); BreadCrumb breadCrumb = getBreadCrumb();
breadCrumb.addEventListener(Events.ON_CLICK, new EventListener<Event>() { breadCrumb.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@ -437,16 +446,13 @@ public class CompositeADTabbox extends AbstractADTabbox
headerTab.setDetailPaneMode(false); headerTab.setDetailPaneMode(false);
getBreadCrumb().getFirstChild().setVisible(false); getBreadCrumb().getFirstChild().setVisible(false);
Events.echoEvent(new Event(ON_POST_TAB_SELECTION_CHANGED_EVENT, layout, oldIndex > newIndex)); Events.postEvent(new Event(ON_POST_TAB_SELECTION_CHANGED_EVENT, layout, oldIndex > newIndex));
} }
private void onPostTabSelectionChanged(Boolean back) { private void onPostTabSelectionChanged(Boolean back) {
if (headerTab instanceof ADTabpanel) { if (headerTab instanceof ADTabpanel && !headerTab.getGridTab().isSortTab()) {
DetailPane detailPane = headerTab.getDetailPane();
if (detailPane == null) { List<Object[]> list = new ArrayList<Object[]>();
detailPane = createDetailPane();
}
int tabIndex = -1; int tabIndex = -1;
int currentLevel = headerTab.getTabLevel(); int currentLevel = headerTab.getTabLevel();
for (int i = selectedIndex + 1; i< tabPanelList.size(); i++) { for (int i = selectedIndex + 1; i< tabPanelList.size(); i++) {
@ -459,28 +465,53 @@ public class CompositeADTabbox extends AbstractADTabbox
} }
if (tabPanel.getParent() != null) tabPanel.detach(); if (tabPanel.getParent() != null) tabPanel.detach();
tabIndex++; tabIndex++;
detailPane.setADTabpanel(tabIndex, tabPanel, tabLabel); Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.TRUE};
list.add(value);
tabPanel.setDetailPaneMode(true); tabPanel.setDetailPaneMode(true);
} else if (tabLevel > currentLevel ){ } else if (tabLevel > currentLevel ){
tabIndex++; tabIndex++;
detailPane.setADTabpanel(tabIndex, tabPanel, tabLabel, false); Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.FALSE};
list.add(value);
tabPanel.setDetailPaneMode(true); tabPanel.setDetailPaneMode(true);
} else { } else {
break; break;
} }
} }
if (detailPane.getTabcount() > 0 && !headerTab.getGridTab().isSortTab()) { if (!list.isEmpty()) {
detailPane.setVflex("true"); DetailPane detailPane = headerTab.getDetailPane();
detailPane.setSelectedIndex(0); if (detailPane == null) {
if (headerTab.getDetailPane() == null) { detailPane = createDetailPane();
headerTab.setDetailPane(detailPane); }
} for (Object[] value : 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.setSelectedIndex(0);
if (headerTab.getDetailPane() == null) {
headerTab.setDetailPane(detailPane);
}
}
}
Events.echoEvent(new Event(ON_TAB_SELECTION_CHANGED_ECHO_EVENT, layout, back));
}
}
private void onTabSelectionChangedEcho(Boolean back) {
if (headerTab instanceof ADTabpanel) {
DetailPane detailPane = headerTab.getDetailPane();
if (detailPane != null && detailPane.getTabcount() > 0) {
activateDetailIfVisible(); activateDetailIfVisible();
} }
} }
updateBreadCrumb();
updateBreadCrumb();
getBreadCrumb().getFirstChild().setVisible(true); getBreadCrumb().getFirstChild().setVisible(true);
updateTabState(); updateTabState();