IDEMPIERE-369 Master Detail layout improvements. Fixed click on row indicator not working in header grid view. Single click instead of double click to maximize selected detail tab. Not to auto switch to form view for the detail record icon and the click to maximize selected tab action.

This commit is contained in:
Heng Sin Low 2013-01-02 20:54:49 +08:00
parent 147b55cd26
commit d112a9c316
6 changed files with 69 additions and 49 deletions

View File

@ -246,25 +246,30 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
ctrl = ExecutionsCtrl.getCurrentCtrl(); ctrl = ExecutionsCtrl.getCurrentCtrl();
((DesktopCtrl)Executions.getCurrent().getDesktop()).setVisualizer(vi); ((DesktopCtrl)Executions.getCurrent().getDesktop()).setVisualizer(vi);
//detach root component from old page //detach root component from old page
Page page = appDesktop.getComponent().getPage(); Page page = appDesktop.getComponent().getPage();
Collection<?> collection = page.getRoots(); if (page.getDesktop() != null) {
Object[] objects = new Object[0]; Collection<?> collection = page.getRoots();
objects = collection.toArray(objects); Object[] objects = new Object[0];
for(Object obj : objects) { objects = collection.toArray(objects);
try { for(Object obj : objects) {
if (obj instanceof Component) { try {
((Component)obj).detach(); if (obj instanceof Component) {
rootComponents.add((Component) obj); ((Component)obj).detach();
rootComponents.add((Component) obj);
}
} catch (Exception e) {
e.printStackTrace();
} }
} catch (Exception e) {
// e.printStackTrace();
} }
appDesktop.getComponent().detach();
DesktopCache desktopCache = ((SessionCtrl)currSess).getDesktopCache();
if (desktopCache != null)
desktopCache.removeDesktop(Executions.getCurrent().getDesktop());
} else {
appDesktop = null;
} }
appDesktop.getComponent().detach();
DesktopCache desktopCache = ((SessionCtrl)currSess).getDesktopCache();
if (desktopCache != null)
desktopCache.removeDesktop(Executions.getCurrent().getDesktop());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
appDesktop = null; appDesktop = null;

View File

@ -69,6 +69,7 @@ import org.compiere.util.Msg;
import org.compiere.util.Util; import org.compiere.util.Util;
import org.zkoss.zk.au.out.AuFocus; import org.zkoss.zk.au.out.AuFocus;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent; import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.IdSpace; import org.zkoss.zk.ui.IdSpace;
@ -106,6 +107,8 @@ import org.zkoss.zul.impl.XulElement;
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>, public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel, IdSpace DataStatusListener, IADTabpanel, IdSpace
{ {
public static final String ON_POST_INIT_EVENT = "onPostInit";
public static final String ON_SWITCH_VIEW_EVENT = "onSwitchView"; public static final String ON_SWITCH_VIEW_EVENT = "onSwitchView";
public static final String ON_DYNAMIC_DISPLAY_EVENT = "onDynamicDisplay"; public static final String ON_DYNAMIC_DISPLAY_EVENT = "onDynamicDisplay";
@ -190,7 +193,7 @@ DataStatusListener, IADTabpanel, IdSpace
removeAttribute(ATTR_ON_ACTIVATE_POSTED); removeAttribute(ATTR_ON_ACTIVATE_POSTED);
} }
}); });
addEventListener("onPostInit", this); addEventListener(ON_POST_INIT_EVENT, this);
} }
private void initComponents() private void initComponents()
@ -498,7 +501,10 @@ DataStatusListener, IADTabpanel, IdSpace
//stretch component to fill grid cell //stretch component to fill grid cell
editor.fillHorizontal(); editor.fillHorizontal();
editor.getComponent().setId(field.getColumnName()); Component fellow = editor.getComponent().getFellowIfAny(field.getColumnName());
if (fellow == null) {
editor.getComponent().setId(field.getColumnName());
}
//setup editor context menu //setup editor context menu
WEditorPopupMenu popupMenu = editor.getPopupMenu(); WEditorPopupMenu popupMenu = editor.getPopupMenu();
@ -932,9 +938,14 @@ DataStatusListener, IADTabpanel, IdSpace
else if (WPaymentEditor.ON_SAVE_PAYMENT.equals(event.getName())) { else if (WPaymentEditor.ON_SAVE_PAYMENT.equals(event.getName())) {
windowPanel.onSavePayment(); windowPanel.onSavePayment();
} }
else if ("onPostInit".equals(event.getName())) { else if (ON_POST_INIT_EVENT.equals(event.getName())) {
if (detailPane != null) { if (detailPane != null) {
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane)); Desktop desktop = Executions.getCurrent().getDesktop();
//for unknown reason, this is needed once per desktop to fixed the layout of the detailpane.
if (desktop.getAttribute("adtabpanel.detailpane.postinit.redraw") == null) {
desktop.setAttribute("adtabpanel.detailpane.postinit.redraw", Boolean.TRUE);
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane));
}
} }
} }
} }

