From 2952930ab4715cc6b6f38fdc3faf74263678a865 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 1 Aug 2013 23:28:17 +0800 Subject: [PATCH] IDEMPIERE-1230 Detail pane always created for level 1 tab even when there's no child tab. Further optimization and fixed problem with sortTab. --- .../src/org/compiere/model/GridTab.java | 2 +- .../adempiere/webui/adwindow/ADTabpanel.java | 13 ++++-- .../webui/adwindow/CompositeADTabbox.java | 44 ++++++++++++++----- 3 files changed, 43 insertions(+), 16 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index b5f1b4aca6..5b4181ba97 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -2423,7 +2423,7 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable // Table Open? if (!m_mTable.isOpen()) { - log.severe ("Table not open"); + log.log (Level.SEVERE, "Table not open", new Exception("Table not open")); return -1; } // Row Count diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java index b4af00a3d2..a150807ec3 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADTabpanel.java @@ -92,6 +92,7 @@ import org.zkoss.zul.Cell; import org.zkoss.zul.Center; import org.zkoss.zul.DefaultTreeNode; import org.zkoss.zul.Div; +import org.zkoss.zul.RowRenderer; import org.zkoss.zul.Separator; import org.zkoss.zul.South; import org.zkoss.zul.Space; @@ -177,7 +178,7 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer private GridTabDataBinder dataBinder; - private boolean activated = false; + protected boolean activated = false; private Group currentGroup; @@ -1517,9 +1518,15 @@ DataStatusListener, IADTabpanel, IdSpace, IFieldEditorContainer } } else if (tabPanel != null && !tabPanel.getGridTab().isCurrent()) { tabPanel.activate(true); + } else if (tabPanel != null && tabPanel.isGridView()) { + //ensure row indicator is not lost + RowRenderer renderer = tabPanel.getGridView().getListbox().getRowRenderer(); + GridTabRowRenderer gtr = (GridTabRowRenderer)renderer; + org.zkoss.zul.Row row = gtr.getCurrentRow(); + if (row != null) + gtr.setCurrentRow(row); } - } - + } } /** 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 dd2e8e156c..50af43f98f 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 @@ -188,8 +188,10 @@ public class CompositeADTabbox extends AbstractADTabbox if (formView && headerTab.isGridView()) { headerTab.switchRowPresentation(); } - - headerTab.getGridTab().setCurrentRow(row, true); + + if (!headerTab.getGridTab().isSortTab()) + headerTab.getGridTab().setCurrentRow(row, true); + if (headerTab.isGridView()) { if (headerTab.getGridTab().isNew() || headerTab.needSave(true, false)) { headerTab.getGridView().onEditCurrentRow(); @@ -450,8 +452,7 @@ public class CompositeADTabbox extends AbstractADTabbox } private void onPostTabSelectionChanged(Boolean back) { - if (headerTab instanceof ADTabpanel && !headerTab.getGridTab().isSortTab()) { - + if (headerTab instanceof ADTabpanel && !headerTab.getGridTab().isSortTab()) { List list = new ArrayList(); int tabIndex = -1; int currentLevel = headerTab.getTabLevel(); @@ -483,10 +484,9 @@ public class CompositeADTabbox extends AbstractADTabbox if (headerTab.getDetailPane() == null) { 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)); } private void onTabSelectionChangedEcho(Boolean back) { @@ -514,8 +514,22 @@ public class CompositeADTabbox extends AbstractADTabbox tabPanel.setDetailPaneMode(true); detailPane.setADTabpanel(tabIndex, tabPanel, tabLabel, enable.booleanValue()); } - detailPane.setSelectedIndex(0); - activateDetailIfVisible(); + if (back == null || !back.booleanValue()) { + detailPane.setSelectedIndex(0); + activateDetailIfVisible(); + } else { + if (((ADTabpanel) headerTab).isDetailVisible()) { + IADTabpanel selectDetailPanel = detailPane.getSelectedADTabpanel(); + if (!selectDetailPanel.isVisible()) { + selectDetailPanel.setVisible(true); + } + if (!selectDetailPanel.isGridView()) { + selectDetailPanel.switchRowPresentation(); + } + if (selectDetailPanel instanceof ADTabpanel) + ((ADTabpanel)selectDetailPanel).activated = true; + } + } } } } @@ -780,8 +794,9 @@ public class CompositeADTabbox extends AbstractADTabbox } else { tabPanel.query(false, 0, 0); } - if (!tabPanel.isVisible()) + if (!tabPanel.isVisible()) { tabPanel.setVisible(true); + } if (!tabPanel.isGridView()) { tabPanel.switchRowPresentation(); } @@ -791,7 +806,12 @@ public class CompositeADTabbox extends AbstractADTabbox headerTab.getDetailPane().updateToolbar(false, true); } else { tabPanel.dynamicDisplay(0); - } + RowRenderer renderer = tabPanel.getGridView().getListbox().getRowRenderer(); + GridTabRowRenderer gtr = (GridTabRowRenderer)renderer; + Row row = gtr.getCurrentRow(); + if (row != null) + gtr.setCurrentRow(row); + } } private void showLastError() {