diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java index 90df4b716b..e3eec95dee 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/CWindowToolbar.java @@ -148,6 +148,19 @@ public class CWindowToolbar extends FToolbar implements EventListener configureKeyMap(); } + /** + * set embedded mode on/off, embedded panel toolbar should show less button + * @param embedded + */ + public void setEmbedded(boolean embedded) + { + btnParentRecord.setVisible(!embedded); + btnDetailRecord.setVisible(!embedded); + btnActiveWorkflows.setVisible(!embedded); + btnHistoryRecords.setVisible(!embedded); + btnProductInfo.setVisible(!embedded); + } + private ToolBarButton createButton(String name, String image, String tooltip) { ToolBarButton btn = new ToolBarButton(""); @@ -158,6 +171,11 @@ public class CWindowToolbar extends FToolbar implements EventListener this.appendChild(btn); return btn; } + + public ToolBarButton getButton(String name) + { + return buttons.get(name); + } private void configureKeyMap() { keyMap.put(KeyEvent.F1, btnHelp); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java index 446c02118e..d56f21b0b6 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/GridPanel.java @@ -1,6 +1,5 @@ /****************************************************************************** - * Product: Posterita Ajax UI * - * Copyright (C) 2007 Posterita Ltd. All Rights Reserved. * + * Copyright (C) 2008 Low Heng Sin * * This program is free software; you can redistribute it and/or modify it * * under the terms version 2 of the GNU General Public License as published * * by the Free Software Foundation. This program is distributed in the hope * @@ -10,11 +9,7 @@ * You should have received a copy of the GNU General Public License along * * with this program; if not, write to the Free Software Foundation, Inc., * * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. * - * For the text or an alternative of this public license, you may reach us * - * Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius * - * or via info@posterita.org or http://www.posterita.org/ * *****************************************************************************/ - package org.adempiere.webui.component; @@ -27,11 +22,9 @@ import org.adempiere.webui.LayoutUtils; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.model.GridTable; -import org.zkoss.zk.au.out.AuEcho; 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.zkex.zul.Borderlayout; import org.zkoss.zkex.zul.Center; import org.zkoss.zkex.zul.South; @@ -231,7 +224,11 @@ public class GridPanel extends Borderlayout implements EventListener south.appendChild(paging); paging.addEventListener(ZulEvents.ON_PAGING, this); this.getParent().invalidate(); - } + } + else + { + south.setVisible(false); + } } private void updateModel() { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java index 1e3cf9eeba..ddb408f55e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/component/ToolBarButton.java @@ -36,9 +36,21 @@ public class ToolBarButton extends org.zkoss.zul.Toolbarbutton if (disabled) { this.setSclass("disableFilter"); } else { - this.setSclass(""); + if (this.getSclass() != null && this.getSclass().indexOf("disableFilter") >= 0) + this.setSclass(this.getSclass().replace("disableFilter", "")); } } + + public void setPressed(boolean pressed) { + if (!isDisabled()) { + if (pressed) + setSclass("depressed"); + else { + if (this.getSclass() != null && this.getSclass().indexOf("depressed") >= 0) + this.setSclass(this.getSclass().replace("depressed", "")); + } + } + } public ToolBarButton(String name) { super(); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java b/zkwebui/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java index 71d98bcba9..333ed0ef46 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/event/ToolbarListener.java @@ -35,11 +35,6 @@ public interface ToolbarListener */ public void onNew(); - /** - * Edit current record - */ - public void onEdit(); - /** * Navigate to first record */ diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java index 3991aa1da5..f34a9ae4b0 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADSortTab.java @@ -847,10 +847,6 @@ public class ADSortTab extends Panel implements IADTabpanel return gridTab != null ? gridTab.isCurrent() : false; } - public boolean isEditing() { - return true; - } - public void query() { loadData(); } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java index 10b415de67..9984d225b9 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADTabpanel.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Properties; import java.util.Map.Entry; import java.util.logging.Level; @@ -38,7 +39,6 @@ import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.SimpleTreeModel; -import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.editor.IZoomableEditor; import org.adempiere.webui.editor.WButtonEditor; import org.adempiere.webui.editor.WEditor; @@ -71,10 +71,11 @@ import org.zkoss.zkex.zul.Borderlayout; import org.zkoss.zkex.zul.Center; import org.zkoss.zkex.zul.West; import org.zkoss.zul.Div; +import org.zkoss.zul.Group; +import org.zkoss.zul.Groupfoot; import org.zkoss.zul.Separator; import org.zkoss.zul.SimpleTreeNode; import org.zkoss.zul.Space; -import org.zkoss.zul.Toolbarbutton; import org.zkoss.zul.Tree; import org.zkoss.zul.Treeitem; @@ -104,7 +105,8 @@ DataStatusListener, IADTabpanel private GridTab gridTab; - private GridWindow gridWindow; + @SuppressWarnings("unused") + private GridWindow gridWindow; private AbstractADWindowPanel windowPanel; @@ -116,17 +118,15 @@ DataStatusListener, IADTabpanel private ArrayList editorIds = new ArrayList(); - private boolean editing; - private boolean uiCreated = false; private GridPanel listPanel; - private Map> fieldGroupContents = new HashMap>(); + private Map> fieldGroupContents = new HashMap>(); - private Map> fieldGroupHeaders = new HashMap>(); + private Map> fieldGroupHeaders = new HashMap>(); - private ArrayList rowList; + private ArrayList rowList; private Component formComponent = null; @@ -134,6 +134,12 @@ DataStatusListener, IADTabpanel private GridTabDataBinder dataBinder; + private Map includedTab = new HashMap(); + + private List includedPanel = new ArrayList(); + + private boolean active = false; + public ADTabpanel() { init(); @@ -237,7 +243,7 @@ DataStatusListener, IADTabpanel Rows rows = new Rows(); GridField fields[] = gridTab.getFields(); - Row row = new Row(); + org.zkoss.zul.Row row = new Row(); String currentFieldGroup = null; for (int i = 0; i < fields.length; i++) @@ -245,6 +251,38 @@ DataStatusListener, IADTabpanel GridField field = fields[i]; if (field.isDisplayed()) { + //included tab + if (field.getIncluded_Tab_ID() > 0) + { + if (row.getChildren().size() == 2) + { + row.appendChild(createSpacer()); + row.appendChild(createSpacer()); + row.appendChild(createSpacer()); + rows.appendChild(row); + if (rowList != null) + rowList.add(row); + row = new Row(); + } else if (row.getChildren().size() > 0) + { + rows.appendChild(row); + if (rowList != null) + rowList.add(row); + row = new Row(); + } + + row.setSpans("5"); + row.appendChild(new Separator()); + rows.appendChild(row); + + row = new Group(); + rows.appendChild(row); + includedTab .put(field.getIncluded_Tab_ID(), (Group)row); + row = new Row(); + continue; + } + + //normal field String fieldGroup = field.getFieldGroup(); if (fieldGroup != null && fieldGroup.trim().length() > 0) { @@ -268,7 +306,7 @@ DataStatusListener, IADTabpanel row = new Row(); } - List headerRows = new ArrayList(); + List headerRows = new ArrayList(); fieldGroupHeaders.put(fieldGroup, headerRows); row.setSpans("5"); @@ -276,13 +314,13 @@ DataStatusListener, IADTabpanel rows.appendChild(row); headerRows.add(row); - rowList = new ArrayList(); + rowList = new ArrayList(); fieldGroupContents.put(fieldGroup, rowList); - - row = new Row(); - row.setSpans("4"); + if (X_AD_FieldGroup.FIELDGROUPTYPE_Label.equals(field.getFieldGroupType())) { + row = new Row(); + row.setSpans("4"); Label groupLabel = new Label(fieldGroup); row.appendChild(groupLabel); row.appendChild(createSpacer()); @@ -300,12 +338,11 @@ DataStatusListener, IADTabpanel } else { - ToolBar toolbar = new ToolBar(); - Toolbarbutton button = new Toolbarbutton(fieldGroup, "images/ns-collapse.png"); - button.addEventListener(Events.ON_CLICK, this); - button.setParent(toolbar); - row.appendChild(toolbar); - row.appendChild(createSpacer()); + row = new Group(fieldGroup); + if (X_AD_FieldGroup.FIELDGROUPTYPE_Tab.equals(field.getFieldGroupType()) || field.getIsCollapsedByDefault()) + { + ((Group)row).setOpen(false); + } rows.appendChild(row); headerRows.add(row); } @@ -316,6 +353,7 @@ DataStatusListener, IADTabpanel if (!field.isSameLine()) { + //next line if(row.getChildren().size() > 0) { if (row.getChildren().size() == 2) @@ -335,6 +373,7 @@ DataStatusListener, IADTabpanel } else if (row.getChildren().size() == 4) { + //next line if reach max column ( 4 ) row.appendChild(createSpacer()); rows.appendChild(row); if (rowList != null) @@ -377,6 +416,7 @@ DataStatusListener, IADTabpanel editor.addValueChangeListener(dataBinder); } + //streach component to fill grid cell if (editor.getComponent() instanceof HtmlBasedComponent) { //can't stretch bandbox & datebox if (!(editor.getComponent() instanceof Bandbox) && @@ -394,8 +434,8 @@ DataStatusListener, IADTabpanel } } - WEditorPopupMenu popupMenu = editor.getPopupMenu(); - + //setup editor context menu + WEditorPopupMenu popupMenu = editor.getPopupMenu(); if (popupMenu != null) { popupMenu.addMenuListener((ContextMenuListener)editor); @@ -411,6 +451,8 @@ DataStatusListener, IADTabpanel } } } + + //last row if (row.getChildren().size() > 0) { if (row.getChildren().size() == 2) @@ -425,11 +467,15 @@ DataStatusListener, IADTabpanel } grid.appendChild(rows); + //create tree if (gridTab.isTreeTab() && tree != null) { int AD_Tree_ID = MTree.getDefaultAD_Tree_ID ( Env.getAD_Client_ID(Env.getCtx()), gridTab.getKeyColumnName()); SimpleTreeModel.initADTree(tree, AD_Tree_ID, windowNo); } + + if (!gridTab.isSingleRow()) + switchRowPresentation(); } private Component createSpacer() { @@ -476,7 +522,7 @@ DataStatusListener, IADTabpanel for (WEditor comp : editors) { GridField mField = comp.getGridField(); - if (mField != null) + if (mField != null && mField.getIncluded_Tab_ID() <= 0) { if (mField.isDisplayed(true)) // check context { @@ -497,13 +543,6 @@ DataStatusListener, IADTabpanel { comp.setMandatory(mField.isMandatory(true)); // check context } - /* - boolean manMissing = false; - if (rw && mField.getValue() == null && mField.isMandatory(true)) // check context - { - manMissing = true; - } - comp.setBackground(manMissing || mField.isError());*/ } } else if (comp.isVisible()) @@ -514,11 +553,11 @@ DataStatusListener, IADTabpanel } // all components //hide row if all editor within the row is invisible - List rows = grid.getRows().getChildren(); + List rows = grid.getRows().getChildren(); for(int i = 0; i < rows.size(); i++) { - Row row = (Row) rows.get(i); - List components = row.getChildren(); + org.zkoss.zul.Row row = (org.zkoss.zul.Row) rows.get(i); + List components = row.getChildren(); boolean visible = false; boolean editorRow = false; for (int j = 0; j < components.size(); j++) @@ -538,13 +577,13 @@ DataStatusListener, IADTabpanel row.setVisible(visible); } - //hide fieldgroup is all editor row within the fieldgroup is invisible - for(Iterator>> i = fieldGroupHeaders.entrySet().iterator(); i.hasNext();) + //hide fieldgroup if all editor row within the fieldgroup is invisible + for(Iterator>> i = fieldGroupHeaders.entrySet().iterator(); i.hasNext();) { - Map.Entry> entry = i.next(); - List contents = fieldGroupContents.get(entry.getKey()); + Map.Entry> entry = i.next(); + List contents = fieldGroupContents.get(entry.getKey()); boolean visible = false; - for (Row row : contents) + for (org.zkoss.zul.Row row : contents) { if (row.isVisible()) { @@ -552,8 +591,8 @@ DataStatusListener, IADTabpanel break; } } - List headers = entry.getValue(); - for(Row row : headers) + List headers = entry.getValue(); + for(org.zkoss.zul.Row row : headers) { if (row.isVisible() != visible) row.setVisible(visible); @@ -621,6 +660,7 @@ DataStatusListener, IADTabpanel public void activate(boolean activate) { + active = activate; if (listPanel.isVisible()) { if (activate) listPanel.activate(gridTab); @@ -632,7 +672,23 @@ DataStatusListener, IADTabpanel setInitialFocus(); } } + + //activate embedded panel + for(EmbeddedPanel ep : includedPanel) + { + activateChild(activate, ep); + } } + + private void activateChild(boolean activate, EmbeddedPanel panel) { + if (activate) + { + panel.windowPanel.getADTab().evaluate(null); + panel.windowPanel.getADTab().setSelectedIndex(0); + panel.tabPanel.query(false, 0, 0); + } + panel.tabPanel.activate(activate); + } private void setInitialFocus() { for (WEditor editor : editors) { @@ -644,38 +700,9 @@ DataStatusListener, IADTabpanel } - public boolean isEditing() - { - return this.editing; - } - - public void editRecord(boolean edit) - { - /* this.editing = edit; - for (Editor editor : editors) - { - editor.setEditing(edit); - }*/ - } - public void onEvent(Event event) { - if (event.getTarget() instanceof Toolbarbutton) - { - Toolbarbutton button = (Toolbarbutton) event.getTarget(); - List list = fieldGroupContents.get(button.getLabel()); - if (list.get(0).isVisible()) { - for (Row row : list) { - row.setVisible(false); - } - button.setImage("images/ns-expand.png"); - } else { - for (Row row : list) { - row.setVisible(true); - } - button.setImage("images/ns-collapse.png"); - } - } else if (event.getTarget() instanceof Listbox) + if (event.getTarget() instanceof Listbox) { this.switchRowPresentation(); } @@ -774,6 +801,12 @@ DataStatusListener, IADTabpanel if (listPanel.isVisible()) { listPanel.updateListIndex(); } + + if (!includedPanel.isEmpty()) { + for (EmbeddedPanel panel : includedPanel) + panel.tabPanel.query(false, 0, 0); + } + } private void deleteNode(int recordId) { @@ -808,7 +841,7 @@ DataStatusListener, IADTabpanel MTreeNode root = (MTreeNode) treeNode.getData(); MTreeNode node = new MTreeNode (gridTab.getRecord_ID(), 0, name, description, root.getNode_ID(), summary, imageIndicator, false, null); - SimpleTreeNode newNode = new SimpleTreeNode(node, new ArrayList()); + SimpleTreeNode newNode = new SimpleTreeNode(node, new ArrayList()); model.addNode(newNode); int[] path = model.getPath(model.getRoot(), newNode); Treeitem ti = tree.renderItemByPath(path); @@ -864,5 +897,47 @@ DataStatusListener, IADTabpanel } } + + /** + * Embed detail tab + * @param ctx + * @param windowNo + * @param gridWindow + * @param adTabId + * @param tabIndex + * @param tabPanel + */ + public void embed(Properties ctx, int windowNo, GridWindow gridWindow, + int adTabId, int tabIndex, IADTabpanel tabPanel) { + EmbeddedPanel ep = new EmbeddedPanel(); + ep.tabPanel = tabPanel; + ep.adTabId = adTabId; + includedPanel.add(ep); + Group group = includedTab.get(adTabId); + if (tabPanel instanceof ADTabpanel) { + ADTabpanel atp = (ADTabpanel) tabPanel; + atp.listPanel.setPageSize(-1); + } + if (group != null) { + ADWindowPanel panel = new ADWindowPanel(ctx, windowNo, gridWindow, tabIndex, tabPanel); + ep.windowPanel = panel; + org.zkoss.zul.Row row = new Row(); + row.setSpans("5"); + Component next = group.getNextSibling(); + grid.getRows().insertBefore(row, next); + panel.createPart(row); + panel.getComponent().setWidth("99%"); + group.setLabel(gridWindow.getTab(tabIndex).getName()); + panel.initPanel(-1, null); + if (active) + activateChild(true, ep); + } + } + + class EmbeddedPanel { + ADWindowPanel windowPanel; + IADTabpanel tabPanel; + int adTabId; + } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java index 0ba627a2a3..5c335368bb 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/ADWindowPanel.java @@ -27,6 +27,8 @@ import org.adempiere.webui.component.Tabbox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabs; import org.adempiere.webui.session.SessionManager; +import org.compiere.model.GridWindow; +import org.compiere.model.MQuery; import org.compiere.util.CLogger; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.HtmlBasedComponent; @@ -63,12 +65,21 @@ public class ADWindowPanel extends AbstractADWindowPanel private Borderlayout layout; private Center contentArea; + + private West west; public ADWindowPanel(Properties ctx, int windowNo) { super(ctx, windowNo); } + + public ADWindowPanel(Properties ctx, int windowNo, GridWindow gridWindow, + int tabIndex, IADTabpanel tabPanel) { + super(ctx, windowNo, gridWindow, tabIndex, tabPanel); + } + + protected Component doCreatePart(Component parent) { layout = new Borderlayout(); @@ -94,14 +105,14 @@ public class ADWindowPanel extends AbstractADWindowPanel statusBar.setParent(s); LayoutUtils.addSclass("adwindow-status", statusBar); - if (adTab.isUseExternalSelection()) + if (!isEmbedded() && adTab.isUseExternalSelection()) { - West w = new West(); - layout.appendChild(w); - w.setSplittable(false); - w.setAutoscroll(true); - LayoutUtils.addSclass("adwindow-nav", w); - adTab.getTabSelectionComponent().setParent(w); + west = new West(); + layout.appendChild(west); + west.setSplittable(false); + west.setAutoscroll(true); + LayoutUtils.addSclass("adwindow-nav", west); + adTab.getTabSelectionComponent().setParent(west); LayoutUtils.addSclass("adwindow-nav-content", (HtmlBasedComponent) adTab.getTabSelectionComponent()); } @@ -116,7 +127,7 @@ public class ADWindowPanel extends AbstractADWindowPanel ((Tabpanel)parent).setOnCloseHandler(handler); } - if (adTab.getComponent() instanceof Window) { + if (!isEmbedded() && adTab.getComponent() instanceof Window) { Window w = (Window) adTab.getComponent(); w.addEventListener(Events.ON_CTRL_KEY, toolbar); } @@ -134,6 +145,18 @@ public class ADWindowPanel extends AbstractADWindowPanel return layout; } + + + @Override + public boolean initPanel(int adWindowId, MQuery query) { + boolean retValue = super.initPanel(adWindowId, query); + if (adTab.getTabCount() == 1 && west != null) + west.setVisible(false); + return retValue; + } + + + class TabOnCloseHanlder implements ITabOnCloseHandler { public void onClose(Tabpanel tabPanel) { diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java index d1c8a0d54f..0bca546d4a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/AbstractADWindowPanel.java @@ -17,6 +17,8 @@ package org.adempiere.webui.panel; +import java.util.HashMap; +import java.util.Map; import java.util.Properties; import java.util.logging.Level; @@ -120,10 +122,40 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To private boolean m_findCancelled; + private int embeddedTabindex = -1; + + protected Map includedMap = new HashMap(); + + private IADTabpanel embeddedTabPanel; + + /** + * Constructor for non-embedded mode + * @param ctx + * @param windowNo + */ public AbstractADWindowPanel(Properties ctx, int windowNo) + { + this(ctx, windowNo, null, -1, null); + } + + /** + * Constructor for embedded mode + * @param ctx + * @param windowNo + * @param gridWindow + * @param tabIndex + * @param tabPanel + */ + public AbstractADWindowPanel(Properties ctx, int windowNo, GridWindow gridWindow, int tabIndex, IADTabpanel tabPanel) { this.ctx = ctx; this.curWindowNo = windowNo; + this.gridWindow = gridWindow; + this.embeddedTabindex = tabIndex; + this.embeddedTabPanel = tabPanel; + curTabpanel = tabPanel; + if (gridWindow != null && tabIndex >= 0) + curTab = gridWindow.getTab(tabIndex); initComponents(); } @@ -134,7 +166,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To this.parent = (Component) parent; adTab = createADTab(); - adTab.addSelectionEventListener(this); + adTab.addSelectionEventListener(this); return super.createPart(parent); } @@ -143,6 +175,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To { return statusBar; } + + public boolean isEmbedded() { + return embeddedTabindex >= 0; + } private void initComponents() { @@ -150,6 +186,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To toolbar = new CWindowToolbar(); toolbar.addListener(this); toolbar.setWidth("100%"); + toolbar.setEmbedded(isEmbedded()); statusBar = new StatusBarPanel(); } @@ -159,106 +196,71 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To public boolean initPanel(int adWindowId, MQuery query) { // Set AutoCommit for this Window - Env.setAutoCommit(ctx, curWindowNo, Env.isAutoCommit(ctx)); - boolean autoNew = Env.isAutoNew(ctx); - Env.setAutoNew(ctx, curWindowNo, autoNew); + if (embeddedTabindex < 0) + { + Env.setAutoCommit(ctx, curWindowNo, Env.isAutoCommit(ctx)); + boolean autoNew = Env.isAutoNew(ctx); + Env.setAutoNew(ctx, curWindowNo, autoNew); - GridWindowVO gWindowVO = AEnv.getMWindowVO(curWindowNo, adWindowId, 0); - if (gWindowVO == null) - { - throw new ApplicationException(Msg.getMsg(ctx, - "AccessTableNoView") - + "(No Window Model Info)"); - } - gridWindow = new GridWindow(gWindowVO); - title = gridWindow.getName(); - - // Set SO/AutoNew for Window - Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx()); - if (!autoNew && gridWindow.isTransaction()) - { - Env.setAutoNew(ctx, curWindowNo, true); - } + GridWindowVO gWindowVO = AEnv.getMWindowVO(curWindowNo, adWindowId, 0); + if (gWindowVO == null) + { + throw new ApplicationException(Msg.getMsg(ctx, + "AccessTableNoView") + + "(No Window Model Info)"); + } + gridWindow = new GridWindow(gWindowVO); + title = gridWindow.getName(); + + // Set SO/AutoNew for Window + Env.setContext(ctx, curWindowNo, "IsSOTrx", gridWindow.isSOTrx()); + if (!autoNew && gridWindow.isTransaction()) + { + Env.setAutoNew(ctx, curWindowNo, true); + } + } - m_onlyCurrentRows = gridWindow.isTransaction(); + m_onlyCurrentRows = embeddedTabindex < 0 && gridWindow.isTransaction(); /** * Window Tabs */ - int tabSize = gridWindow.getTabCount(); - - for (int tab = 0; tab < tabSize; tab++) + if (embeddedTabindex < 0) { - gridWindow.initTab(tab); - - GridTab gTab = gridWindow.getTab(tab); - Env.setContext(ctx, curWindowNo, tab, "TabLevel", Integer - .toString(gTab.getTabLevel())); - - - - gTab.addDataStatusListener(this); - - // Query first tab - if (tab == 0) - { - query = initialQuery(query, gTab); - if (gTab.isHighVolume() && m_findCancelled) - return false; - - if (query != null && query.getRecordCount() <= 1) - { - // goSingleRow = true; - } - // Set initial Query on first tab - if (query != null) - { - m_onlyCurrentRows = false; - gTab.setQuery(query); - } - - curTab = gTab; - curTabIndex = tab; - } - - if (gTab.isSortTab()) - { - ADSortTab sortTab = new ADSortTab(curWindowNo, gTab); - adTab.addTab(gTab, sortTab); - sortTab.registerAPanel(this); - if (tab == 0) { - curTabpanel = sortTab; - curTabpanel.createUI(); - curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, 0); - curTabpanel.activate(true); - } - } - else - { - ADTabpanel fTabPanel = new ADTabpanel(); - fTabPanel.init(this, curWindowNo, gTab, gridWindow); - adTab.addTab(gTab, fTabPanel); - if (tab == 0) { - fTabPanel.createUI(); - curTabpanel = fTabPanel; - curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, 0); - curTabpanel.activate(true); - } - } + int tabSize = gridWindow.getTabCount(); + + for (int tab = 0; tab < tabSize; tab++) + { + initTab(query, tab); + } + Env.setContext(ctx, curWindowNo, "WindowName", gridWindow.getName()); } - - Env.setContext(ctx, curWindowNo, "WindowName", gridWindow.getName()); - curTab.getTableModel().setChanged(false); - curTabIndex = 0; - - adTab.setSelectedIndex(0); - toolbar.enableTabNavigation(adTab.getTabCount() > 1); - toolbar.enableFind(true); - adTab.evaluate(null); - - if (gridWindow.isTransaction()) + else { - toolbar.enableHistoryRecords(true); + initEmbeddedTab(query, embeddedTabindex); + } + + curTab.getTableModel().setChanged(false); + if (embeddedTabindex < 0) + { + curTabIndex = 0; + + adTab.setSelectedIndex(0); + toolbar.enableTabNavigation(adTab.getTabCount() > 1); + toolbar.enableFind(true); + adTab.evaluate(null); + + if (gridWindow.isTransaction()) + { + toolbar.enableHistoryRecords(true); + } + } + else + { + curTabIndex = embeddedTabindex; + toolbar.enableTabNavigation(false); + toolbar.enableFind(true); + toolbar.enableHistoryRecords(false); } updateToolbar(); @@ -266,6 +268,98 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To return true; } + private void initEmbeddedTab(MQuery query, int tabIndex) { + GridTab gTab = gridWindow.getTab(tabIndex); + gTab.addDataStatusListener(this); + adTab.addTab(gTab, embeddedTabPanel); + if (gTab.isSortTab()) { + ((ADSortTab)embeddedTabPanel).registerAPanel(this); + } else { + ((ADTabpanel)embeddedTabPanel).init(this, curWindowNo, gTab, gridWindow); + } + } + + protected void initTab(MQuery query, int tabIndex) { + gridWindow.initTab(tabIndex); + + GridTab gTab = gridWindow.getTab(tabIndex); + Env.setContext(ctx, curWindowNo, tabIndex, "TabLevel", Integer + .toString(gTab.getTabLevel())); + + // Query first tab + if (tabIndex == 0) + { + query = initialQuery(query, gTab); + if (gTab.isHighVolume() && m_findCancelled) + return; + + if (query != null && query.getRecordCount() <= 1) + { + // goSingleRow = true; + } + // Set initial Query on first tab + if (query != null) + { + m_onlyCurrentRows = false; + gTab.setQuery(query); + } + + curTab = gTab; + curTabIndex = tabIndex; + } + + if (gTab.isSortTab()) + { + ADSortTab sortTab = new ADSortTab(curWindowNo, gTab); + if (includedMap.containsKey(gTab.getAD_Tab_ID())) + { + includedMap.get(gTab.getAD_Tab_ID()).embed(ctx, curWindowNo, gridWindow, gTab.getAD_Tab_ID(), tabIndex, sortTab); + } + else + { + adTab.addTab(gTab, sortTab); + sortTab.registerAPanel(this); + if (tabIndex == 0) { + curTabpanel = sortTab; + curTabpanel.createUI(); + curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, 0); + curTabpanel.activate(true); + } + gTab.addDataStatusListener(this); + } + } + else + { + //build embedded tab map + ADTabpanel fTabPanel = new ADTabpanel(); + GridField[] fields = gTab.getTableModel().getFields(); + for(int i = 0; i < fields.length; i++) + { + if (fields[i].getIncluded_Tab_ID() > 0) + { + includedMap.put(fields[i].getIncluded_Tab_ID(), fTabPanel); + } + } + + if (includedMap.containsKey(gTab.getAD_Tab_ID())) + { + includedMap.get(gTab.getAD_Tab_ID()).embed(ctx, curWindowNo, gridWindow, gTab.getAD_Tab_ID(), tabIndex, fTabPanel); + } + else + { + gTab.addDataStatusListener(this); + fTabPanel.init(this, curWindowNo, gTab, gridWindow); + adTab.addTab(gTab, fTabPanel); + if (tabIndex == 0) { + fTabPanel.createUI(); + curTabpanel = fTabPanel; + curTabpanel.query(m_onlyCurrentRows, m_onlyCurrentDays, 0); + curTabpanel.activate(true); + } + } + } + } + /** * Initial Query * @@ -623,37 +717,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To public void dataStatusChanged(DataStatusEvent e) { - //TODO: ignore non-ui thread event for now. + //ignore non-ui thread event for now. if (Executions.getCurrent() == null) return; - /* // update Navigation - boolean firstRow = e.isFirstRow(); - boolean lastRow = e.isLastRow(); - toolbar.enableFirstNavigation(!firstRow); - toolbar.enableLastNavigation(!lastRow); - - // update Change - boolean changed = e.isChanged() || e.isInserting(); - boolean readOnly = curTab.isReadOnly(); - boolean insertRecord = !readOnly; - if (insertRecord) - { - insertRecord = curTab.isInsertRecord(); - } - - toolbar.enabledNew(!changed && insertRecord); - toolbar.enableRefresh(!changed); - toolbar.enableDelete(!changed && !readOnly); - - if (readOnly && curTab.isAlwaysUpdateField()) - { - readOnly = false; - } - - lblRecords.setValue(e.getMessage()); - tabbox.evaluate(e);*/ - logger.info(e.getMessage()); String dbInfo = e.getMessage(); if (curTab != null && curTab.isQueryActive()) @@ -739,13 +806,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To toolbar.enableDeleteSelection(true); } - // Single-Multi -// aMulti.setPressed(!m_curGC.isSingleRow()); - // History (on first Tab only) if (isFirstTab()) { -// aHistory.setPressed(!curTab.isOnlyCurrentRows()); + toolbar.getButton("HistoryRecords").setPressed(!curTab.isOnlyCurrentRows()); } // Transaction info @@ -770,15 +834,14 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To if (canHaveAttachment) { toolbar.enableAttachment(true); - /*aAttachment.setPressed(m_curTab.hasAttachment()); - aChat.setEnabled(true); - aChat.setPressed(m_curTab.hasChat());*/ + toolbar.getButton("Attachment").setPressed(curTab.hasAttachment()); } else { toolbar.enableAttachment(false); -// aChat.setEnabled(false); } + + toolbar.getButton("Find").setPressed(curTab.isQueryActive()); // Lock Indicator /* if (m_isPersonalLock) { @@ -829,7 +892,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To newRecord = curTab.dataNew(false); if (newRecord) { - curTabpanel.editRecord(true); curTabpanel.dynamicDisplay(0); toolbar.enableChanges(false); toolbar.enableDelete(false); @@ -860,7 +922,6 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To newRecord = curTab.dataNew(true); if (newRecord) { - curTabpanel.editRecord(true); curTabpanel.dynamicDisplay(0); toolbar.enableChanges(false); toolbar.enableDelete(false); @@ -921,27 +982,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To curTab.dataIgnore(); curTab.dataRefresh(); curTabpanel.dynamicDisplay(0); - curTabpanel.editRecord(false); toolbar.enableIgnore(false); } } - /** - * @see ToolbarListener#onEdit() - */ - public void onEdit() - { - curTabpanel.editRecord(true); - toolbar.enableIgnore(true); - toolbar.enabledNew(false); - toolbar.enableCopy(false); - toolbar.enableDelete(false); - toolbar.enableNavigation(false); - toolbar.enableTabNavigation(false); - toolbar.enablePrint(true); - toolbar.enableReport(true); - } - /** * @see ToolbarListener#onSave() */ diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java index e1db1c6689..95c5501e88 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/IADTabpanel.java @@ -45,10 +45,5 @@ public interface IADTabpanel extends Component, Evaluatee { public void switchRowPresentation(); - public boolean isEditing(); - public void dynamicDisplay(int i); - - public void editRecord(boolean b); - }