From b253e2cdf698c9514b9474a3bd13e6a3fa27e2a1 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Wed, 27 Mar 2013 16:21:44 +0800 Subject: [PATCH] IDEMPIERE-801 Tab body mask doesn't block focus. --- .../org/adempiere/webui/ValuePreference.java | 4 +- .../adwindow/AbstractADWindowContent.java | 52 ++++++++++++------- .../adempiere/webui/editor/WBinaryEditor.java | 4 +- .../adempiere/webui/editor/WStringEditor.java | 2 +- .../webui/panel/action/ExportAction.java | 4 +- .../webui/panel/action/FileImportAction.java | 4 +- org.adempiere.ui.zk/js/window.js | 35 +++++++++++++ 7 files changed, 76 insertions(+), 29 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ValuePreference.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ValuePreference.java index 60b9c53734..7cf9b50d55 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ValuePreference.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/ValuePreference.java @@ -219,10 +219,10 @@ public class ValuePreference extends Window implements EventListener this.setClosable(true); adwindowContent = findADWindowContent(ref); - if (adwindowContent != null) { - adwindowContent.showBusyMask(); + if (adwindowContent != null) { ZkCssHelper.appendStyle(this, "position: absolute;"); adwindowContent.getComponent().getParent().appendChild(this); + adwindowContent.showBusyMask(this); LayoutUtils.openOverlappedWindow(ref, this, "after_start"); } else { AEnv.showCenterScreen(this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java index 401ad97383..c1b27ac7d6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/AbstractADWindowContent.java @@ -104,6 +104,7 @@ import org.compiere.util.Env; import org.compiere.util.Msg; import org.compiere.util.Util; import org.compiere.util.WebDoc; +import org.zkoss.zk.au.out.AuScript; import org.zkoss.zk.ui.AbstractComponent; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.Executions; @@ -908,8 +909,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements hideBusyMask(); } }); - showBusyMask(); getComponent().getParent().appendChild(win); + showBusyMask(win); LayoutUtils.openOverlappedWindow(getComponent(), win, "middle_center"); } @@ -951,8 +952,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements focusToActivePanel(); } }); - showBusyMask(); - getComponent().getParent().appendChild(chat); + getComponent().getParent().appendChild(chat); + showBusyMask(chat); LayoutUtils.openOverlappedWindow(getComponent(), chat, "middle_center"); chat.showWindow(); } @@ -1726,8 +1727,8 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements }); } - showBusyMask(); - getComponent().getParent().appendChild(findWindow); + getComponent().getParent().appendChild(findWindow); + showBusyMask(findWindow); LayoutUtils.openEmbeddedWindow(toolbar, findWindow, "after_start"); } @@ -2190,9 +2191,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements hideBusyMask(); focusToActivePanel(); } - }); - showBusyMask(); + }); getComponent().getParent().appendChild(messagePanel); + showBusyMask(messagePanel); LayoutUtils.openOverlappedWindow(getComponent(), messagePanel, "middle_center"); } // @@ -2223,9 +2224,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements ProcessModalDialog dialog = new ProcessModalDialog(AbstractADWindowContent.this, getWindowNo(), AD_Process_ID,table_ID, record_ID, true); if (dialog.isValid()) { dialog.setWidth("500px"); - dialog.setBorder("normal"); - showBusyMask(); + dialog.setBorder("normal"); getComponent().getParent().appendChild(dialog); + showBusyMask(dialog); LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center"); dialog.focus(); } @@ -2474,9 +2475,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements boolean isProcessMandatory = true; executeButtonProcess(wButton, startWOasking, table_ID, recordIdParam, isProcessMandatory); } - }); - showBusyMask(); + }); getComponent().getParent().appendChild(win); + showBusyMask(win); LayoutUtils.openOverlappedWindow(getComponent(), win, "middle_center"); win.focus(); return; @@ -2506,9 +2507,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements window.setZindex(1000); window.setMaximizable(true); window.setSizable(true); - ZkCssHelper.appendStyle(window, "position: absolute; "); - showBusyMask(); + ZkCssHelper.appendStyle(window, "position: absolute; "); getComponent().getParent().appendChild(window); + showBusyMask(window); cf.showWindow(); LayoutUtils.openOverlappedWindow(getComponent(), window, "middle_center"); window.focus(); @@ -2601,11 +2602,22 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements public void hideBusyMask() { if (mask != null && mask.getParent() != null) { mask.detach(); + StringBuilder script = new StringBuilder("var w=zk.Widget.$('#"); + script.append(getComponent().getParent().getUuid()).append("');w.busy=false;"); + Clients.response(new AuScript(script.toString())); } } - public void showBusyMask() { + public void showBusyMask(Window window) { getComponent().getParent().appendChild(getMask()); + StringBuilder script = new StringBuilder("var w=zk.Widget.$('#"); + script.append(getComponent().getParent().getUuid()).append("');"); + if (window != null) { + script.append("var d=zk.Widget.$('#").append(window.getUuid()).append("');w.busy=d;"); + } else { + script.append("w.busy=true;"); + } + Clients.response(new AuScript(script.toString())); } private void executeButtonProcess(final IProcessButton wButton, @@ -2677,7 +2689,7 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements onRefresh(true, false); } }); - showBusyMask(); + showBusyMask(form); LayoutUtils.openOverlappedWindow(getComponent(), form, "middle_center"); form.focus(); } @@ -2692,9 +2704,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements if (dialog.isValid()) { dialog.setWidth("500px"); - dialog.setBorder("normal"); - showBusyMask(); + dialog.setBorder("normal"); getComponent().getParent().appendChild(dialog); + showBusyMask(dialog); LayoutUtils.openOverlappedWindow(getComponent(), dialog, "middle_center"); dialog.focus(); } @@ -2842,9 +2854,9 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements public void onEvent(Event event) throws Exception { hideBusyMask(); } - }); - showBusyMask(); - getComponent().getParent().appendChild(dialog); + }); + getComponent().getParent().appendChild(dialog); + showBusyMask(dialog); LayoutUtils.openOverlappedWindow(this.getComponent(),dialog,"middle_center"); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java index cf6145671a..f402f84234 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WBinaryEditor.java @@ -162,9 +162,9 @@ public class WBinaryEditor extends WEditor }); adwindow = ADWindow.findADWindow(getComponent()); if (adwindow != null) { - ADWindowContent content = adwindow.getADWindowContent(); - content.showBusyMask(); + ADWindowContent content = adwindow.getADWindowContent(); content.getComponent().getParent().appendChild(dialog); + content.showBusyMask(dialog); LayoutUtils.openOverlappedWindow(content.getComponent().getParent(), dialog, "middle_center"); } else { AEnv.showWindow(dialog); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java index 4b89fdfac6..dc9bbebcb0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/editor/WStringEditor.java @@ -248,7 +248,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener if (adwindowContent != null) { adwindowContent.getComponent().getParent().appendChild(dialog); - adwindowContent.showBusyMask(); + adwindowContent.showBusyMask(dialog); LayoutUtils.openOverlappedWindow(adwindowContent.getComponent().getParent(), dialog, "middle_center"); } else diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java index c511151682..9e31f8303c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/ExportAction.java @@ -133,9 +133,9 @@ public class ExportAction implements EventListener vb.appendChild(confirmPanel); confirmPanel.addActionListener(this); } - - panel.showBusyMask(); + panel.getComponent().getParent().appendChild(winExportFile); + panel.showBusyMask(winExportFile); LayoutUtils.openOverlappedWindow(panel.getComponent(), winExportFile, "middle_center"); winExportFile.addEventListener(DialogEvents.ON_WINDOW_CLOSE, this); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java index 50894dc2f2..1e6aee95fb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/FileImportAction.java @@ -195,9 +195,9 @@ public class FileImportAction implements EventListener vb.appendChild(confirmPanel); confirmPanel.addActionListener(this); } - - panel.showBusyMask(); + panel.getComponent().getParent().appendChild(winImportFile); + panel.showBusyMask(winImportFile); LayoutUtils.openOverlappedWindow(panel.getComponent(), winImportFile, "middle_center"); winImportFile.addEventListener(DialogEvents.ON_WINDOW_CLOSE, this); } diff --git a/org.adempiere.ui.zk/js/window.js b/org.adempiere.ui.zk/js/window.js index baaabad1d6..b6bc23dd7c 100644 --- a/org.adempiere.ui.zk/js/window.js +++ b/org.adempiere.ui.zk/js/window.js @@ -3,3 +3,38 @@ function _idempiere_popup_window(refid, windowid, position) { var window = zk(windowid); window.position(ref.$n(), position); } + +zk.override(zk.Widget.prototype, "canActivate", + function () { + var b = this.$canActivate.apply(this, arguments); + if (b) { + if (zk.currentModal) { + return true; + } + var wgt = this; + while (wgt) { + if (wgt.busy) { + if (wgt.busy.className == 'zul.wnd.Window') { + if (zUtl.isAncestor(wgt.busy, this)) { + return true; + } else { + wgt.busy.focus(0); + return false; + } + } else { + jq.focusOut(); + } + return false; + } + if (wgt.className == 'zul.wnd.Window') { + if (wgt.getMode() == 'overlapped') { + return true; + } + } + wgt = wgt.parent; + } + return true; + } else { + return false; + } + });