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.

This commit is contained in:
Heng Sin Low 2012-10-10 07:28:48 +08:00
parent 89b02ce27d
commit 3354e6d4b1
8 changed files with 53 additions and 22 deletions

View File

@ -3223,4 +3223,8 @@ public class GridTab implements DataStatusListener, Evaluatee, Serializable
return col; return col;
} }
public boolean isNew() {
return isOpen() && getCurrentRow() >= 0 && getCurrentRow() == m_mTable.getNewRow();
}
} // GridTab } // GridTab

View File

@ -147,6 +147,8 @@ DataStatusListener, IADTabpanel
private Component detailPane; private Component detailPane;
public static final String ON_TOGGLE_EVENT = "onToggle";
public ADTabpanel() public ADTabpanel()
{ {
init(); init();
@ -777,7 +779,7 @@ DataStatusListener, IADTabpanel
{ {
if (event.getTarget() == listPanel.getListbox()) 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()) { else if (event.getTarget() == treePanel.getTree()) {
Treeitem item = treePanel.getTree().getSelectedItem(); Treeitem item = treePanel.getTree().getSelectedItem();

View File

@ -106,7 +106,6 @@ public class ADWindowContent extends AbstractADWindowContent
toolbar.setParent(div); toolbar.setParent(div);
toolbar.setWindowNo(getWindowNo()); toolbar.setWindowNo(getWindowNo());
breadCrumb = new BreadCrumb(getWindowNo()); breadCrumb = new BreadCrumb(getWindowNo());
breadCrumb.setStyle("background-color: #e9e9e9");
breadCrumb.setToolbarListener(this); breadCrumb.setToolbarListener(this);
div.appendChild(breadCrumb); div.appendChild(breadCrumb);

View File

@ -918,7 +918,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
*/ */
public void onEvent(Event event) public void onEvent(Event event)
{ {
if ("onSelectionChanged".equals(event.getName())) if (CompositeADTabbox.ON_SELECTION_CHANGED_EVENT.equals(event.getName()))
{ {
Object eventData = event.getData(); Object eventData = event.getData();
@ -928,14 +928,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
int newTabIndex = (Integer)indexes[1]; int newTabIndex = (Integer)indexes[1];
final int originalTabIndex = adTabbox.getSelectedIndex(); final int originalTabIndex = adTabbox.getSelectedIndex();
final int originalTabRow = adTabbox.getSelectedGridTab().getCurrentRow();
setActiveTab(newTabIndex, new Callback<Boolean>() { setActiveTab(newTabIndex, new Callback<Boolean>() {
@Override @Override
public void onCallback(Boolean result) { public void onCallback(Boolean result) {
if (result) if (result)
{ {
//force sync model adTabbox.setDetailpaneSelection(originalTabIndex, originalTabRow);
adTabbox.refresh();
} }
else else
{ {
@ -1548,6 +1548,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
public void onIgnore() public void onIgnore()
{ {
IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel(); IADTabpanel dirtyTabpanel = adTabbox.getDirtyADTabpanel();
boolean newrecod = adTabbox.getSelectedGridTab().isNew();
if (dirtyTabpanel != null && dirtyTabpanel.getGridTab().isSortTab()) if (dirtyTabpanel != null && dirtyTabpanel.getGridTab().isSortTab())
{ {
dirtyTabpanel.refresh(); dirtyTabpanel.refresh();
@ -1556,11 +1557,14 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
else else
{ {
adTabbox.dataIgnore(); adTabbox.dataIgnore();
if (dirtyTabpanel != null) { toolbar.enableIgnore(false);
if (newrecod) {
onRefresh(true);
} else if (dirtyTabpanel != null) {
dirtyTabpanel.getGridTab().dataRefresh(true); // update statusbar & toolbar dirtyTabpanel.getGridTab().dataRefresh(true); // update statusbar & toolbar
dirtyTabpanel.dynamicDisplay(0); dirtyTabpanel.dynamicDisplay(0);
} }
toolbar.enableIgnore(false);
} }
if (dirtyTabpanel != null) if (dirtyTabpanel != null)
focusToTabpanel(dirtyTabpanel); focusToTabpanel(dirtyTabpanel);
@ -1583,7 +1587,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
breadCrumb.setStatusLine(statusLine); breadCrumb.setStatusLine(statusLine);
} }
if (dirtyTabpanel != null) { if (dirtyTabpanel != null) {
onDetailRecord(); if (dirtyTabpanel == adTabbox.getSelectedDetailADTabpanel())
onDetailRecord();
focusToTabpanel(dirtyTabpanel); focusToTabpanel(dirtyTabpanel);
} else { } else {
focusToActivePanel(); focusToActivePanel();

View File

@ -53,13 +53,11 @@ import org.zkoss.zul.Vlayout;
*/ */
public class CompositeADTabbox extends AbstractADTabbox 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_SWITCH_VIEW_EVENT = "onSwitchView";
private static final String ON_ACTIVATE_EVENT = "onActivate"; 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"; 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<Event>() { tabPanel.addEventListener(ADTabpanel.ON_TOGGLE_EVENT, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
@ -471,8 +469,8 @@ public class CompositeADTabbox extends AbstractADTabbox
return null; return null;
} }
public void refresh() { // public void refresh() {
} // }
class SyncDataStatusListener implements DataStatusListener { class SyncDataStatusListener implements DataStatusListener {
@ -643,4 +641,23 @@ public class CompositeADTabbox extends AbstractADTabbox
public void updateDetailPaneToolbar(boolean changed, boolean readOnly) { public void updateDetailPaneToolbar(boolean changed, boolean readOnly) {
detailPane.updateToolbar(changed, 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;
}
}
}
}
} }

View File

@ -91,10 +91,7 @@ public class DetailPane extends Panel implements EventListener<Event> {
tabbox.addEventListener(Events.ON_SELECT, new EventListener<Event>() { tabbox.addEventListener(Events.ON_SELECT, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
int index = tabbox.getSelectedIndex(); fireActivateDetailEvent();
IADTabpanel tabPanel = (IADTabpanel) tabbox.getTabpanel(index).getChildren().get(1);
Event activateEvent = new Event(ON_ACTIVATE_DETAIL_EVENT, tabPanel, prevSelectedIndex);
Events.sendEvent(activateEvent);
} }
}); });
tabbox.setStyle(TABBOX_STYLE); tabbox.setStyle(TABBOX_STYLE);
@ -411,4 +408,11 @@ public class DetailPane extends Panel implements EventListener<Event> {
Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this); Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this);
eventListener.onEvent(openEvent); 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);
}
} }

View File

@ -123,8 +123,6 @@ public interface IADTabbox extends UIPart {
public boolean dataSave(boolean onSaveEvent); public boolean dataSave(boolean onSaveEvent);
public void refresh();
public void setDetailPaneStatusMessage(String status, boolean error); public void setDetailPaneStatusMessage(String status, boolean error);
IADTabpanel getSelectedDetailADTabpanel(); IADTabpanel getSelectedDetailADTabpanel();
@ -132,4 +130,6 @@ public interface IADTabbox extends UIPart {
IADTabpanel getDirtyADTabpanel(); IADTabpanel getDirtyADTabpanel();
public void updateDetailPaneToolbar(boolean changed, boolean readOnly); public void updateDetailPaneToolbar(boolean changed, boolean readOnly);
public void setDetailpaneSelection(int tabIndex, int currentRow);
} }

View File

@ -472,7 +472,7 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
.adwindow-breadcrumb { .adwindow-breadcrumb {
height: 30px; height: 30px;
background-color: transparent; background-color: #EEEEEE;
padding-left: 2px; padding-left: 2px;
} }