From 3354e6d4b185d9bc99bfd93dc329816ce2da9aab Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 10 Oct 2012 07:28:48 +0800 Subject: [PATCH] IDEMPIERE-369 Master Detail layout improvements. Fixed navigation from detail to header lost the detail tab's current selected row position. Fixed data ignore for new row doesn't refresh detail pane. --- .../src/org/compiere/model/GridTab.java | 4 +++ .../adempiere/webui/adwindow/ADTabpanel.java | 4 ++- .../webui/adwindow/ADWindowContent.java | 1 - .../adwindow/AbstractADWindowContent.java | 19 +++++++----- .../webui/adwindow/CompositeADTabbox.java | 29 +++++++++++++++---- .../adempiere/webui/adwindow/DetailPane.java | 12 +++++--- .../adempiere/webui/adwindow/IADTabbox.java | 4 +-- .../theme/default/css/theme.css.dsp | 2 +- 8 files changed, 53 insertions(+), 22 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/GridTab.java b/org.adempiere.base/src/org/compiere/model/GridTab.java index 47d2b210c5..07720180c1 100644 --- a/org.adempiere.base/src/org/compiere/model/GridTab.java +++ b/org.adempiere.base/src/org/compiere/model/GridTab.java @@ -3223,4 +3223,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable return col; } + + public boolean isNew() { + return isOpen() && getCurrentRow() >= 0 && getCurrentRow() == m_mTable.getNewRow(); + } } // GridTab 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 74a2a6ffbb..a09b781e9c 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 @@ -147,6 +147,8 @@ DataStatusListener, IADTabpanel private Component detailPane; + public static final String ON_TOGGLE_EVENT = "onToggle"; + public ADTabpanel() { init(); @@ -777,7 +779,7 @@ DataStatusListener, IADTabpanel { if (event.getTarget() == listPanel.getListbox()) { - Events.sendEvent(this, new Event("onToggle", this)); + Events.sendEvent(this, new Event(ON_TOGGLE_EVENT, this)); } else if (event.getTarget() == treePanel.getTree()) { Treeitem item = treePanel.getTree().getSelectedItem(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java index 5a2bdd6162..29a0b287bc 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowContent.java @@ -106,7 +106,6 @@ public class ADWindowContent extends AbstractADWindowContent toolbar.setParent(div); toolbar.setWindowNo(getWindowNo()); breadCrumb = new BreadCrumb(getWindowNo()); - breadCrumb.setStyle("background-color: #e9e9e9"); breadCrumb.setToolbarListener(this); div.appendChild(breadCrumb); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 4bb95fe57c..3e0c6b6a54 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -918,7 +918,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements */ public void onEvent(Event event) { - if ("onSelectionChanged".equals(event.getName())) + if (CompositeADTabbox.ON_SELECTION_CHANGED_EVENT.equals(event.getName())) { Object eventData = event.getData(); @@ -928,14 +928,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements int newTabIndex = (Integer)indexes[1]; final int originalTabIndex = adTabbox.getSelectedIndex(); + final int originalTabRow = adTabbox.getSelectedGridTab().getCurrentRow(); setActiveTab(newTabIndex, new Callback() { @Override public void onCallback(Boolean result) { if (result) { - //force sync model - adTabbox.refresh(); + adTabbox.setDetailpaneSelection(originalTabIndex, originalTabRow); } else { @@ -1548,6 +1548,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements public void onIgnore() { IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel(); + boolean newrecod = adTabbox.getSelectedGridTab().isNew(); if (dirtyTabpanel != null && dirtyTabpanel.getGridTab().isSortTab()) { dirtyTabpanel.refresh(); @@ -1556,11 +1557,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements else { adTabbox.dataIgnore(); - if (dirtyTabpanel != null) { + toolbar.enableIgnore(false); + if (newrecod) { + onRefresh(true); + } else if (dirtyTabpanel != null) { dirtyTabpanel.getGridTab().dataRefresh(true); // update statusbar & toolbar dirtyTabpanel.dynamicDisplay(0); - } - toolbar.enableIgnore(false); + } + } if (dirtyTabpanel != null) focusToTabpanel(dirtyTabpanel); @@ -1583,7 +1587,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements breadCrumb.setStatusLine(statusLine); } if (dirtyTabpanel != null) { - onDetailRecord(); + if (dirtyTabpanel == adTabbox.getSelectedDetailADTabpanel()) + onDetailRecord(); focusToTabpanel(dirtyTabpanel); } else { focusToActivePanel(); 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 69e260c55f..a6d6d25003 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 @@ -53,13 +53,11 @@ import org.zkoss.zul.Vlayout; */ public class CompositeADTabbox extends AbstractADTabbox { - private static final String ON_TOGGLE_EVENT = "onToggle"; - private static final String ON_SWITCH_VIEW_EVENT = "onSwitchView"; private static final String ON_ACTIVATE_EVENT = "onActivate"; - private static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged"; + public static final String ON_SELECTION_CHANGED_EVENT = "onSelectionChanged"; public static final String ADTAB_INDEX_ATTRIBUTE = "adtab.index"; @@ -265,7 +263,7 @@ public class CompositeADTabbox extends AbstractADTabbox } }); - tabPanel.addEventListener(ON_TOGGLE_EVENT, new EventListener() { + tabPanel.addEventListener(ADTabpanel.ON_TOGGLE_EVENT, new EventListener() { @Override public void onEvent(Event event) throws Exception { @@ -471,8 +469,8 @@ public class CompositeADTabbox extends AbstractADTabbox return null; } - public void refresh() { - } +// public void refresh() { +// } class SyncDataStatusListener implements DataStatusListener { @@ -643,4 +641,23 @@ public class CompositeADTabbox extends AbstractADTabbox public void updateDetailPaneToolbar(boolean changed, boolean readOnly) { detailPane.updateToolbar(changed, readOnly); } + + @Override + public void setDetailpaneSelection(int tabIndex, int currentRow) { + if (detailPane.getTabcount() > 0) { + for(int i = 0; i < detailPane.getTabcount(); i++) { + IADTabpanel adtab = detailPane.getADTabpanel(i); + int index = (Integer) adtab.getAttribute(ADTAB_INDEX_ATTRIBUTE); + if (index == tabIndex) { + if (i != detailPane.getSelectedIndex()) { + detailPane.setSelectedIndex(i); + detailPane.fireActivateDetailEvent(); + } + if (adtab.getGridTab().getCurrentRow() != currentRow) + adtab.getGridTab().setCurrentRow(currentRow, true); + break; + } + } + } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java index 56553a1180..78f75a49ff 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/DetailPane.java @@ -91,10 +91,7 @@ public class DetailPane extends Panel implements EventListener { tabbox.addEventListener(Events.ON_SELECT, new EventListener() { @Override public void onEvent(Event event) throws Exception { - int index = tabbox.getSelectedIndex(); - IADTabpanel tabPanel = (IADTabpanel) tabbox.getTabpanel(index).getChildren().get(1); - Event activateEvent = new Event(ON_ACTIVATE_DETAIL_EVENT, tabPanel, prevSelectedIndex); - Events.sendEvent(activateEvent); + fireActivateDetailEvent(); } }); tabbox.setStyle(TABBOX_STYLE); @@ -411,4 +408,11 @@ public class DetailPane extends Panel implements EventListener { Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this); eventListener.onEvent(openEvent); } + + public void fireActivateDetailEvent() { + int index = tabbox.getSelectedIndex(); + IADTabpanel tabPanel = (IADTabpanel) tabbox.getTabpanel(index).getChildren().get(1); + Event activateEvent = new Event(ON_ACTIVATE_DETAIL_EVENT, tabPanel, prevSelectedIndex); + Events.sendEvent(activateEvent); + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java index 71c938432f..524bec5609 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabbox.java @@ -123,8 +123,6 @@ public interface IADTabbox extends UIPart { public boolean dataSave(boolean onSaveEvent); - public void refresh(); - public void setDetailPaneStatusMessage(String status, boolean error); IADTabpanel getSelectedDetailADTabpanel(); @@ -132,4 +130,6 @@ public interface IADTabbox extends UIPart { IADTabpanel getDirtyADTabpanel(); public void updateDetailPaneToolbar(boolean changed, boolean readOnly); + + public void setDetailpaneSelection(int tabIndex, int currentRow); } diff --git a/org.adempiere.ui.zk/theme/default/css/theme.css.dsp b/org.adempiere.ui.zk/theme/default/css/theme.css.dsp index 8ff2cccb79..87e78c0615 100644 --- a/org.adempiere.ui.zk/theme/default/css/theme.css.dsp +++ b/org.adempiere.ui.zk/theme/default/css/theme.css.dsp @@ -472,7 +472,7 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { .adwindow-breadcrumb { height: 30px; - background-color: transparent; + background-color: #EEEEEE; padding-left: 2px; }