From b323eb142406d3ebd4d7d5b0c700f70efe2f3f3a Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 24 Dec 2012 16:19:35 +0800 Subject: [PATCH] IDEMPIERE-369 Master Detail layout improvements. Performance optimization. Drop non split view support for form view. --- .../adempiere/webui/adwindow/ADSortTab.java | 4 +- .../adempiere/webui/adwindow/ADTabpanel.java | 156 ++++++++---------- .../webui/adwindow/CompositeADTabbox.java | 51 ++---- .../adempiere/webui/adwindow/DetailPane.java | 6 - .../webui/adwindow/GridTabRowRenderer.java | 59 +++---- .../adempiere/webui/adwindow/GridView.java | 112 +++---------- .../adempiere/webui/adwindow/IADTabpanel.java | 2 +- .../theme/default/css/theme.css.dsp | 10 +- 8 files changed, 141 insertions(+), 259 deletions(-) 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 962b5091fa..2977f7ce57 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 @@ -936,9 +936,9 @@ public class ADSortTab extends Panel implements IADTabpanel } @Override - public void setDetailPaneMode(boolean detailMode, boolean vflex) { + public void setDetailPaneMode(boolean detailMode) { this.detailPaneMode = detailMode; - this.setVflex(Boolean.toString(vflex)); + this.setVflex("true"); } public boolean isDetailPaneMode() { 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 a3c30d007b..b916f6f658 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 @@ -54,7 +54,6 @@ import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.model.GridWindow; import org.compiere.model.MLookup; -import org.compiere.model.MSysConfig; import org.compiere.model.MToolBarButton; import org.compiere.model.MToolBarButtonRestrict; import org.compiere.model.MTree; @@ -70,6 +69,7 @@ import org.compiere.util.Util; import org.zkoss.zk.au.out.AuFocus; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; +import org.zkoss.zk.ui.HtmlBasedComponent; import org.zkoss.zk.ui.IdSpace; import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; @@ -209,41 +209,29 @@ DataStatusListener, IADTabpanel, IdSpace } public void addDetails(Component component) { - if (formContainer.isVisible()) { - detailPane = component; - if (formContainer instanceof Borderlayout) { - if (isUseSplitViewForForm()) { - Borderlayout borderLayout = (Borderlayout) formContainer; - borderLayout.appendSouth(detailPane); - - borderLayout.getSouth().setCollapsible(true); - borderLayout.getSouth().setSplittable(true); - borderLayout.getSouth().setOpen(true); - borderLayout.getSouth().setSclass("adwindow-gridview-detail"); - } else { - form.getParent().appendChild(detailPane); - } - } else { - formContainer.appendChild(component); - } - } else { - listPanel.addDetails(component); - } + detailPane = component; + if (formContainer instanceof Borderlayout) { + Borderlayout borderLayout = (Borderlayout) formContainer; + borderLayout.appendSouth(detailPane); + + borderLayout.getSouth().setCollapsible(true); + borderLayout.getSouth().setSplittable(true); + borderLayout.getSouth().setOpen(true); + borderLayout.getSouth().setSclass("adwindow-gridview-detail"); + } else { + formContainer.appendChild(component); + } } public Component removeDetails() { Component details = null; - if (listPanel.isVisible()) { - details = listPanel.removeDetails(); - } else { - if (detailPane != null) { - if (detailPane.getParent() != null) { - details = detailPane; - detailPane.detach(); - } - detailPane = null; - } - } + if (detailPane != null) { + if (detailPane.getParent() != null) { + details = detailPane; + detailPane.detach(); + } + detailPane = null; + } return details; } @@ -308,6 +296,7 @@ DataStatusListener, IADTabpanel, IdSpace div.setVflex("1"); div.setHflex("1"); div.setSclass("adtab-form"); + div.setStyle("overflow-y: visible;"); layout.appendChild(center); formContainer = layout; @@ -319,49 +308,41 @@ DataStatusListener, IADTabpanel, IdSpace Vlayout div = new Vlayout(); div.setSclass("adtab-form"); div.appendChild(form); + div.setStyle("overflow-y: visible;"); div.setVflex("1"); div.setWidth("100%"); - if (isUseSplitViewForForm()) { - StringBuilder cssContent = new StringBuilder(); - cssContent.append(".adtab-form-borderlayout .z-south-colpsd:before { "); - cssContent.append("content: \""); - cssContent.append(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Detail"))); - cssContent.append("\"; "); - cssContent.append("position: relative; font-size: 12px; font-weight: bold; "); - cssContent.append("top: 3px; "); - cssContent.append("left: 4px; "); - cssContent.append("z-index: -1; "); - cssContent.append("} "); - Style style = new Style(); - style.setContent(cssContent.toString()); - appendChild(style); - - Borderlayout layout = new Borderlayout(); - layout.setParent(this); - layout.setSclass("adtab-form-borderlayout"); - - Center center = new Center(); - layout.appendChild(center); - center.appendChild(div); - formContainer = layout; - } else { - this.appendChild(div); - formContainer = div; - } + StringBuilder cssContent = new StringBuilder(); + cssContent.append(".adtab-form-borderlayout .z-south-colpsd:before { "); + cssContent.append("content: \""); + cssContent.append(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Detail"))); + cssContent.append("\"; "); + cssContent.append("position: relative; font-size: 12px; font-weight: bold; "); + cssContent.append("top: 3px; "); + cssContent.append("left: 4px; "); + cssContent.append("z-index: -1; "); + cssContent.append("} "); + Style style = new Style(); + style.setContent(cssContent.toString()); + appendChild(style); + Borderlayout layout = new Borderlayout(); + layout.setParent(this); + layout.setSclass("adtab-form-borderlayout"); + + Center center = new Center(); + layout.appendChild(center); + center.appendChild(div); + formContainer = layout; } - this.appendChild(listPanel); + + form.getParent().appendChild(listPanel); listPanel.setVisible(false); listPanel.setWindowNo(windowNo); listPanel.setADWindowPanel(winPanel); } - public static boolean isUseSplitViewForForm() { - return MSysConfig.getBooleanValue("ZK_AD_WINDOW_FORM_SPLITVIEW", true); - } - /** * Create UI components if not already created */ @@ -642,8 +623,10 @@ DataStatusListener, IADTabpanel, IdSpace GridField changedField = gridTab.getField(col); String columnName = changedField.getColumnName(); ArrayList dependants = gridTab.getDependantFields(columnName); - logger.config("(" + gridTab.toString() + ") " - + columnName + " - Dependents=" + dependants.size()); + if (logger.isLoggable(Level.CONFIG)) { + logger.config("(" + gridTab.toString() + ") " + + columnName + " - Dependents=" + dependants.size()); + } if (dependants.size() == 0 && changedField.getCallout().length() > 0) { return; @@ -651,7 +634,9 @@ DataStatusListener, IADTabpanel, IdSpace } boolean noData = gridTab.getRowCount() == 0; - logger.config(gridTab.toString() + " - Rows=" + gridTab.getRowCount()); + if (logger.isLoggable(Level.CONFIG)) { + logger.config(gridTab.toString() + " - Rows=" + gridTab.getRowCount()); + } for (WEditor comp : editors) { GridField mField = comp.getGridField(); @@ -758,7 +743,9 @@ DataStatusListener, IADTabpanel, IdSpace } Events.sendEvent(this, new Event(ON_DYNAMIC_DISPLAY_EVENT, this)); - logger.config(gridTab.toString() + " - fini - " + (col<=0 ? "complete" : "seletive")); + if (logger.isLoggable(Level.CONFIG)) { + logger.config(gridTab.toString() + " - fini - " + (col<=0 ? "complete" : "seletive")); + } } // dynamicDisplay /** @@ -978,7 +965,7 @@ DataStatusListener, IADTabpanel, IdSpace } if (row == -1) { - if (nodeID > 0) + if (nodeID > 0 && logger.isLoggable(Level.WARNING)) logger.log(Level.WARNING, "Tab does not have ID with Node_ID=" + nodeID); return; } @@ -997,7 +984,9 @@ DataStatusListener, IADTabpanel, IdSpace if (Executions.getCurrent() == null) return; int col = e.getChangedColumn(); - logger.config("(" + gridTab + ") Col=" + col + ": " + e.toString()); + if (logger.isLoggable(Level.CONFIG)) { + logger.config("(" + gridTab + ") Col=" + col + ": " + e.toString()); + } // Process Callout GridField mField = gridTab.getField(col); @@ -1129,14 +1118,14 @@ DataStatusListener, IADTabpanel, IdSpace * Toggle between form and grid view */ public void switchRowPresentation() { - Component details = removeDetails(); - if (formContainer.isVisible()) { - formContainer.setVisible(false); + if (form.isVisible()) { + form.setVisible(false); + ((HtmlBasedComponent)form.getParent()).setStyle(""); } else { - formContainer.setVisible(true); - formContainer.getParent().invalidate(); + form.setVisible(true); + ((HtmlBasedComponent)form.getParent()).setStyle("overflow-y: visible;"); } - listPanel.setVisible(!formContainer.isVisible()); + listPanel.setVisible(!form.isVisible()); if (listPanel.isVisible()) { listPanel.refresh(gridTab); listPanel.scrollToCurrentRow(); @@ -1144,9 +1133,6 @@ DataStatusListener, IADTabpanel, IdSpace listPanel.deactivate(); } - if (details != null) - addDetails(details); - Events.sendEvent(this, new Event(ON_SWITCH_VIEW_EVENT, this)); } @@ -1229,15 +1215,13 @@ DataStatusListener, IADTabpanel, IdSpace } @Override - public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { + public void setDetailPaneMode(boolean detailPaneMode) { this.detailPaneMode = detailPaneMode; if (detailPaneMode) { - detailPane = null; - this.setVflex("true"); - } else { - this.setVflex(Boolean.toString(vflex)); - } - listPanel.setDetailPaneMode(detailPaneMode, vflex); + detailPane = null; + } + this.setVflex("true"); + listPanel.setDetailPaneMode(detailPaneMode); } /** 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 6b3fab1bc9..2128e3b569 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 @@ -23,7 +23,6 @@ import java.util.LinkedHashMap; import java.util.List; import org.adempiere.util.Callback; -import org.adempiere.webui.LayoutUtils; import org.adempiere.webui.component.ADTabListModel; import org.adempiere.webui.component.ADTabListModel.ADTabLabel; import org.adempiere.webui.window.FDialog; @@ -134,17 +133,7 @@ public class CompositeADTabbox extends AbstractADTabbox } } } - }); - - detailPane.addEventListener(DetailPane.ON_POST_SELECT_TAB_EVENT, new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - if ((!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView())) { - LayoutUtils.redraw(detailPane); - Clients.scrollIntoView(detailPane.getSelectedADTabpanel()); - } - } - }); + }); } protected void onEditDetail(int row) { @@ -160,7 +149,7 @@ public class CompositeADTabbox extends AbstractADTabbox throw new RuntimeException(e); } - headerTab.setDetailPaneMode(false, true); + headerTab.setDetailPaneMode(false); if (headerTab.isGridView()) { headerTab.switchRowPresentation(); } @@ -270,10 +259,9 @@ public class CompositeADTabbox extends AbstractADTabbox if (tabPanel == headerTab) { IADTabpanel detailPanel = getSelectedDetailADTabpanel(); if (detailPanel != null) { - detailPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); + detailPanel.setDetailPaneMode(true); } - detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); - layout.invalidate(); + detailPane.setVflex("true"); } } }); @@ -316,12 +304,12 @@ public class CompositeADTabbox extends AbstractADTabbox tabPanel.setVisible(false); detailPane.setHflex("1"); detailPane.addADTabpanel(tabPanel, tabLabel); - tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); - detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); + tabPanel.setDetailPaneMode(true); + detailPane.setVflex("true"); } else { detailPane.addADTabpanel(tabPanel, tabLabel, false); - tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); - detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); + tabPanel.setDetailPaneMode(true); + detailPane.setVflex("true"); } HtmlBasedComponent htmlComponent = (HtmlBasedComponent) tabPanel; htmlComponent.setVflex("1"); @@ -413,10 +401,10 @@ public class CompositeADTabbox extends AbstractADTabbox } if (tabPanel.getParent() != null) tabPanel.detach(); detailPane.addADTabpanel(tabPanel, tabLabel); - tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); + tabPanel.setDetailPaneMode(true); } else if (tabLevel > currentLevel ){ detailPane.addADTabpanel(tabPanel, tabLabel, false); - tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); + tabPanel.setDetailPaneMode(true); } else { break; } @@ -425,12 +413,12 @@ public class CompositeADTabbox extends AbstractADTabbox if (detailPane.getTabcount() > 0 && !headerTab.getGridTab().isSortTab()) { ADTabpanel adtabpanel = (ADTabpanel) headerTab; adtabpanel.addDetails(detailPane); - detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); + detailPane.setVflex("true"); detailPane.setSelectedIndex(0); activateDetailADTabpanel(); } - headerTab.setDetailPaneMode(false, true); + headerTab.setDetailPaneMode(false); updateBreadCrumb(); } @@ -550,11 +538,8 @@ public class CompositeADTabbox extends AbstractADTabbox Env.setContext(Env.getCtx(), field.getWindowNo(), field.getColumnName(), ""); } detailTab.activate(true); - detailTab.setDetailPaneMode(true, isUseVflexForDetailPane()); - detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); - if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) { - Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane)); - } + detailTab.setDetailPaneMode(true); + detailPane.setVflex("true"); } } @@ -649,8 +634,8 @@ public class CompositeADTabbox extends AbstractADTabbox if (!tabPanel.isGridView()) { tabPanel.switchRowPresentation(); } - tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); - detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); + tabPanel.setDetailPaneMode(true); + detailPane.setVflex("true"); if (tabPanel instanceof ADSortTab) { detailPane.updateToolbar(false, true); } else { @@ -667,10 +652,6 @@ public class CompositeADTabbox extends AbstractADTabbox //other error will be catch in the dataStatusChanged event } - private boolean isUseVflexForDetailPane() { - return headerTab.isGridView() || ADTabpanel.isUseSplitViewForForm(); - } - @Override public void updateDetailPaneToolbar(boolean changed, boolean readOnly) { if (headerTab.getGridTab().isNew() || headerTab.getGridTab().getRowCount() == 0) 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 648f76ea00..f8fd0642ba 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 @@ -99,16 +99,10 @@ public class DetailPane extends Panel implements EventListener, IdSpace { } }); tabbox.setSclass("adwindow-detailpane-tabbox"); - if (!ADTabpanel.isUseSplitViewForForm()) { - LayoutUtils.addSclass("adwindow-detailpane-tabbox-xsplit", tabbox); - } createPopup(); this.setSclass("adwindow-detailpane"); - if (!ADTabpanel.isUseSplitViewForForm()) { - LayoutUtils.addSclass("adwindow-detailpane-xsplit", this); - } addEventListener(LayoutUtils.ON_REDRAW_EVENT, this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java index c597c7590a..9aed78b301 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridTabRowRenderer.java @@ -45,16 +45,14 @@ import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; import org.zkoss.zul.Cell; -import org.zkoss.zul.Div; import org.zkoss.zul.Grid; +import org.zkoss.zul.Label; import org.zkoss.zul.Paging; import org.zkoss.zul.RendererCtrl; import org.zkoss.zul.Row; import org.zkoss.zul.RowRenderer; import org.zkoss.zul.RowRendererExt; import org.zkoss.zul.impl.XulElement; -import org.zkoss.zhtml.Label; -import org.zkoss.zhtml.Text; /** * Row renderer for GridTab grid. @@ -64,8 +62,12 @@ import org.zkoss.zhtml.Text; *
  • BF [ 2996608 ] GridPanel is not displaying time * https://sourceforge.net/tracker/?func=detail&aid=2996608&group_id=176962&atid=955896 */ -public class GridTabRowRenderer implements RowRenderer, RowRendererExt, RendererCtrl { +public class GridTabRowRenderer implements RowRenderer, RowRendererExt, RendererCtrl, EventListener { + private static final String CELL_DIV_STYLE = "border: none; height: 100%; cursor: pointer; "; + private static final String CELL_DIV_STYLE_ALIGN_CENTER = CELL_DIV_STYLE + "text-align:center; "; + private static final String CELL_DIV_STYLE_ALIGN_RIGHT = CELL_DIV_STYLE + "text-align:right; "; + private static final int MAX_TEXT_LENGTH = 60; private GridTab gridTab; private int windowNo; @@ -211,11 +213,9 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt // since 5.0.8, the org.zkoss.zhtml.Text is encoded by default // if (display != null) // display = XMLs.encodeText(display); - label.appendChild(new Text(display)); + label.setValue(display); if (text != null && text.length() > MAX_TEXT_LENGTH) - label.setDynamicProperty("title", text); - else - label.setDynamicProperty("title", ""); + label.setTooltiptext(text); } /** @@ -251,11 +251,11 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt for (Entry entry : editors.entrySet()) { if (entry.getValue().getComponent().getParent() != null) { Component child = entry.getValue().getComponent(); - Div div = null; + Cell div = null; while (div == null && child != null) { Component parent = child.getParent(); - if (parent instanceof Div && parent.getParent() instanceof Row) - div = (Div)parent; + if (parent instanceof Cell && parent.getParent() instanceof Row) + div = (Cell)parent; else child = parent; } @@ -355,16 +355,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt Cell cell = new Cell(); cell.setWidth("10px"); - cell.addEventListener(Events.ON_CLICK, new EventListener() { - @Override - public void onEvent(Event event) throws Exception { - Cell cell = (Cell) event.getTarget(); - if (cell.getSclass() != null && cell.getSclass().indexOf("row-indicator-seld") >= 0) - Events.sendEvent(gridPanel, new Event(DetailPane.ON_EDIT_EVENT, gridPanel)); - else - Events.sendEvent(event.getTarget().getParent(), event); - } - }); + cell.addEventListener(Events.ON_CLICK, this); cell.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord"))); //TODO: checkbox for selection and batch action ( delete, export, complete, etc ) @@ -391,8 +382,8 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt } colIndex ++; - Div div = new Div(); - String divStyle = "border: none; height: 100%; cursor: pointer;"; + Cell div = new Cell(); + String divStyle = CELL_DIV_STYLE; org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex); if (column.isVisible()) { Component component = getDisplayComponent(rowIndex, currentValues[i], gridPanelFields[i]); @@ -400,10 +391,10 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt div.setAttribute("display.component", component); if (DisplayType.YesNo == gridPanelFields[i].getDisplayType() || DisplayType.Image == gridPanelFields[i].getDisplayType()) { - divStyle += "text-align:center; "; + divStyle = CELL_DIV_STYLE_ALIGN_CENTER; } else if (DisplayType.isNumeric(gridPanelFields[i].getDisplayType())) { - divStyle += "text-align:right; "; + divStyle = CELL_DIV_STYLE_ALIGN_RIGHT; } } div.setStyle(divStyle); @@ -412,14 +403,15 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt div.setAttribute("columnName", gridPanelFields[i].getColumnName()); div.addEventListener(Events.ON_CLICK, rowListener); div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener); - row.addEventListener(Events.ON_CLICK, rowListener); - row.setStyle("cursor:pointer"); + row.addEventListener(Events.ON_CLICK, rowListener); row.appendChild(div); } if (rowIndex == gridTab.getCurrentRow()) { setCurrentRow(row); } + + row.setStyle("cursor:pointer"); row.addEventListener(Events.ON_OK, rowListener); } @@ -490,7 +482,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex); if (column.isVisible()) { - Div div = (Div) currentRow.getChildren().get(colIndex); + Cell div = (Cell) currentRow.getChildren().get(colIndex); div.getChildren().clear(); WEditor editor = getEditorCell(gridPanelFields[i]); div.appendChild(editor.getComponent()); @@ -663,4 +655,15 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt } }; } + + @Override + public void onEvent(Event event) throws Exception { + if (event.getTarget() instanceof Cell) { + Cell cell = (Cell) event.getTarget(); + if (cell.getSclass() != null && cell.getSclass().indexOf("row-indicator-seld") >= 0) + Events.sendEvent(gridPanel, new Event(DetailPane.ON_EDIT_EVENT, gridPanel)); + else + Events.sendEvent(event.getTarget().getParent(), event); + } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java index ff4b14f831..32d2b2910f 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/GridView.java @@ -23,7 +23,6 @@ import javax.swing.table.AbstractTableModel; import org.adempiere.model.MTabCustomization; import org.adempiere.webui.apps.AEnv; -import org.adempiere.webui.component.Borderlayout; import org.adempiere.webui.component.Columns; import org.adempiere.webui.component.EditorBox; import org.adempiere.webui.component.Grid; @@ -47,14 +46,11 @@ import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.util.Clients; -import org.zkoss.zul.Center; import org.zkoss.zul.Column; import org.zkoss.zul.Div; import org.zkoss.zul.Frozen; -import org.zkoss.zul.North; import org.zkoss.zul.Paging; import org.zkoss.zul.Row; -import org.zkoss.zul.Style; import org.zkoss.zul.Vbox; import org.zkoss.zul.event.ZulEvents; @@ -65,9 +61,11 @@ import org.zkoss.zul.event.ZulEvents; */ public class GridView extends Vbox implements EventListener, IdSpace { + private static final String HEADER_GRID_STYLE = "border: none; margin:0; padding: 0;"; + private static final int DEFAULT_DETAIL_PAGE_SIZE = 10; - private static final int DEFAULT_PAGE_SIZE = 50; + private static final int DEFAULT_PAGE_SIZE = 20; /** * generated serial version ID @@ -115,10 +113,6 @@ public class GridView extends Vbox implements EventListener, IdSpace private Map columnWidthMap; - private Component detail; - - private Borderlayout borderLayout; - private boolean detailPaneMode; public GridView() @@ -141,87 +135,48 @@ public class GridView extends Vbox implements EventListener, IdSpace gridFooter.setHflex("1"); gridFooter.setVflex("0"); - StringBuilder cssContent = new StringBuilder(); - cssContent.append(".adwindow-gridview-borderlayout .z-south-colpsd:before { "); - cssContent.append("content: \""); - cssContent.append(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Detail"))); - cssContent.append("\"; "); - cssContent.append("position: relative; font-size: 12px; font-weight: bold; "); - cssContent.append("top: 3px; "); - cssContent.append("left: 4px; "); - cssContent.append("z-index: -1; "); - cssContent.append("} "); - Style style = new Style(); - style.setContent(cssContent.toString()); - appendChild(style); - - borderLayout = new Borderlayout(); - borderLayout.setSclass("adwindow-gridview-borderlayout"); - appendChild(borderLayout); - Center center = new Center(); - borderLayout.appendChild(center); - North north = new North(); - north.setVflex("min"); - borderLayout.appendChild(north); - - borderLayout.appendCenter(listbox); - borderLayout.appendNorth(gridFooter); - //default paging size if (AEnv.isTablet()) { //anything more than 20 is very slow on a tablet - pageSize = 20; + pageSize = 10; } else { - pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 50); + pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, DEFAULT_PAGE_SIZE); } //default true for better UI experience modeless = MSysConfig.getBooleanValue(MSysConfig.ZK_GRID_EDIT_MODELESS, true); + appendChild(listbox); + appendChild(gridFooter); + this.setVflex("true"); + + setStyle(HEADER_GRID_STYLE); + gridFooter.setStyle(HEADER_GRID_STYLE); + setSpacing("2px"); } protected void createListbox() { listbox = new Grid(); listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "FindZeroRecords"))); - listbox.addEventListener(ZulEvents.ON_AFTER_RENDER, this); listbox.setSizedByContent(true); listbox.setVflex("1"); listbox.setHflex("1"); listbox.setSclass("adtab-grid"); } - public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { + public void setDetailPaneMode(boolean detailPaneMode) { this.detailPaneMode = detailPaneMode; - if (detailPaneMode) { - pageSize = DEFAULT_DETAIL_PAGE_SIZE; - updatePaging(); - if (borderLayout.getParent() != null) { - listbox.detach(); - gridFooter.detach(); - borderLayout.detach(); - appendChild(listbox); - appendChild(gridFooter); - } - //false work for header form, true work for header grid - listbox.setVflex(vflex); - listbox.setSclass(""); - this.setVflex(Boolean.toString(vflex)); + pageSize = detailPaneMode ? DEFAULT_DETAIL_PAGE_SIZE : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20); + updatePaging(); + if (detailPaneMode) { + setStyle(""); + gridFooter.setStyle(""); } else { - pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 50); - updatePaging(); - if (borderLayout.getParent() == null) { - listbox.detach(); - gridFooter.detach(); - appendChild(borderLayout); - borderLayout.appendCenter(listbox); - borderLayout.appendNorth(gridFooter); - } - listbox.setVflex("true"); - listbox.setSclass("adtab-grid"); - this.setVflex("true"); + setStyle(HEADER_GRID_STYLE); + gridFooter.setStyle(HEADER_GRID_STYLE); } } @@ -361,7 +316,6 @@ public class GridView extends Vbox implements EventListener, IdSpace paging.setTotalSize(gridTab.getRowCount()); if (paging.getPageCount() > 1 && !gridFooter.isVisible()) { gridFooter.setVisible(true); - borderLayout.invalidate(); } int pgIndex = rowIndex >= 0 ? rowIndex % pageSize : 0; int pgNo = rowIndex >= 0 ? (rowIndex - pgIndex) / pageSize : 0; @@ -608,11 +562,6 @@ public class GridView extends Vbox implements EventListener, IdSpace onSelectedRowChange(0); } } - else if (event.getName().equals(ZulEvents.ON_AFTER_RENDER)) - { - //render all rows of active page to give smooth scrolling performance - listbox.renderAll(); - } } private void onSelectedRowChange(int index) { @@ -889,25 +838,4 @@ public class GridView extends Vbox implements EventListener, IdSpace public GridField[] getFields() { return gridField; } - - public void addDetails(Component component) { - detail = component; - borderLayout.appendSouth(detail); - borderLayout.getSouth().setCollapsible(true); - borderLayout.getSouth().setSplittable(true); - borderLayout.getSouth().setOpen(true); - borderLayout.getSouth().setSclass("adwindow-gridview-detail"); - } - - public Component removeDetails() { - Component details = null; - if (detail != null) { - if (detail.getParent() != null) { - detail.detach(); - details = detail; - } - detail = null; - } - return details; - } } 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 226c621fc5..cc2242bf16 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 @@ -122,7 +122,7 @@ public interface IADTabpanel extends Component, Evaluatee { public boolean isActive(); - public void setDetailPaneMode(boolean detailMode, boolean vflex); + public void setDetailPaneMode(boolean detailMode); public boolean isDetailPaneMode(); 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 2a5b27e39a..0e7adaf6e8 100644 --- a/org.adempiere.ui.zk/theme/default/css/theme.css.dsp +++ b/org.adempiere.ui.zk/theme/default/css/theme.css.dsp @@ -510,10 +510,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { overflow-y: visible; } -.adwindow-detailpane-xsplit { - min-height: 200px; -} - .adwindow-detailpane-tabpanel { background-color: #fff } @@ -541,10 +537,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { background-color: #E4E4E4; } -.adwindow-detailpane-tabbox-xsplit .z-tabpanel { - min-height: 200px; -} - .adwindow-gridview-detail { height: 200px; } @@ -573,7 +565,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { border:none !important; margin:0; padding:0; - overflow-y: visible; } .adtab-grid { @@ -583,6 +574,7 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none { .adtab-grid-south { border: none; + height: 30px; } .adtab-grid-south .z-paging {