IDEMPIERE-369 Master Detail layout improvements. 1) Fixed selected tab in detailpane is wrong when navigate to parent tab that is more than 1 level up. 2) Fixed changes in sort tab not auto save when user navigate to another tab. 3) Fixed double click on sort tab doesn't maximized it.

This commit is contained in:
Heng Sin Low 2012-10-20 00:11:18 +08:00
parent 1214a9a6c6
commit b3d3d04a51
6 changed files with 61 additions and 31 deletions

View File

@ -139,6 +139,7 @@ public class ADSortTab extends Panel implements IADTabpanel
private boolean uiCreated; private boolean uiCreated;
private boolean active = false; private boolean active = false;
private boolean isChanged; private boolean isChanged;
private boolean detailPaneMode;
/** /**
* Dynamic Init * Dynamic Init
@ -698,15 +699,6 @@ public class ADSortTab extends Panel implements IADTabpanel
} }
} // saveData } // saveData
/* (non-Javadoc)
* @see org.compiere.grid.APanelTab#unregisterPanel()
*/
public void unregisterPanel ()
{
saveData();
adWindowPanel = null;
} // dispose
/** /**
* List Item * List Item
* @author Teo Sarca * @author Teo Sarca
@ -929,12 +921,32 @@ public class ADSortTab extends Panel implements IADTabpanel
@Override @Override
public void setDetailPaneMode(boolean detailMode, boolean vflex) { public void setDetailPaneMode(boolean detailMode, boolean vflex) {
this.detailPaneMode = detailMode;
this.setVflex(Boolean.toString(vflex)); this.setVflex(Boolean.toString(vflex));
} }
public boolean isDetailPaneMode() {
return this.detailPaneMode;
}
@Override @Override
public GridView getGridView() { public GridView getGridView() {
return null; 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 } //ADSortTab

View File

@ -159,6 +159,8 @@ DataStatusListener, IADTabpanel
private Component detailPane; private Component detailPane;
private boolean detailPaneMode;
public static final String ON_TOGGLE_EVENT = "onToggle"; public static final String ON_TOGGLE_EVENT = "onToggle";
public ADTabpanel() public ADTabpanel()
@ -1187,6 +1189,7 @@ DataStatusListener, IADTabpanel
@Override @Override
public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) {
this.detailPaneMode = detailPaneMode;
if (detailPaneMode) { if (detailPaneMode) {
detailPane = null; detailPane = null;
this.setVflex("true"); this.setVflex("true");
@ -1216,5 +1219,20 @@ DataStatusListener, IADTabpanel
} }
return buttonList; 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;
}
} }

View File

@ -1627,10 +1627,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
if (dirtyTabpanel != null && dirtyTabpanel instanceof ADSortTab) if (dirtyTabpanel != null && dirtyTabpanel instanceof ADSortTab)
{ {
ADSortTab sortTab = (ADSortTab) dirtyTabpanel; ADSortTab sortTab = (ADSortTab) dirtyTabpanel;
if (onNavigationEvent) sortTab.saveData();
sortTab.unregisterPanel();
else
sortTab.saveData();
if (!onNavigationEvent) if (!onNavigationEvent)
{ {
toolbar.enableSave(sortTab.isChanged()); // set explicitly toolbar.enableSave(sortTab.isChanged()); // set explicitly

View File

@ -230,7 +230,7 @@ public class CompositeADTabbox extends AbstractADTabbox
int oldIndex = (Integer) event.getData(); int oldIndex = (Integer) event.getData();
if (oldIndex != detailPane.getSelectedIndex()) { if (oldIndex != detailPane.getSelectedIndex()) {
IADTabpanel prevTabPanel = detailPane.getADTabpanel(oldIndex); 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(); final int newIndex = detailPane.getSelectedIndex();
detailPane.setSelectedIndex(oldIndex); detailPane.setSelectedIndex(oldIndex);
adWindowPanel.saveAndNavigate(new Callback<Boolean>() { adWindowPanel.saveAndNavigate(new Callback<Boolean>() {
@ -243,6 +243,7 @@ public class CompositeADTabbox extends AbstractADTabbox
} }
}); });
} else { } else {
detailPane.setSelectedIndex(detailPane.getSelectedIndex());
onActivateDetail(tabPanel); onActivateDetail(tabPanel);
} }
} else { } else {
@ -571,13 +572,13 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override @Override
public boolean needSave(boolean rowChange, boolean onlyRealChange) { public boolean needSave(boolean rowChange, boolean onlyRealChange) {
boolean b = headerTab.getGridTab().needSave(rowChange, onlyRealChange); boolean b = headerTab.needSave(rowChange, onlyRealChange);
if (b) if (b)
return b; return b;
IADTabpanel detailPanel = getSelectedDetailADTabpanel(); IADTabpanel detailPanel = getSelectedDetailADTabpanel();
if (detailPanel != null) { if (detailPanel != null) {
b = detailPanel.getGridTab().needSave(rowChange, onlyRealChange); b = detailPanel.needSave(rowChange, onlyRealChange);
} }
return b; return b;
@ -601,14 +602,14 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override @Override
public boolean dataSave(boolean onSaveEvent) { public boolean dataSave(boolean onSaveEvent) {
IADTabpanel detail = getSelectedDetailADTabpanel(); 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(); Execution execution = Executions.getCurrent();
if (execution != null) { if (execution != null) {
execution.setAttribute(getClass().getName()+".dataAction", detail.getUuid()); 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 @Override
@ -619,13 +620,9 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override @Override
public IADTabpanel getDirtyADTabpanel() { public IADTabpanel getDirtyADTabpanel() {
IADTabpanel detail = getSelectedDetailADTabpanel(); IADTabpanel detail = getSelectedDetailADTabpanel();
if (detail != null && detail.getGridTab().needSave(true, true)) { if (detail != null && detail.needSave(true, true)) {
return detail; return detail;
} else if (detail != null && detail instanceof ADSortTab && ((ADSortTab)detail).isChanged()) { } else if (headerTab.needSave(true, true)) {
return detail;
} else if (headerTab.getGridTab().needSave(true, true)) {
return headerTab;
} else if (headerTab instanceof ADSortTab && ((ADSortTab)headerTab).isChanged()) {
return headerTab; return headerTab;
} }
@ -678,7 +675,7 @@ public class CompositeADTabbox extends AbstractADTabbox
IADTabpanel adtab = detailPane.getADTabpanel(i); IADTabpanel adtab = detailPane.getADTabpanel(i);
int index = (Integer) adtab.getAttribute(ADTAB_INDEX_ATTRIBUTE); int index = (Integer) adtab.getAttribute(ADTAB_INDEX_ATTRIBUTE);
if (index == tabIndex) { if (index == tabIndex) {
if (!detailPane.isTabVisible(i)) { if (!detailPane.isTabVisible(i) || !detailPane.isTabEnabled(i)) {
return; return;
} }
if (i != detailPane.getSelectedIndex()) { if (i != detailPane.getSelectedIndex()) {

View File

@ -151,15 +151,14 @@ public class DetailPane extends Panel implements EventListener<Event> {
if (!tab.isSelected()) if (!tab.isSelected())
return; return;
org.zkoss.zul.Tabpanel zkTabpanel = tab.getLinkedPanel(); org.zkoss.zul.Tabpanel zkTabpanel = tab.getLinkedPanel();
ADTabpanel adtab = null; IADTabpanel adtab = null;
for(Component c : zkTabpanel.getChildren()) { for(Component c : zkTabpanel.getChildren()) {
if (c instanceof ADTabpanel) { if (c instanceof IADTabpanel) {
adtab = (ADTabpanel) c; adtab = (IADTabpanel) c;
break; break;
} }
} }
if (adtab != null && adtab.getGridView() != null if (adtab != null && adtab.isDetailPaneMode()) {
&& adtab.getGridView().isDetailPaneMode()) {
onEdit(); onEdit();
} }
} }

View File

@ -120,6 +120,12 @@ public interface IADTabpanel extends Component, Evaluatee {
public boolean isActive(); public boolean isActive();
public void setDetailPaneMode(boolean detailMode, boolean vflex); public void setDetailPaneMode(boolean detailMode, boolean vflex);
public boolean isDetailPaneMode();
public abstract GridView getGridView(); public abstract GridView getGridView();
public boolean needSave(boolean rowChange, boolean onlyRealChange);
public boolean dataSave(boolean onSaveEvent);
} }