diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java index f5f69a7a88..a7e8f62084 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADSortTab.java @@ -139,6 +139,7 @@ public class ADSortTab extends Panel implements IADTabpanel private boolean uiCreated; private boolean active = false; private boolean isChanged; + private boolean detailPaneMode; /** * Dynamic Init @@ -698,15 +699,6 @@ public class ADSortTab extends Panel implements IADTabpanel } } // saveData - /* (non-Javadoc) - * @see org.compiere.grid.APanelTab#unregisterPanel() - */ - public void unregisterPanel () - { - saveData(); - adWindowPanel = null; - } // dispose - /** * List Item * @author Teo Sarca @@ -929,12 +921,32 @@ public class ADSortTab extends Panel implements IADTabpanel @Override public void setDetailPaneMode(boolean detailMode, boolean vflex) { + this.detailPaneMode = detailMode; this.setVflex(Boolean.toString(vflex)); } + + public boolean isDetailPaneMode() { + return this.detailPaneMode; + } @Override public GridView getGridView() { return null; } + + @Override + public boolean needSave(boolean rowChange, boolean onlyRealChange) { + return isChanged(); + } + + @Override + public boolean dataSave(boolean onSaveEvent) { + if (isChanged()) { + saveData(); + return isChanged() == false; + } else { + return true; + } + } } //ADSortTab 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 420c48cdfb..89eb939ee2 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 @@ -159,6 +159,8 @@ DataStatusListener, IADTabpanel private Component detailPane; + private boolean detailPaneMode; + public static final String ON_TOGGLE_EVENT = "onToggle"; public ADTabpanel() @@ -1187,6 +1189,7 @@ DataStatusListener, IADTabpanel @Override public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { + this.detailPaneMode = detailPaneMode; if (detailPaneMode) { detailPane = null; this.setVflex("true"); @@ -1216,5 +1219,20 @@ DataStatusListener, IADTabpanel } return buttonList; } + + @Override + public boolean needSave(boolean rowChange, boolean onlyRealChange) { + return getGridTab().needSave(rowChange, onlyRealChange); + } + + @Override + public boolean dataSave(boolean onSaveEvent) { + return getGridTab().dataSave(onSaveEvent); + } + + @Override + public boolean isDetailPaneMode() { + return this.detailPaneMode; + } } 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 74c82dc9ea..d1bc076de0 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 @@ -1627,10 +1627,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (dirtyTabpanel != null && dirtyTabpanel instanceof ADSortTab) { ADSortTab sortTab = (ADSortTab) dirtyTabpanel; - if (onNavigationEvent) - sortTab.unregisterPanel(); - else - sortTab.saveData(); + sortTab.saveData(); + if (!onNavigationEvent) { toolbar.enableSave(sortTab.isChanged()); // set explicitly 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 692002cdcb..9d51662cdc 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 @@ -230,7 +230,7 @@ public class CompositeADTabbox extends AbstractADTabbox int oldIndex = (Integer) event.getData(); if (oldIndex != detailPane.getSelectedIndex()) { IADTabpanel prevTabPanel = detailPane.getADTabpanel(oldIndex); - if (prevTabPanel != null && prevTabPanel.getGridTab().needSave(true, true)) { + if (prevTabPanel != null && prevTabPanel.needSave(true, true)) { final int newIndex = detailPane.getSelectedIndex(); detailPane.setSelectedIndex(oldIndex); adWindowPanel.saveAndNavigate(new Callback() { @@ -243,6 +243,7 @@ public class CompositeADTabbox extends AbstractADTabbox } }); } else { + detailPane.setSelectedIndex(detailPane.getSelectedIndex()); onActivateDetail(tabPanel); } } else { @@ -571,13 +572,13 @@ public class CompositeADTabbox extends AbstractADTabbox @Override public boolean needSave(boolean rowChange, boolean onlyRealChange) { - boolean b = headerTab.getGridTab().needSave(rowChange, onlyRealChange); + boolean b = headerTab.needSave(rowChange, onlyRealChange); if (b) return b; IADTabpanel detailPanel = getSelectedDetailADTabpanel(); if (detailPanel != null) { - b = detailPanel.getGridTab().needSave(rowChange, onlyRealChange); + b = detailPanel.needSave(rowChange, onlyRealChange); } return b; @@ -601,14 +602,14 @@ public class CompositeADTabbox extends AbstractADTabbox @Override public boolean dataSave(boolean onSaveEvent) { IADTabpanel detail = getSelectedDetailADTabpanel(); - if (detail != null && !detail.getGridTab().isSortTab() && detail.getGridTab().needSave(true, true)) { + if (detail != null && detail.needSave(true, true)) { Execution execution = Executions.getCurrent(); if (execution != null) { execution.setAttribute(getClass().getName()+".dataAction", detail.getUuid()); } - return detail.getGridTab().dataSave(onSaveEvent); + return detail.dataSave(onSaveEvent); } - return headerTab.getGridTab().isSortTab() ? true : headerTab.getGridTab().dataSave(onSaveEvent); + return headerTab.dataSave(onSaveEvent); } @Override @@ -619,13 +620,9 @@ public class CompositeADTabbox extends AbstractADTabbox @Override public IADTabpanel getDirtyADTabpanel() { IADTabpanel detail = getSelectedDetailADTabpanel(); - if (detail != null && detail.getGridTab().needSave(true, true)) { + if (detail != null && detail.needSave(true, true)) { return detail; - } else if (detail != null && detail instanceof ADSortTab && ((ADSortTab)detail).isChanged()) { - return detail; - } else if (headerTab.getGridTab().needSave(true, true)) { - return headerTab; - } else if (headerTab instanceof ADSortTab && ((ADSortTab)headerTab).isChanged()) { + } else if (headerTab.needSave(true, true)) { return headerTab; } @@ -678,7 +675,7 @@ public class CompositeADTabbox extends AbstractADTabbox IADTabpanel adtab = detailPane.getADTabpanel(i); int index = (Integer) adtab.getAttribute(ADTAB_INDEX_ATTRIBUTE); if (index == tabIndex) { - if (!detailPane.isTabVisible(i)) { + if (!detailPane.isTabVisible(i) || !detailPane.isTabEnabled(i)) { return; } if (i != detailPane.getSelectedIndex()) { 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 8a2a525aa6..dc08b2fefb 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 @@ -151,15 +151,14 @@ public class DetailPane extends Panel implements EventListener { if (!tab.isSelected()) return; org.zkoss.zul.Tabpanel zkTabpanel = tab.getLinkedPanel(); - ADTabpanel adtab = null; + IADTabpanel adtab = null; for(Component c : zkTabpanel.getChildren()) { - if (c instanceof ADTabpanel) { - adtab = (ADTabpanel) c; + if (c instanceof IADTabpanel) { + adtab = (IADTabpanel) c; break; } } - if (adtab != null && adtab.getGridView() != null - && adtab.getGridView().isDetailPaneMode()) { + if (adtab != null && adtab.isDetailPaneMode()) { onEdit(); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java index 75a5a9b76c..3f86cc8ca1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/IADTabpanel.java @@ -120,6 +120,12 @@ public interface IADTabpanel extends Component, Evaluatee { public boolean isActive(); public void setDetailPaneMode(boolean detailMode, boolean vflex); + + public boolean isDetailPaneMode(); public abstract GridView getGridView(); + + public boolean needSave(boolean rowChange, boolean onlyRealChange); + + public boolean dataSave(boolean onSaveEvent); }