From 92580221f7c78bb46c5dd3853077fa44bb076a9a Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 1 Aug 2013 17:18:14 +0800 Subject: [PATCH] IDEMPIERE-1230 Detail pane always created for level 1 tab even when there's no child tab. --- .../webui/adwindow/CompositeADTabbox.java | 65 ++++++++++++++----- 1 file changed, 48 insertions(+), 17 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java index 2bcab4e55a..47afa7c239 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/CompositeADTabbox.java @@ -61,6 +61,8 @@ public class CompositeADTabbox extends AbstractADTabbox 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_TAB_SELECTION_CHANGED_ECHO_EVENT = "onTabSelectionChangedEcho"; public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged"; @@ -215,6 +217,13 @@ public class CompositeADTabbox extends AbstractADTabbox onPostTabSelectionChanged((Boolean)event.getData()); } }); + + layout.addEventListener(ON_TAB_SELECTION_CHANGED_ECHO_EVENT, new EventListener() { + @Override + public void onEvent(Event event) throws Exception { + onTabSelectionChangedEcho((Boolean)event.getData()); + } + }); BreadCrumb breadCrumb = getBreadCrumb(); breadCrumb.addEventListener(Events.ON_CLICK, new EventListener() { @@ -437,16 +446,13 @@ public class CompositeADTabbox extends AbstractADTabbox headerTab.setDetailPaneMode(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) { - if (headerTab instanceof ADTabpanel) { - DetailPane detailPane = headerTab.getDetailPane(); - if (detailPane == null) { - detailPane = createDetailPane(); - } - + if (headerTab instanceof ADTabpanel && !headerTab.getGridTab().isSortTab()) { + + List list = new ArrayList(); int tabIndex = -1; int currentLevel = headerTab.getTabLevel(); for (int i = selectedIndex + 1; i< tabPanelList.size(); i++) { @@ -459,28 +465,53 @@ public class CompositeADTabbox extends AbstractADTabbox } if (tabPanel.getParent() != null) tabPanel.detach(); tabIndex++; - detailPane.setADTabpanel(tabIndex, tabPanel, tabLabel); + Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.TRUE}; + list.add(value); tabPanel.setDetailPaneMode(true); } else if (tabLevel > currentLevel ){ tabIndex++; - detailPane.setADTabpanel(tabIndex, tabPanel, tabLabel, false); + Object[] value = new Object[]{tabIndex, tabPanel, tabLabel, Boolean.FALSE}; + list.add(value); tabPanel.setDetailPaneMode(true); } else { break; } } - if (detailPane.getTabcount() > 0 && !headerTab.getGridTab().isSortTab()) { - detailPane.setVflex("true"); - detailPane.setSelectedIndex(0); - if (headerTab.getDetailPane() == null) { - headerTab.setDetailPane(detailPane); - } + if (!list.isEmpty()) { + DetailPane detailPane = headerTab.getDetailPane(); + if (detailPane == null) { + detailPane = createDetailPane(); + } + 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(); } } - - updateBreadCrumb(); + updateBreadCrumb(); getBreadCrumb().getFirstChild().setVisible(true); updateTabState();