View File

@ -586,7 +586,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
private void initFirstTabpanel() { private void initFirstTabpanel() {
adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords()); adTabbox.getSelectedTabpanel().query(m_onlyCurrentRows, m_onlyCurrentDays, MRole.getDefault().getMaxQueryRecords());
adTabbox.getSelectedTabpanel().activate(true); adTabbox.getSelectedTabpanel().activate(true);
Events.echoEvent(new Event("onPostInit", adTabbox.getSelectedTabpanel())); Events.echoEvent(new Event(ADTabpanel.ON_POST_INIT_EVENT, adTabbox.getSelectedTabpanel()));
} }
/** /**

View File

@ -87,11 +87,12 @@ public class CompositeADTabbox extends AbstractADTabbox
final int row = detailPane.getSelectedADTabpanel() != null final int row = detailPane.getSelectedADTabpanel() != null
? detailPane.getSelectedADTabpanel().getGridTab().getCurrentRow() ? detailPane.getSelectedADTabpanel().getGridTab().getCurrentRow()
: 0; : 0;
final boolean formView = event.getData() != null ? (Boolean)event.getData() : true;
adWindowPanel.saveAndNavigate(new Callback<Boolean>() { adWindowPanel.saveAndNavigate(new Callback<Boolean>() {
@Override @Override
public void onCallback(Boolean result) { public void onCallback(Boolean result) {
if (result) if (result)
onEditDetail(row); onEditDetail(row, formView);
} }
}); });
} }
@ -105,7 +106,7 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override @Override
public void onCallback(Boolean result) { public void onCallback(Boolean result) {
if (result) { if (result) {
onEditDetail(row); onEditDetail(row, true);
if (!adWindowPanel.getActiveGridTab().isNew()) if (!adWindowPanel.getActiveGridTab().isNew())
adWindowPanel.onNew(); adWindowPanel.onNew();
} }
@ -136,7 +137,7 @@ public class CompositeADTabbox extends AbstractADTabbox
}); });
} }
protected void onEditDetail(int row) { protected void onEditDetail(int row, boolean formView) {
int oldIndex = selectedIndex; int oldIndex = selectedIndex;
IADTabpanel selectedPanel = detailPane.getSelectedADTabpanel(); IADTabpanel selectedPanel = detailPane.getSelectedADTabpanel();
if (selectedPanel == null) return; if (selectedPanel == null) return;
@ -150,7 +151,7 @@ public class CompositeADTabbox extends AbstractADTabbox
} }
headerTab.setDetailPaneMode(false); headerTab.setDetailPaneMode(false);
if (headerTab.isGridView()) { if (formView && headerTab.isGridView()) {
headerTab.switchRowPresentation(); headerTab.switchRowPresentation();
} }
headerTab.getGridTab().setCurrentRow(row, true); headerTab.getGridTab().setCurrentRow(row, true);
@ -213,9 +214,6 @@ public class CompositeADTabbox extends AbstractADTabbox
if (b != null && b.booleanValue()) { if (b != null && b.booleanValue()) {
activateDetailADTabpanel(); activateDetailADTabpanel();
} }
if (selectedIndex > 0 && tabPanel.isGridView()) {
tabPanel.switchRowPresentation();
}
} else { } else {
onActivateDetail(tabPanel); onActivateDetail(tabPanel);
} }
@ -274,7 +272,7 @@ public class CompositeADTabbox extends AbstractADTabbox
if (tabPanel == headerTab) { if (tabPanel == headerTab) {
adWindowPanel.onToggle(); adWindowPanel.onToggle();
} else { } else {
detailPane.onEdit(); detailPane.onEdit(true);
} }
} }
@ -285,7 +283,7 @@ public class CompositeADTabbox extends AbstractADTabbox
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
GridView gridView = (GridView) event.getTarget(); GridView gridView = (GridView) event.getTarget();
if (gridView.getParent() == headerTab) { if (!gridView.isDetailPaneMode()) {
adWindowPanel.onToggle(); adWindowPanel.onToggle();
} }
} }
@ -549,7 +547,7 @@ public class CompositeADTabbox extends AbstractADTabbox
public void onDetailRecord() { public void onDetailRecord() {
if (detailPane != null && detailPane.getSelectedADTabpanel() != null) { if (detailPane != null && detailPane.getSelectedADTabpanel() != null) {
try { try {
detailPane.onEdit(); detailPane.onEdit(false);
} catch (Exception e) {} } catch (Exception e) {}
} }
} }

View File

@ -46,6 +46,8 @@ import org.zkoss.zul.Toolbar;
*/ */
public class DetailPane extends Panel implements EventListener<Event>, IdSpace { public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
private static final String TABBOX_ONSELECT_ATTRIBUTE = "detailpane.tabbox.onselect";
public static final String ON_POST_SELECT_TAB_EVENT = "onPostSelectTab"; public static final String ON_POST_SELECT_TAB_EVENT = "onPostSelectTab";
private static final String STATUS_TEXT_ATTRIBUTE = "status.text"; private static final String STATUS_TEXT_ATTRIBUTE = "status.text";
@ -95,7 +97,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
fireActivateDetailEvent(); fireActivateDetailEvent();
Events.postEvent(new Event(ON_POST_SELECT_TAB_EVENT, DetailPane.this)); Events.postEvent(new Event(ON_POST_SELECT_TAB_EVENT, DetailPane.this));
Executions.getCurrent().setAttribute(TABBOX_ONSELECT_ATTRIBUTE, Boolean.TRUE);
} }
}); });
tabbox.setSclass("adwindow-detailpane-tabbox"); tabbox.setSclass("adwindow-detailpane-tabbox");
@ -104,10 +107,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
this.setSclass("adwindow-detailpane"); this.setSclass("adwindow-detailpane");
addEventListener(LayoutUtils.ON_REDRAW_EVENT, this); addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);
addEventListener("onPostInit", this);
setId("detailPane"); setId("detailPane");
} }
@ -154,12 +155,16 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
tab.setSclass("adwindow-detailpane-sub-tab"); tab.setSclass("adwindow-detailpane-sub-tab");
} }
tab.addEventListener(Events.ON_DOUBLE_CLICK, new EventListener<Event>() { tab.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
Tab tab = (Tab) event.getTarget(); Tab tab = (Tab) event.getTarget();
if (!tab.isSelected()) if (!tab.isSelected())
return; return;
if (Executions.getCurrent().getAttribute(TABBOX_ONSELECT_ATTRIBUTE) != null)
return;
org.zkoss.zul.Tabpanel zkTabpanel = tab.getLinkedPanel(); org.zkoss.zul.Tabpanel zkTabpanel = tab.getLinkedPanel();
IADTabpanel adtab = null; IADTabpanel adtab = null;
for(Component c : zkTabpanel.getChildren()) { for(Component c : zkTabpanel.getChildren()) {
@ -169,7 +174,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
} }
} }
if (adtab != null && adtab.isDetailPaneMode()) { if (adtab != null && adtab.isDetailPaneMode()) {
onEdit(); onEdit(false);
} }
} }
}); });
@ -207,7 +212,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() { button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
@Override @Override
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
onEdit(); onEdit(true);
} }
}); });
button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord"))); button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord")));
@ -259,7 +264,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
public void onEvent(Event event) throws Exception { public void onEvent(Event event) throws Exception {
GridView gridView = (GridView) event.getTarget(); GridView gridView = (GridView) event.getTarget();
if (gridView.isDetailPaneMode()) if (gridView.isDetailPaneMode())
onEdit(); onEdit(true);
} }
}); });
} }
@ -407,14 +412,7 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
return; return;
} }
LayoutUtils.redraw(this); LayoutUtils.redraw(this);
} else if (event.getName().equals("onPostInit")) { }
IADTabpanel adtabpanel = getSelectedADTabpanel();
if (adtabpanel != null) {
GridView gridView = adtabpanel.getGridView();
if (gridView != null && gridView.getListbox() != null)
Clients.resize(gridView.getListbox());
}
}
} }
protected void createPopupContent(String status) { protected void createPopupContent(String status) {
@ -518,8 +516,8 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
} }
} }
public void onEdit() throws Exception { public void onEdit(boolean formView) throws Exception {
Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this); Event openEvent = new Event(ON_EDIT_EVENT, DetailPane.this, Boolean.valueOf(formView));
eventListener.onEvent(openEvent); eventListener.onEvent(openEvent);
} }

View File

@ -522,6 +522,14 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
overflow-y: visible; overflow-y: visible;
} }
.adwindow-detailpane-tabbox .z-tab-seld span.z-tab-text {
cursor: pointer;
}
.adwindow-detailpane-tabbox .z-tab-seld span.z-tab-text:hover {
text-decoration: underline;
}
.adwindow-detailpane-tabpanel { .adwindow-detailpane-tabpanel {
background-color: #fff background-color: #fff
} }