IDEMPIERE-369 Master Detail layout improvements. Performance optimization. Drop non split view support for form view.

This commit is contained in:
Heng Sin Low 2012-12-24 16:19:35 +08:00
parent 84af8c3d6a
commit b323eb1424
8 changed files with 141 additions and 259 deletions

View File

@ -936,9 +936,9 @@ public class ADSortTab extends Panel implements IADTabpanel
} }
@Override @Override
public void setDetailPaneMode(boolean detailMode, boolean vflex) { public void setDetailPaneMode(boolean detailMode) {
this.detailPaneMode = detailMode; this.detailPaneMode = detailMode;
this.setVflex(Boolean.toString(vflex)); this.setVflex("true");
} }
public boolean isDetailPaneMode() { public boolean isDetailPaneMode() {

View File

@ -54,7 +54,6 @@ import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.GridWindow; import org.compiere.model.GridWindow;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MSysConfig;
import org.compiere.model.MToolBarButton; import org.compiere.model.MToolBarButton;
import org.compiere.model.MToolBarButtonRestrict; import org.compiere.model.MToolBarButtonRestrict;
import org.compiere.model.MTree; 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.au.out.AuFocus;
import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions; import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.IdSpace; import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
@ -209,10 +209,8 @@ DataStatusListener, IADTabpanel, IdSpace
} }
public void addDetails(Component component) { public void addDetails(Component component) {
if (formContainer.isVisible()) {
detailPane = component; detailPane = component;
if (formContainer instanceof Borderlayout) { if (formContainer instanceof Borderlayout) {
if (isUseSplitViewForForm()) {
Borderlayout borderLayout = (Borderlayout) formContainer; Borderlayout borderLayout = (Borderlayout) formContainer;
borderLayout.appendSouth(detailPane); borderLayout.appendSouth(detailPane);
@ -220,22 +218,13 @@ DataStatusListener, IADTabpanel, IdSpace
borderLayout.getSouth().setSplittable(true); borderLayout.getSouth().setSplittable(true);
borderLayout.getSouth().setOpen(true); borderLayout.getSouth().setOpen(true);
borderLayout.getSouth().setSclass("adwindow-gridview-detail"); borderLayout.getSouth().setSclass("adwindow-gridview-detail");
} else {
form.getParent().appendChild(detailPane);
}
} else { } else {
formContainer.appendChild(component); formContainer.appendChild(component);
} }
} else {
listPanel.addDetails(component);
}
} }
public Component removeDetails() { public Component removeDetails() {
Component details = null; Component details = null;
if (listPanel.isVisible()) {
details = listPanel.removeDetails();
} else {
if (detailPane != null) { if (detailPane != null) {
if (detailPane.getParent() != null) { if (detailPane.getParent() != null) {
details = detailPane; details = detailPane;
@ -243,7 +232,6 @@ DataStatusListener, IADTabpanel, IdSpace
} }
detailPane = null; detailPane = null;
} }
}
return details; return details;
} }
@ -308,6 +296,7 @@ DataStatusListener, IADTabpanel, IdSpace
div.setVflex("1"); div.setVflex("1");
div.setHflex("1"); div.setHflex("1");
div.setSclass("adtab-form"); div.setSclass("adtab-form");
div.setStyle("overflow-y: visible;");
layout.appendChild(center); layout.appendChild(center);
formContainer = layout; formContainer = layout;
@ -319,10 +308,10 @@ DataStatusListener, IADTabpanel, IdSpace
Vlayout div = new Vlayout(); Vlayout div = new Vlayout();
div.setSclass("adtab-form"); div.setSclass("adtab-form");
div.appendChild(form); div.appendChild(form);
div.setStyle("overflow-y: visible;");
div.setVflex("1"); div.setVflex("1");
div.setWidth("100%"); div.setWidth("100%");
if (isUseSplitViewForForm()) {
StringBuilder cssContent = new StringBuilder(); StringBuilder cssContent = new StringBuilder();
cssContent.append(".adtab-form-borderlayout .z-south-colpsd:before { "); cssContent.append(".adtab-form-borderlayout .z-south-colpsd:before { ");
cssContent.append("content: \""); cssContent.append("content: \"");
@ -345,23 +334,15 @@ DataStatusListener, IADTabpanel, IdSpace
layout.appendChild(center); layout.appendChild(center);
center.appendChild(div); center.appendChild(div);
formContainer = layout; formContainer = layout;
} else {
this.appendChild(div);
formContainer = div;
} }
} form.getParent().appendChild(listPanel);
this.appendChild(listPanel);
listPanel.setVisible(false); listPanel.setVisible(false);
listPanel.setWindowNo(windowNo); listPanel.setWindowNo(windowNo);
listPanel.setADWindowPanel(winPanel); listPanel.setADWindowPanel(winPanel);
} }
public static boolean isUseSplitViewForForm() {
return MSysConfig.getBooleanValue("ZK_AD_WINDOW_FORM_SPLITVIEW", true);
}
/** /**
* Create UI components if not already created * Create UI components if not already created
*/ */
@ -642,8 +623,10 @@ DataStatusListener, IADTabpanel, IdSpace
GridField changedField = gridTab.getField(col); GridField changedField = gridTab.getField(col);
String columnName = changedField.getColumnName(); String columnName = changedField.getColumnName();
ArrayList<?> dependants = gridTab.getDependantFields(columnName); ArrayList<?> dependants = gridTab.getDependantFields(columnName);
if (logger.isLoggable(Level.CONFIG)) {
logger.config("(" + gridTab.toString() + ") " logger.config("(" + gridTab.toString() + ") "
+ columnName + " - Dependents=" + dependants.size()); + columnName + " - Dependents=" + dependants.size());
}
if (dependants.size() == 0 && changedField.getCallout().length() > 0) if (dependants.size() == 0 && changedField.getCallout().length() > 0)
{ {
return; return;
@ -651,7 +634,9 @@ DataStatusListener, IADTabpanel, IdSpace
} }
boolean noData = gridTab.getRowCount() == 0; boolean noData = gridTab.getRowCount() == 0;
if (logger.isLoggable(Level.CONFIG)) {
logger.config(gridTab.toString() + " - Rows=" + gridTab.getRowCount()); logger.config(gridTab.toString() + " - Rows=" + gridTab.getRowCount());
}
for (WEditor comp : editors) for (WEditor comp : editors)
{ {
GridField mField = comp.getGridField(); GridField mField = comp.getGridField();
@ -758,7 +743,9 @@ DataStatusListener, IADTabpanel, IdSpace
} }
Events.sendEvent(this, new Event(ON_DYNAMIC_DISPLAY_EVENT, this)); Events.sendEvent(this, new Event(ON_DYNAMIC_DISPLAY_EVENT, this));
if (logger.isLoggable(Level.CONFIG)) {
logger.config(gridTab.toString() + " - fini - " + (col<=0 ? "complete" : "seletive")); logger.config(gridTab.toString() + " - fini - " + (col<=0 ? "complete" : "seletive"));
}
} // dynamicDisplay } // dynamicDisplay
/** /**
@ -978,7 +965,7 @@ DataStatusListener, IADTabpanel, IdSpace
} }
if (row == -1) 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); logger.log(Level.WARNING, "Tab does not have ID with Node_ID=" + nodeID);
return; return;
} }
@ -997,7 +984,9 @@ DataStatusListener, IADTabpanel, IdSpace
if (Executions.getCurrent() == null) return; if (Executions.getCurrent() == null) return;
int col = e.getChangedColumn(); int col = e.getChangedColumn();
if (logger.isLoggable(Level.CONFIG)) {
logger.config("(" + gridTab + ") Col=" + col + ": " + e.toString()); logger.config("(" + gridTab + ") Col=" + col + ": " + e.toString());
}
// Process Callout // Process Callout
GridField mField = gridTab.getField(col); GridField mField = gridTab.getField(col);
@ -1129,14 +1118,14 @@ DataStatusListener, IADTabpanel, IdSpace
* Toggle between form and grid view * Toggle between form and grid view
*/ */
public void switchRowPresentation() { public void switchRowPresentation() {
Component details = removeDetails(); if (form.isVisible()) {
if (formContainer.isVisible()) { form.setVisible(false);
formContainer.setVisible(false); ((HtmlBasedComponent)form.getParent()).setStyle("");
} else { } else {
formContainer.setVisible(true); form.setVisible(true);
formContainer.getParent().invalidate(); ((HtmlBasedComponent)form.getParent()).setStyle("overflow-y: visible;");
} }
listPanel.setVisible(!formContainer.isVisible()); listPanel.setVisible(!form.isVisible());
if (listPanel.isVisible()) { if (listPanel.isVisible()) {
listPanel.refresh(gridTab); listPanel.refresh(gridTab);
listPanel.scrollToCurrentRow(); listPanel.scrollToCurrentRow();
@ -1144,9 +1133,6 @@ DataStatusListener, IADTabpanel, IdSpace
listPanel.deactivate(); listPanel.deactivate();
} }
if (details != null)
addDetails(details);
Events.sendEvent(this, new Event(ON_SWITCH_VIEW_EVENT, this)); Events.sendEvent(this, new Event(ON_SWITCH_VIEW_EVENT, this));
} }
@ -1229,15 +1215,13 @@ DataStatusListener, IADTabpanel, IdSpace
} }
@Override @Override
public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { public void setDetailPaneMode(boolean detailPaneMode) {
this.detailPaneMode = detailPaneMode; this.detailPaneMode = detailPaneMode;
if (detailPaneMode) { if (detailPaneMode) {
detailPane = null; detailPane = null;
this.setVflex("true");
} else {
this.setVflex(Boolean.toString(vflex));
} }
listPanel.setDetailPaneMode(detailPaneMode, vflex); this.setVflex("true");
listPanel.setDetailPaneMode(detailPaneMode);
} }
/** /**

View File

@ -23,7 +23,6 @@ import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import org.adempiere.util.Callback; import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.ADTabListModel; import org.adempiere.webui.component.ADTabListModel;
import org.adempiere.webui.component.ADTabListModel.ADTabLabel; import org.adempiere.webui.component.ADTabListModel.ADTabLabel;
import org.adempiere.webui.window.FDialog; import org.adempiere.webui.window.FDialog;
@ -135,16 +134,6 @@ public class CompositeADTabbox extends AbstractADTabbox
} }
} }
}); });
detailPane.addEventListener(DetailPane.ON_POST_SELECT_TAB_EVENT, new EventListener<Event>() {
@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) { protected void onEditDetail(int row) {
@ -160,7 +149,7 @@ public class CompositeADTabbox extends AbstractADTabbox
throw new RuntimeException(e); throw new RuntimeException(e);
} }
headerTab.setDetailPaneMode(false, true); headerTab.setDetailPaneMode(false);
if (headerTab.isGridView()) { if (headerTab.isGridView()) {
headerTab.switchRowPresentation(); headerTab.switchRowPresentation();
} }
@ -270,10 +259,9 @@ public class CompositeADTabbox extends AbstractADTabbox
if (tabPanel == headerTab) { if (tabPanel == headerTab) {
IADTabpanel detailPanel = getSelectedDetailADTabpanel(); IADTabpanel detailPanel = getSelectedDetailADTabpanel();
if (detailPanel != null) { if (detailPanel != null) {
detailPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); detailPanel.setDetailPaneMode(true);
} }
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); detailPane.setVflex("true");
layout.invalidate();
} }
} }
}); });
@ -316,12 +304,12 @@ public class CompositeADTabbox extends AbstractADTabbox
tabPanel.setVisible(false); tabPanel.setVisible(false);
detailPane.setHflex("1"); detailPane.setHflex("1");
detailPane.addADTabpanel(tabPanel, tabLabel); detailPane.addADTabpanel(tabPanel, tabLabel);
tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); tabPanel.setDetailPaneMode(true);
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); detailPane.setVflex("true");
} else { } else {
detailPane.addADTabpanel(tabPanel, tabLabel, false); detailPane.addADTabpanel(tabPanel, tabLabel, false);
tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); tabPanel.setDetailPaneMode(true);
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); detailPane.setVflex("true");
} }
HtmlBasedComponent htmlComponent = (HtmlBasedComponent) tabPanel; HtmlBasedComponent htmlComponent = (HtmlBasedComponent) tabPanel;
htmlComponent.setVflex("1"); htmlComponent.setVflex("1");
@ -413,10 +401,10 @@ public class CompositeADTabbox extends AbstractADTabbox
} }
if (tabPanel.getParent() != null) tabPanel.detach(); if (tabPanel.getParent() != null) tabPanel.detach();
detailPane.addADTabpanel(tabPanel, tabLabel); detailPane.addADTabpanel(tabPanel, tabLabel);
tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); tabPanel.setDetailPaneMode(true);
} else if (tabLevel > currentLevel ){ } else if (tabLevel > currentLevel ){
detailPane.addADTabpanel(tabPanel, tabLabel, false); detailPane.addADTabpanel(tabPanel, tabLabel, false);
tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); tabPanel.setDetailPaneMode(true);
} else { } else {
break; break;
} }
@ -425,12 +413,12 @@ public class CompositeADTabbox extends AbstractADTabbox
if (detailPane.getTabcount() > 0 && !headerTab.getGridTab().isSortTab()) { if (detailPane.getTabcount() > 0 && !headerTab.getGridTab().isSortTab()) {
ADTabpanel adtabpanel = (ADTabpanel) headerTab; ADTabpanel adtabpanel = (ADTabpanel) headerTab;
adtabpanel.addDetails(detailPane); adtabpanel.addDetails(detailPane);
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); detailPane.setVflex("true");
detailPane.setSelectedIndex(0); detailPane.setSelectedIndex(0);
activateDetailADTabpanel(); activateDetailADTabpanel();
} }
headerTab.setDetailPaneMode(false, true); headerTab.setDetailPaneMode(false);
updateBreadCrumb(); updateBreadCrumb();
} }
@ -550,11 +538,8 @@ public class CompositeADTabbox extends AbstractADTabbox
Env.setContext(Env.getCtx(), field.getWindowNo(), field.getColumnName(), ""); Env.setContext(Env.getCtx(), field.getWindowNo(), field.getColumnName(), "");
} }
detailTab.activate(true); detailTab.activate(true);
detailTab.setDetailPaneMode(true, isUseVflexForDetailPane()); detailTab.setDetailPaneMode(true);
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); detailPane.setVflex("true");
if (!ADTabpanel.isUseSplitViewForForm() && !headerTab.isGridView()) {
Events.postEvent(new Event(LayoutUtils.ON_REDRAW_EVENT, detailPane));
}
} }
} }
@ -649,8 +634,8 @@ public class CompositeADTabbox extends AbstractADTabbox
if (!tabPanel.isGridView()) { if (!tabPanel.isGridView()) {
tabPanel.switchRowPresentation(); tabPanel.switchRowPresentation();
} }
tabPanel.setDetailPaneMode(true, isUseVflexForDetailPane()); tabPanel.setDetailPaneMode(true);
detailPane.setVflex(Boolean.toString(isUseVflexForDetailPane())); detailPane.setVflex("true");
if (tabPanel instanceof ADSortTab) { if (tabPanel instanceof ADSortTab) {
detailPane.updateToolbar(false, true); detailPane.updateToolbar(false, true);
} else { } else {
@ -667,10 +652,6 @@ public class CompositeADTabbox extends AbstractADTabbox
//other error will be catch in the dataStatusChanged event //other error will be catch in the dataStatusChanged event
} }
private boolean isUseVflexForDetailPane() {
return headerTab.isGridView() || ADTabpanel.isUseSplitViewForForm();
}
@Override @Override
public void updateDetailPaneToolbar(boolean changed, boolean readOnly) { public void updateDetailPaneToolbar(boolean changed, boolean readOnly) {
if (headerTab.getGridTab().isNew() || headerTab.getGridTab().getRowCount() == 0) if (headerTab.getGridTab().isNew() || headerTab.getGridTab().getRowCount() == 0)

View File

@ -99,16 +99,10 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
} }
}); });
tabbox.setSclass("adwindow-detailpane-tabbox"); tabbox.setSclass("adwindow-detailpane-tabbox");
if (!ADTabpanel.isUseSplitViewForForm()) {
LayoutUtils.addSclass("adwindow-detailpane-tabbox-xsplit", tabbox);
}
createPopup(); createPopup();
this.setSclass("adwindow-detailpane"); this.setSclass("adwindow-detailpane");
if (!ADTabpanel.isUseSplitViewForForm()) {
LayoutUtils.addSclass("adwindow-detailpane-xsplit", this);
}
addEventListener(LayoutUtils.ON_REDRAW_EVENT, this); addEventListener(LayoutUtils.ON_REDRAW_EVENT, this);

View File

@ -45,16 +45,14 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Cell; import org.zkoss.zul.Cell;
import org.zkoss.zul.Div;
import org.zkoss.zul.Grid; import org.zkoss.zul.Grid;
import org.zkoss.zul.Label;
import org.zkoss.zul.Paging; import org.zkoss.zul.Paging;
import org.zkoss.zul.RendererCtrl; import org.zkoss.zul.RendererCtrl;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer; import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.RowRendererExt; import org.zkoss.zul.RowRendererExt;
import org.zkoss.zul.impl.XulElement; import org.zkoss.zul.impl.XulElement;
import org.zkoss.zhtml.Label;
import org.zkoss.zhtml.Text;
/** /**
* Row renderer for GridTab grid. * Row renderer for GridTab grid.
@ -64,7 +62,11 @@ import org.zkoss.zhtml.Text;
* <li>BF [ 2996608 ] GridPanel is not displaying time * <li>BF [ 2996608 ] GridPanel is not displaying time
* https://sourceforge.net/tracker/?func=detail&aid=2996608&group_id=176962&atid=955896 * https://sourceforge.net/tracker/?func=detail&aid=2996608&group_id=176962&atid=955896
*/ */
public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt, RendererCtrl { public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt, RendererCtrl, EventListener<Event> {
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 static final int MAX_TEXT_LENGTH = 60;
private GridTab gridTab; private GridTab gridTab;
@ -211,11 +213,9 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
// since 5.0.8, the org.zkoss.zhtml.Text is encoded by default // since 5.0.8, the org.zkoss.zhtml.Text is encoded by default
// if (display != null) // if (display != null)
// display = XMLs.encodeText(display); // display = XMLs.encodeText(display);
label.appendChild(new Text(display)); label.setValue(display);
if (text != null && text.length() > MAX_TEXT_LENGTH) if (text != null && text.length() > MAX_TEXT_LENGTH)
label.setDynamicProperty("title", text); label.setTooltiptext(text);
else
label.setDynamicProperty("title", "");
} }
/** /**
@ -251,11 +251,11 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
for (Entry<GridField, WEditor> entry : editors.entrySet()) { for (Entry<GridField, WEditor> entry : editors.entrySet()) {
if (entry.getValue().getComponent().getParent() != null) { if (entry.getValue().getComponent().getParent() != null) {
Component child = entry.getValue().getComponent(); Component child = entry.getValue().getComponent();
Div div = null; Cell div = null;
while (div == null && child != null) { while (div == null && child != null) {
Component parent = child.getParent(); Component parent = child.getParent();
if (parent instanceof Div && parent.getParent() instanceof Row) if (parent instanceof Cell && parent.getParent() instanceof Row)
div = (Div)parent; div = (Cell)parent;
else else
child = parent; child = parent;
} }
@ -355,16 +355,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
Cell cell = new Cell(); Cell cell = new Cell();
cell.setWidth("10px"); cell.setWidth("10px");
cell.addEventListener(Events.ON_CLICK, new EventListener<Event>() { cell.addEventListener(Events.ON_CLICK, this);
@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.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord"))); cell.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "EditRecord")));
//TODO: checkbox for selection and batch action ( delete, export, complete, etc ) //TODO: checkbox for selection and batch action ( delete, export, complete, etc )
@ -391,8 +382,8 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
} }
colIndex ++; colIndex ++;
Div div = new Div(); Cell div = new Cell();
String divStyle = "border: none; height: 100%; cursor: pointer;"; String divStyle = CELL_DIV_STYLE;
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex); org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) { if (column.isVisible()) {
Component component = getDisplayComponent(rowIndex, currentValues[i], gridPanelFields[i]); Component component = getDisplayComponent(rowIndex, currentValues[i], gridPanelFields[i]);
@ -400,10 +391,10 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
div.setAttribute("display.component", component); div.setAttribute("display.component", component);
if (DisplayType.YesNo == gridPanelFields[i].getDisplayType() || DisplayType.Image == gridPanelFields[i].getDisplayType()) { 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())) { else if (DisplayType.isNumeric(gridPanelFields[i].getDisplayType())) {
divStyle += "text-align:right; "; divStyle = CELL_DIV_STYLE_ALIGN_RIGHT;
} }
} }
div.setStyle(divStyle); div.setStyle(divStyle);
@ -413,13 +404,14 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
div.addEventListener(Events.ON_CLICK, rowListener); div.addEventListener(Events.ON_CLICK, rowListener);
div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener); div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
row.addEventListener(Events.ON_CLICK, rowListener); row.addEventListener(Events.ON_CLICK, rowListener);
row.setStyle("cursor:pointer");
row.appendChild(div); row.appendChild(div);
} }
if (rowIndex == gridTab.getCurrentRow()) { if (rowIndex == gridTab.getCurrentRow()) {
setCurrentRow(row); setCurrentRow(row);
} }
row.setStyle("cursor:pointer");
row.addEventListener(Events.ON_OK, rowListener); row.addEventListener(Events.ON_OK, rowListener);
} }
@ -490,7 +482,7 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex); org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) { if (column.isVisible()) {
Div div = (Div) currentRow.getChildren().get(colIndex); Cell div = (Cell) currentRow.getChildren().get(colIndex);
div.getChildren().clear(); div.getChildren().clear();
WEditor editor = getEditorCell(gridPanelFields[i]); WEditor editor = getEditorCell(gridPanelFields[i]);
div.appendChild(editor.getComponent()); div.appendChild(editor.getComponent());
@ -663,4 +655,15 @@ public class GridTabRowRenderer implements RowRenderer<Object[]>, 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);
}
}
} }

View File

@ -23,7 +23,6 @@ import javax.swing.table.AbstractTableModel;
import org.adempiere.model.MTabCustomization; import org.adempiere.model.MTabCustomization;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Borderlayout;
import org.adempiere.webui.component.Columns; import org.adempiere.webui.component.Columns;
import org.adempiere.webui.component.EditorBox; import org.adempiere.webui.component.EditorBox;
import org.adempiere.webui.component.Grid; 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.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Center;
import org.zkoss.zul.Column; import org.zkoss.zul.Column;
import org.zkoss.zul.Div; import org.zkoss.zul.Div;
import org.zkoss.zul.Frozen; import org.zkoss.zul.Frozen;
import org.zkoss.zul.North;
import org.zkoss.zul.Paging; import org.zkoss.zul.Paging;
import org.zkoss.zul.Row; import org.zkoss.zul.Row;
import org.zkoss.zul.Style;
import org.zkoss.zul.Vbox; import org.zkoss.zul.Vbox;
import org.zkoss.zul.event.ZulEvents; import org.zkoss.zul.event.ZulEvents;
@ -65,9 +61,11 @@ import org.zkoss.zul.event.ZulEvents;
*/ */
public class GridView extends Vbox implements EventListener<Event>, IdSpace public class GridView extends Vbox implements EventListener<Event>, 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_DETAIL_PAGE_SIZE = 10;
private static final int DEFAULT_PAGE_SIZE = 50; private static final int DEFAULT_PAGE_SIZE = 20;
/** /**
* generated serial version ID * generated serial version ID
@ -115,10 +113,6 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace
private Map<Integer, String> columnWidthMap; private Map<Integer, String> columnWidthMap;
private Component detail;
private Borderlayout borderLayout;
private boolean detailPaneMode; private boolean detailPaneMode;
public GridView() public GridView()
@ -141,87 +135,48 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace
gridFooter.setHflex("1"); gridFooter.setHflex("1");
gridFooter.setVflex("0"); 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 //default paging size
if (AEnv.isTablet()) if (AEnv.isTablet())
{ {
//anything more than 20 is very slow on a tablet //anything more than 20 is very slow on a tablet
pageSize = 20; pageSize = 10;
} }
else 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 //default true for better UI experience
modeless = MSysConfig.getBooleanValue(MSysConfig.ZK_GRID_EDIT_MODELESS, true); 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() { protected void createListbox() {
listbox = new Grid(); listbox = new Grid();
listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "FindZeroRecords"))); listbox.setEmptyMessage(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "FindZeroRecords")));
listbox.addEventListener(ZulEvents.ON_AFTER_RENDER, this);
listbox.setSizedByContent(true); listbox.setSizedByContent(true);
listbox.setVflex("1"); listbox.setVflex("1");
listbox.setHflex("1"); listbox.setHflex("1");
listbox.setSclass("adtab-grid"); listbox.setSclass("adtab-grid");
} }
public void setDetailPaneMode(boolean detailPaneMode, boolean vflex) { public void setDetailPaneMode(boolean detailPaneMode) {
this.detailPaneMode = detailPaneMode; this.detailPaneMode = detailPaneMode;
pageSize = detailPaneMode ? DEFAULT_DETAIL_PAGE_SIZE : MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 20);
updatePaging();
if (detailPaneMode) { if (detailPaneMode) {
pageSize = DEFAULT_DETAIL_PAGE_SIZE; setStyle("");
updatePaging(); gridFooter.setStyle("");
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));
} else { } else {
pageSize = MSysConfig.getIntValue(MSysConfig.ZK_PAGING_SIZE, 50); setStyle(HEADER_GRID_STYLE);
updatePaging(); gridFooter.setStyle(HEADER_GRID_STYLE);
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");
} }
} }
@ -361,7 +316,6 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace
paging.setTotalSize(gridTab.getRowCount()); paging.setTotalSize(gridTab.getRowCount());
if (paging.getPageCount() > 1 && !gridFooter.isVisible()) { if (paging.getPageCount() > 1 && !gridFooter.isVisible()) {
gridFooter.setVisible(true); gridFooter.setVisible(true);
borderLayout.invalidate();
} }
int pgIndex = rowIndex >= 0 ? rowIndex % pageSize : 0; int pgIndex = rowIndex >= 0 ? rowIndex % pageSize : 0;
int pgNo = rowIndex >= 0 ? (rowIndex - pgIndex) / pageSize : 0; int pgNo = rowIndex >= 0 ? (rowIndex - pgIndex) / pageSize : 0;
@ -608,11 +562,6 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace
onSelectedRowChange(0); 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) { private void onSelectedRowChange(int index) {
@ -889,25 +838,4 @@ public class GridView extends Vbox implements EventListener<Event>, IdSpace
public GridField[] getFields() { public GridField[] getFields() {
return gridField; 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;
}
} }

View File

@ -122,7 +122,7 @@ public interface IADTabpanel extends Component, Evaluatee {
public boolean isActive(); public boolean isActive();
public void setDetailPaneMode(boolean detailMode, boolean vflex); public void setDetailPaneMode(boolean detailMode);
public boolean isDetailPaneMode(); public boolean isDetailPaneMode();

View File

@ -510,10 +510,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
overflow-y: visible; overflow-y: visible;
} }
.adwindow-detailpane-xsplit {
min-height: 200px;
}
.adwindow-detailpane-tabpanel { .adwindow-detailpane-tabpanel {
background-color: #fff background-color: #fff
} }
@ -541,10 +537,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
background-color: #E4E4E4; background-color: #E4E4E4;
} }
.adwindow-detailpane-tabbox-xsplit .z-tabpanel {
min-height: 200px;
}
.adwindow-gridview-detail { .adwindow-gridview-detail {
height: 200px; height: 200px;
} }
@ -573,7 +565,6 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
border:none !important; border:none !important;
margin:0; margin:0;
padding:0; padding:0;
overflow-y: visible;
} }
.adtab-grid { .adtab-grid {
@ -583,6 +574,7 @@ div.wc-modal, div.wc-modal-none, div.wc-highlighted, div.wc-highlighted-none {
.adtab-grid-south { .adtab-grid-south {
border: none; border: none;
height: 30px;
} }
.adtab-grid-south .z-paging { .adtab-grid-south .z-paging {