From 15e178c110a2fcf857b1c6ce87669763c597a4a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Tak=C3=A1cs?= <93127072+PeterTakacs300@users.noreply.github.com> Date: Wed, 26 Jul 2023 15:35:05 +0200 Subject: [PATCH] IDEMPIERE-5803 - ESC Shortcut Closes Tab and Pop-up Window at Once (#1946) * IDEMPIERE-5803 - ESC Shortcut Closes Tab and Pop-up Window at Once - delay the execution of ON_CTRL_KEY after ON_CANCEL by adding echo: ON_CLOSE_WINDOW_SHORTCUT_EVENT - improve IDesktop by isCloseTabWithShortcut methods - the ON_CANCEL event sets isCloseTabWithShortcut to false - tab is closed after ON_CTRL_KEY if isCloseTabWithShortcut is true * IDEMPIERE-5803 - fix breaking Alt+X in InfoPanel - issue reported by Heng Sin * IDEMPIERE-5803 - fix breaking Alt+X in InfoPanel --- .../org/adempiere/webui/AdempiereWebUI.java | 6 +++++ .../org/adempiere/webui/ValuePreference.java | 8 ++++++ .../org/adempiere/webui/acct/WAcctViewer.java | 18 ++++++++----- .../webui/adwindow/ADWindowToolbar.java | 20 ++++++++------ .../adempiere/webui/apps/ProcessDialog.java | 20 +++++++++----- .../webui/apps/ProcessModalDialog.java | 8 ++++++ .../adempiere/webui/apps/form/WQuickForm.java | 7 +++++ .../org/adempiere/webui/apps/wf/WFPanel.java | 16 +++++++---- .../adempiere/webui/component/Messagebox.java | 8 ++++++ .../webui/desktop/AbstractDesktop.java | 11 ++++++++ .../org/adempiere/webui/desktop/IDesktop.java | 14 ++++++++++ .../org/adempiere/webui/grid/WQuickEntry.java | 8 +++++- .../src/org/adempiere/webui/panel/ADForm.java | 16 +++++++---- .../webui/panel/CustomizeGridViewPanel.java | 7 +++++ .../org/adempiere/webui/panel/InfoPanel.java | 20 +++++++++++--- .../adempiere/webui/panel/WAttachment.java | 9 ++++++- .../webui/panel/WProcessParameterForm.java | 9 +++++++ .../webui/panel/action/CSVImportAction.java | 8 ++++++ .../webui/panel/action/ExportAction.java | 8 ++++++ .../webui/panel/action/FileImportAction.java | 8 ++++++ .../adempiere/webui/window/FindWindow.java | 8 ++++++ .../adempiere/webui/window/InfoSchedule.java | 22 ++++++++++----- .../webui/window/WAccountDialog.java | 7 +++++ .../webui/window/WAssignmentDialog.java | 9 +++++++ .../src/org/adempiere/webui/window/WChat.java | 9 +++++++ .../webui/window/WCtxHelpSuggestion.java | 8 ++++++ .../adempiere/webui/window/WEMailDialog.java | 8 ++++++ .../webui/window/WFieldRecordInfo.java | 8 ++++++ .../webui/window/WFieldSuggestion.java | 8 ++++++ .../org/adempiere/webui/window/WGadgets.java | 7 +++++ .../adempiere/webui/window/WImageDialog.java | 8 ++++++ .../webui/window/WLocationDialog.java | 7 +++++ .../webui/window/WLocatorDialog.java | 8 ++++++ .../adempiere/webui/window/WMediaDialog.java | 8 ++++++ .../webui/window/WPAttributeDialog.java | 7 +++++ .../webui/window/WPAttributeInstance.java | 8 ++++++ .../org/adempiere/webui/window/WPostIt.java | 8 ++++++ .../adempiere/webui/window/WRecordInfo.java | 8 ++++++ .../webui/window/WReportExportDialog.java | 8 ++++++ .../webui/window/WReportUploadDialog.java | 8 ++++++ .../webui/window/WTextEditorDialog.java | 8 ++++++ .../adempiere/webui/window/ZkJRViewer.java | 15 ++++++++--- .../webui/window/ZkReportViewer.java | 27 ++++++++++++------- 43 files changed, 396 insertions(+), 55 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java index 995edae029..1ab74281c0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java @@ -148,6 +148,9 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb /** Login completed event */ private static final String ON_LOGIN_COMPLETED = "onLoginCompleted"; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); + /** * default constructor */ @@ -249,6 +252,9 @@ public class AdempiereWebUI extends Window implements EventListener, IWeb */ public void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); } /* (non-Javadoc) 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 d6a7cc9d4e..256b1ccea2 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 @@ -36,11 +36,13 @@ import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; import org.adempiere.webui.component.ZkCssHelper; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.window.Dialog; import org.compiere.model.GridField; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogMgt; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -256,6 +258,8 @@ public class ValuePreference extends Window implements EventListener private ConfirmPanel confirmPanel = new ConfirmPanel(true); private Button bDelete; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * is true when value preference for a field of process call by info window @@ -467,6 +471,10 @@ public class ValuePreference extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java index 6368bbff59..ae85105cb5 100755 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/acct/WAcctViewer.java @@ -244,6 +244,7 @@ public class WAcctViewer extends Window implements EventListener setAttribute(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT); setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_windowNo); // for closing the window with shortcut SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); AEnv.showWindow(this); } catch(Exception e) @@ -802,9 +803,16 @@ public class WAcctViewer extends Window implements EventListener } else if (e.getName().equals(Events.ON_CTRL_KEY)) { KeyEvent keyEvent = (KeyEvent) e; - if (LayoutUtils.isReallyVisible(this)) - this.onCtrlKeyEvent(keyEvent); + if (LayoutUtils.isReallyVisible(this)) + this.onCtrlKeyEvent(keyEvent); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(e.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_windowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_windowNo); + else + desktop.setCloseTabWithShortcut(true); + } } // onEvent /** @@ -1416,10 +1424,8 @@ public class WAcctViewer extends Window implements EventListener private void onCtrlKeyEvent(KeyEvent keyEvent) { if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (m_windowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(m_windowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java index a4cf5a147b..22fe19248b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/adwindow/ADWindowToolbar.java @@ -35,6 +35,7 @@ import org.adempiere.webui.component.Combobox; import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.ToolBarButton; +import org.adempiere.webui.desktop.IDesktop; import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.part.WindowContainer; import org.adempiere.webui.session.SessionManager; @@ -592,6 +593,10 @@ public class ADWindowToolbar extends ToolBar implements EventListener doOnClick(event); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(eventName)) { + if (windowNo > 0) + SessionManager.getAppDesktop().closeWindow(windowNo); + } } /** @@ -916,7 +921,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener { if ((keyEvent.getKeyCode() == VK_X)) { - closeWindow(keyEvent); + onCloseWithShortcut(keyEvent); } else { @@ -924,7 +929,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener } } else if (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing) { // ESC - closeWindow(keyEvent); + onCloseWithShortcut(keyEvent); } else if (!keyEvent.isAltKey() && keyEvent.isCtrlKey() && !keyEvent.isShiftKey()) { @@ -964,12 +969,9 @@ public class ADWindowToolbar extends ToolBar implements EventListener * Close Window * @param keyEvent */ - private void closeWindow(KeyEvent keyEvent) { - if (windowNo > 0) - { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(windowNo); - } + private void onCloseWithShortcut(KeyEvent keyEvent) { + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } /** @@ -1204,6 +1206,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener super.onPageDetached(page); try { SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); + removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } catch (Exception e) {} } @@ -1212,6 +1215,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener super.onPageAttached(newpage, oldpage); if (newpage != null) { SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java index 015646c52a..fc26b84d71 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessDialog.java @@ -172,6 +172,7 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene super.onPageAttached(newpage, oldpage); try { SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); Component parentTab = this.getParent(); if (parentTab != null && parentTab instanceof Tabpanel) { @@ -185,6 +186,7 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene super.onPageDetached(page); try { SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); + removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); SessionManager.getAppDesktop().unregisterWindow(m_WindowNo); } catch (Exception e) {} } @@ -235,9 +237,17 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene } } else if (event.getName().equals(Events.ON_CTRL_KEY)) { KeyEvent keyEvent = (KeyEvent) event; - if (LayoutUtils.isReallyVisible(this)) + if (LayoutUtils.isReallyVisible(this)) this.onCtrlKeyEvent(keyEvent); - } else { + } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_WindowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_WindowNo); + else + desktop.setCloseTabWithShortcut(true); + } + else { super.onEvent(event); } } @@ -266,10 +276,8 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene private void onCtrlKeyEvent(KeyEvent keyEvent) { if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (m_WindowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(m_WindowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java index 95ceb1dd61..d8a03ba2b8 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/ProcessModalDialog.java @@ -24,8 +24,10 @@ import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Window; import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.panel.ITabOnCloseHandler; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MPInstance; +import org.compiere.model.MSysConfig; import org.compiere.print.MPrintFormat; import org.compiere.process.ProcessInfo; import org.compiere.util.CLogger; @@ -72,6 +74,8 @@ public class ProcessModalDialog extends AbstractProcessDialog implements EventLi private ITabOnCloseHandler originalOnCloseHandler; private Tabpanel parentTabPanel; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @param WindowNo @@ -350,6 +354,10 @@ public class ProcessModalDialog extends AbstractProcessDialog implements EventLi * Handle ON_Click event from {@link #bCancel} */ private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + cancelProcess(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WQuickForm.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WQuickForm.java index 8955f65073..d72307ba5d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WQuickForm.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/form/WQuickForm.java @@ -39,6 +39,7 @@ import org.compiere.model.DataStatusEvent; import org.compiere.model.GridField; import org.compiere.model.GridTab; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkforge.keylistener.Keylistener; @@ -88,6 +89,8 @@ public class WQuickForm extends Window implements IQuickForm private int windowNo; private boolean stayInParent; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @param winContent @@ -419,6 +422,10 @@ public class WQuickForm extends Window implements IQuickForm { super.dispose(); + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + gridTab.setQuickForm(false); onIgnore(); gridTab.removeDataStatusListener(this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java index 9cff5d4387..4cdfa6b097 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/apps/wf/WFPanel.java @@ -81,6 +81,7 @@ public class WFPanel extends Borderlayout implements EventListener, IHelp m_WindowNo = SessionManager.getAppDesktop().registerWindow(this); setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo); // for closing the window with shortcut SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } // WFPanel /** Window No */ @@ -289,9 +290,16 @@ public class WFPanel extends Borderlayout implements EventListener, IHelp } else if (event.getName().equals(Events.ON_CTRL_KEY)) { KeyEvent keyEvent = (KeyEvent) event; - if (LayoutUtils.isReallyVisible(this)) + if (LayoutUtils.isReallyVisible(this)) this.onCtrlKeyEvent(keyEvent); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_WindowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_WindowNo); + else + desktop.setCloseTabWithShortcut(true); + } } private void start(MWFNode wfn) { @@ -318,10 +326,8 @@ public class WFPanel extends Borderlayout implements EventListener, IHelp private void onCtrlKeyEvent(KeyEvent keyEvent) { if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (m_WindowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(m_WindowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } } // WFPanel diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Messagebox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Messagebox.java index 9f611d6979..b2c81f4369 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Messagebox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Messagebox.java @@ -33,6 +33,7 @@ import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.model.MSysConfig; import org.compiere.model.SystemProperties; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -127,6 +128,9 @@ public class Messagebox extends Window implements EventListener /** Contains no symbols. */ public static final String NONE = null; + + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Default constructor @@ -560,6 +564,10 @@ public class Messagebox extends Window implements EventListener */ private void close() { try { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } catch (NullPointerException npe) { if (! (SessionManager.getSessionApplication() == null)) // IDEMPIERE-1937 - ignore when session was closed diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java index 388617740e..0986b96f96 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/AbstractDesktop.java @@ -45,6 +45,7 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop private String predefinedContextVariables; private boolean menuIsSOTrx; + private boolean isCloseTabWithShortcut = true; @SuppressWarnings("unused") private static final CLogger logger = CLogger.getCLogger(AbstractDesktop.class); @@ -402,4 +403,14 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop protected boolean isMenuSOTrx() { return this.menuIsSOTrx; } + + @Override + public boolean isCloseTabWithShortcut() { + return this.isCloseTabWithShortcut; + } + + @Override + public void setCloseTabWithShortcut(boolean isCloseTabWithShortcut) { + this.isCloseTabWithShortcut = isCloseTabWithShortcut; + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java index f21f9e55a6..e627c315ac 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/desktop/IDesktop.java @@ -39,6 +39,8 @@ public interface IDesktop extends UIPart { /** {@link EventQueue} name for activities (workflow activities, request, notice and unprocessed documents) */ public static final String ACTIVITIES_EVENT_QUEUE = "ActivitiesEventQueue"; public static final String ON_ACTIVITIES_CHANGED_EVENT = "onActivitiesChanged"; + /** Event when closing window/tab with shortcut */ + public static final String ON_CLOSE_WINDOW_SHORTCUT_EVENT = "onCloseWindowShortcut"; /** * @@ -279,4 +281,16 @@ public interface IDesktop extends UIPart { * render home tab */ public void renderHomeTab(); + + /** + * Is closing tab with shortcut allowed + * @return true if allowed + */ + public boolean isCloseTabWithShortcut(); + + /** + * Set if closing tab with shortcut is allowed + * @param isCloseTabWithShortcutAllowed + */ + public void setCloseTabWithShortcut(boolean isCloseTabWithShortcut); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java index 21abcd6884..3db7452a28 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/grid/WQuickEntry.java @@ -24,6 +24,7 @@ import java.util.logging.Level; import org.adempiere.webui.ClientInfo; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Label; +import org.adempiere.webui.desktop.IDesktop; import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WLocationEditor; import org.adempiere.webui.editor.WebEditorFactory; @@ -542,8 +543,13 @@ public class WQuickEntry extends AbstractWQuickEntry implements EventListener, IHe form.init(adFormID, name); form.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, form.getWindowNo()); // for closing the window with shortcut SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, form); + form.addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, form); return form; } else @@ -234,9 +235,16 @@ public abstract class ADForm extends Window implements EventListener, IHe } else if (event.getName().equals(Events.ON_CTRL_KEY)) { KeyEvent keyEvent = (KeyEvent) event; - if (LayoutUtils.isReallyVisible(this)) + if (LayoutUtils.isReallyVisible(this)) this.onCtrlKeyEvent(keyEvent); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_WindowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_WindowNo); + else + desktop.setCloseTabWithShortcut(true); + } } /** @@ -286,10 +294,8 @@ public abstract class ADForm extends Window implements EventListener, IHe private void onCtrlKeyEvent(KeyEvent keyEvent) { if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (m_WindowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(m_WindowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java index 4e7e27034b..3bba8a3e64 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/CustomizeGridViewPanel.java @@ -40,6 +40,7 @@ import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.SimpleListModel; import org.adempiere.webui.factory.ButtonFactory; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.window.Dialog; @@ -136,6 +137,8 @@ public class CustomizeGridViewPanel extends Panel private boolean uiCreated; private boolean m_saved = false; private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, true, false, false, false); + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Static Layout @@ -333,6 +336,10 @@ public class CustomizeGridViewPanel extends Panel * cancel form */ public void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + getParent().detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java index 0ca6dc220a..ec14837356 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/InfoPanel.java @@ -2431,6 +2431,13 @@ public abstract class InfoPanel extends Window implements EventListener, }else if (event.getName().equals(Events.ON_CANCEL) || (event.getTarget().equals(this) && event.getName().equals(Events.ON_CLOSE))){ onCancel(); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (p_WindowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(p_WindowNo); + else + desktop.setCloseTabWithShortcut(true); + } //when user push enter keyboard at input parameter field else { @@ -2442,6 +2449,10 @@ public abstract class InfoPanel extends Window implements EventListener, * handle cancel event */ protected void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_cancel = true; dispose(false); } @@ -2461,10 +2472,8 @@ public abstract class InfoPanel extends Window implements EventListener, // do nothing, let on_ok at infoWindo do, at this is too soon to get value from control, it's not bind } else if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (p_WindowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(p_WindowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } @@ -3264,12 +3273,15 @@ public abstract class InfoPanel extends Window implements EventListener, SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0, this); } SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } @Override public void onPageDetached(Page page) { super.onPageDetached(page); try { + removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); + if (SessionManager.getSessionApplication() != null && SessionManager.getSessionApplication().getKeylistener() != null) SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java index 6d16759f74..fcd40b77e0 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WAttachment.java @@ -45,6 +45,7 @@ import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.Window; import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.factory.ButtonFactory; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.window.Dialog; @@ -148,6 +149,9 @@ public class WAttachment extends Window implements EventListener private Progressmeter progress = new Progressmeter(0); private static List autoPreviewList; + + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); static { autoPreviewList = new ArrayList(); @@ -731,7 +735,10 @@ public class WAttachment extends Window implements EventListener } // onEvent - private void onCancel() { + private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); // Cancel dispose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WProcessParameterForm.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WProcessParameterForm.java index 184aaa2e90..08009a6fcd 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WProcessParameterForm.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/WProcessParameterForm.java @@ -26,12 +26,14 @@ import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.VerticalBox; import org.adempiere.webui.factory.ButtonFactory; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.GridTab; import org.compiere.model.MPInstancePara; import org.compiere.model.MProcessDrillRule; import org.compiere.model.MScheduler; +import org.compiere.model.MSysConfig; import org.compiere.process.ProcessInfo; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -70,6 +72,9 @@ public class WProcessParameterForm extends ADForm private ProcessParameterPanel parameterPanel; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); + private final static CLogger log = CLogger.getCLogger(WProcessParameterForm.class); public WProcessParameterForm(WProcessParameter wpp) { @@ -106,6 +111,10 @@ public class WProcessParameterForm extends ADForm } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.dispose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java index c76222dcd7..a854137e94 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/action/CSVImportAction.java @@ -53,11 +53,13 @@ import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; import org.adempiere.webui.event.DialogEvents; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ReaderInputStream; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.GridTab; import org.compiere.model.MImportTemplate; import org.compiere.model.MQuery; +import org.compiere.model.MSysConfig; import org.compiere.util.DB; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -92,6 +94,8 @@ public class CSVImportAction implements EventListener private Listbox fTemplates = new Listbox(); private Listbox fImportMode = new Listbox(); private InputStream m_file_istream = null; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @param panel @@ -245,6 +249,10 @@ public class CSVImportAction implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + winImportFile.onClose(); } 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 f7bb6f73f3..9448c69725 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 @@ -42,10 +42,12 @@ import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; import org.adempiere.webui.event.DialogEvents; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.window.Dialog; import org.compiere.model.GridTab; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.util.Env; import org.compiere.util.Msg; import org.zkoss.util.media.AMedia; @@ -81,6 +83,8 @@ public class ExportAction implements EventListener private Row childTabSelectionRow = null; private List chkSelectChildTabs = null; private IGridTabExporter exporter; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @param panel @@ -296,6 +300,10 @@ public class ExportAction implements EventListener * Close export file dialog */ private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + winExportFile.onClose(); } 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 73cf053819..6eddad4e7b 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 @@ -48,6 +48,7 @@ import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.event.DialogEvents; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ReaderInputStream; import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.window.Dialog; @@ -55,6 +56,7 @@ import org.compiere.model.GridTab; import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupInfo; +import org.compiere.model.MSysConfig; import org.compiere.util.Env; import org.compiere.util.Ini; import org.compiere.util.Msg; @@ -90,6 +92,8 @@ public class FileImportAction implements EventListener private Listbox fCharset = new Listbox(); private WTableDirEditor fImportMode; private InputStream m_file_istream = null; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @param panel @@ -257,6 +261,10 @@ public class FileImportAction implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + winImportFile.onClose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java index eefce8da4a..cd89c39174 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/FindWindow.java @@ -80,6 +80,7 @@ import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.panel.StatusBarPanel; import org.adempiere.webui.part.MultiTabPart; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.GridField; @@ -296,6 +297,9 @@ public class FindWindow extends Window implements EventListener, ValueCha /** Column name attribute set instance */ private static final String COLUMNNAME_M_AttributeSetInstance_ID = "M_AttributeSetInstance_ID"; + + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * FindWindow Constructor @@ -1965,6 +1969,10 @@ public class FindWindow extends Window implements EventListener, ValueCha * user cancellation, close dialog */ private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_isCancel = true; dispose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java index 0a13dd2cbf..d33de7316c 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/InfoSchedule.java @@ -178,6 +178,7 @@ public class InfoSchedule extends Window implements EventListener m_windowNo = SessionManager.getAppDesktop().registerWindow(this); setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_windowNo); // for closing the window with shortcut SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } // InfoSchedule @@ -501,13 +502,24 @@ public class InfoSchedule extends Window implements EventListener displayCalendar(); else if (event.getName().equals(Events.ON_CTRL_KEY)) { KeyEvent keyEvent = (KeyEvent) event; - if (LayoutUtils.isReallyVisible(this)) - this.onCtrlKeyEvent(keyEvent); + if (LayoutUtils.isReallyVisible(this)) + this.onCtrlKeyEvent(keyEvent); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_windowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_windowNo); + else + desktop.setCloseTabWithShortcut(true); + } // } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_cancel = true; dispose(); } @@ -692,10 +704,8 @@ public class InfoSchedule extends Window implements EventListener private void onCtrlKeyEvent(KeyEvent keyEvent) { if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (m_windowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(m_windowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } } // InfoSchedule diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java index 6165f0fa09..63f70b1c4d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAccountDialog.java @@ -55,6 +55,7 @@ import org.compiere.model.MAccountLookup; import org.compiere.model.MAcctSchema; import org.compiere.model.MAcctSchemaElement; import org.compiere.model.MQuery; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -90,6 +91,8 @@ public final class WAccountDialog extends Window private static final long serialVersionUID = 3041802296879719489L; private Callback m_callback; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Constructor @@ -791,6 +794,10 @@ public final class WAccountDialog extends Window } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_changed = false; dispose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAssignmentDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAssignmentDialog.java index 1a7f81d89e..b63622ab4e 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAssignmentDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WAssignmentDialog.java @@ -44,10 +44,12 @@ import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Timebox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MResourceAssignment; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.model.MUOMConversion; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -76,6 +78,9 @@ public class WAssignmentDialog extends Window implements EventListener * */ private static final long serialVersionUID = -1762339564864115852L; + + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Assignment Dialog. @@ -424,6 +429,10 @@ public class WAssignmentDialog extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_cancel = true; detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java index ccc5dbeef0..d598426768 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WChat.java @@ -29,10 +29,12 @@ import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; import org.adempiere.webui.event.DialogEvents; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MChat; import org.compiere.model.MChatEntry; +import org.compiere.model.MSysConfig; import org.compiere.model.MUser; import org.compiere.util.CLogger; import org.compiere.util.DisplayType; @@ -70,6 +72,9 @@ public class WChat extends Window implements EventListener, DialogEvents private static final String USER_LABEL_STYLE = "font-weight: bold"; private static final String TIME_LABEL_STYLE = "font-size:xx-small;color:gray;margin-left:20px"; + + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Constructor. @@ -383,6 +388,10 @@ public class WChat extends Window implements EventListener, DialogEvents } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } } // WChat diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WCtxHelpSuggestion.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WCtxHelpSuggestion.java index 36f1fc5b0b..6f3ea60aa2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WCtxHelpSuggestion.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WCtxHelpSuggestion.java @@ -8,6 +8,7 @@ import java.util.List; import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.compiere.model.I_AD_CtxHelpMsg; import org.compiere.model.MCtxHelp; import org.compiere.model.MCtxHelpMsg; @@ -15,6 +16,7 @@ import org.compiere.model.MCtxHelpSuggestion; import org.compiere.model.MForm; import org.compiere.model.MInfoWindow; import org.compiere.model.MProcess; +import org.compiere.model.MSysConfig; import org.compiere.model.MTab; import org.compiere.model.MTable; import org.compiere.model.MTask; @@ -62,6 +64,8 @@ public class WCtxHelpSuggestion extends Window implements EventListener { private String baseContent; private String translatedContent; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * default constructor @@ -172,6 +176,10 @@ public class WCtxHelpSuggestion extends Window implements EventListener { } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java index a1d25b563b..09acf5af10 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WEMailDialog.java @@ -53,6 +53,7 @@ import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeListener; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.Lookup; @@ -61,6 +62,7 @@ import org.compiere.model.MAttachmentEntry; import org.compiere.model.MClient; import org.compiere.model.MLookupFactory; import org.compiere.model.MMailText; +import org.compiere.model.MSysConfig; import org.compiere.model.MUser; import org.compiere.model.MUserMail; import org.compiere.model.PrintInfo; @@ -270,6 +272,8 @@ public class WEMailDialog extends Window implements EventListener, ValueC private Button bAddDefaultMailText; private Div attachmentBox; private Checkbox isAcknowledgmentReceipt = new Checkbox(); + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); @Override public void onPageAttached(Page newpage, Page oldpage) { @@ -646,6 +650,10 @@ public class WEMailDialog extends Window implements EventListener, ValueC } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + onClose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldRecordInfo.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldRecordInfo.java index 227d9f05c7..0f1295a4f7 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldRecordInfo.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldRecordInfo.java @@ -30,6 +30,7 @@ import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.SimpleListModel; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WEditorPopupMenu; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.GridField; @@ -38,6 +39,7 @@ import org.compiere.model.MColumn; import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.model.MTable; import org.compiere.model.MUser; import org.compiere.util.CLogger; @@ -72,6 +74,8 @@ public class WFieldRecordInfo extends Window implements EventListener private int AD_Column_ID; private int Record_ID; private String Record_UU; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Record Info @@ -377,6 +381,10 @@ public class WFieldRecordInfo extends Window implements EventListener private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldSuggestion.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldSuggestion.java index 5f3fb7a482..4422a5e173 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldSuggestion.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WFieldSuggestion.java @@ -11,9 +11,11 @@ import org.adempiere.webui.component.GridFactory; import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MField; import org.compiere.model.MFieldSuggestion; +import org.compiere.model.MSysConfig; import org.compiere.model.PO; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -46,6 +48,8 @@ public class WFieldSuggestion extends Window implements EventListener { private Textbox descriptionTextbox; private Textbox helpTextbox; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * default constructor @@ -139,6 +143,10 @@ public class WFieldSuggestion extends Window implements EventListener { } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WGadgets.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WGadgets.java index 2729d9395d..b56f765356 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WGadgets.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WGadgets.java @@ -41,6 +41,7 @@ import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MDashboardContent; import org.compiere.model.MDashboardPreference; +import org.compiere.model.MSysConfig; import org.compiere.model.Query; import org.compiere.util.DB; import org.compiere.util.Env; @@ -84,6 +85,8 @@ public class WGadgets extends Window implements EventListener{ protected ArrayList noItems =new ArrayList(); protected Map dirtyList = new LinkedHashMap(); + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @@ -126,6 +129,10 @@ public class WGadgets extends Window implements EventListener{ } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java index aaa26287e4..757b9ffbdd 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WImageDialog.java @@ -31,10 +31,12 @@ import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.apache.commons.codec.binary.Base64; import org.compiere.model.MImage; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.MimeType; @@ -132,6 +134,8 @@ public class WImageDialog extends Window implements EventListener private Div captureDiv; private String defaultNameForCaptureImage = "CapturedImage"; private Button cancelCaptureButton; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); private static List autoPreviewList; @@ -327,6 +331,10 @@ public class WImageDialog extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + cancel = true; detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java index c92bc4efa8..6503dfd795 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocationDialog.java @@ -45,6 +45,7 @@ import org.adempiere.webui.component.Row; import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.GridField; @@ -155,6 +156,8 @@ public class WLocationDialog extends Window implements EventListener private GridField m_GridField = null; private boolean onSaveError = false; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); //END public WLocationDialog(String title, MLocation location) @@ -931,6 +934,10 @@ public class WLocationDialog extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_change = false; this.dispose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java index 41b8d87c36..f3036c90f1 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WLocatorDialog.java @@ -42,12 +42,14 @@ import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; import org.adempiere.webui.editor.WTableDirEditor; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MLocator; import org.compiere.model.MLocatorLookup; import org.compiere.model.MLocatorType; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.util.AdempiereUserError; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -124,6 +126,8 @@ public class WLocatorDialog extends Window implements EventListener private boolean m_change; private String title; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); private static final CLogger log = CLogger.getCLogger(WLocatorDialog.class); @@ -695,6 +699,10 @@ public class WLocatorDialog extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_change = false; this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java index b43a5b9722..77ef16eb27 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WMediaDialog.java @@ -26,8 +26,10 @@ import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Window; import org.adempiere.webui.component.ZkCssHelper; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -83,6 +85,8 @@ public class WMediaDialog extends Window implements EventListener private Hbox confirmPanel = new Hbox(); private boolean m_cancel; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Constructor. @@ -343,6 +347,10 @@ public class WMediaDialog extends Window implements EventListener } // onEvent private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_cancel = true; dispose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java index 95f8e6e5e3..15cb12f5d6 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeDialog.java @@ -67,6 +67,7 @@ import org.compiere.model.MLotCtl; import org.compiere.model.MQuery; import org.compiere.model.MRole; import org.compiere.model.MSerNoCtl; +import org.compiere.model.MSysConfig; import org.compiere.model.X_M_MovementLine; import org.compiere.util.CLogger; import org.compiere.util.DB; @@ -211,6 +212,8 @@ public class WPAttributeDialog extends Window implements EventListener protected ConfirmPanel confirmPanel = new ConfirmPanel (true); protected String m_columnName = null; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * Layout @@ -839,6 +842,10 @@ public class WPAttributeDialog extends Window implements EventListener } // actionPerformed protected void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_changed = false; m_M_AttributeSetInstance_ID = 0; m_M_Locator_ID = 0; diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java index c195c01f3f..2cbef58be2 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPAttributeInstance.java @@ -27,10 +27,12 @@ import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.WListbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.IDColumn; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.DB; import org.compiere.util.Env; @@ -133,6 +135,8 @@ public class WPAttributeInstance extends Window implements EventListener private int m_M_AttributeSetInstance_ID = -1; private String m_M_AttributeSetInstanceName = null; private String m_sql; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** Logger */ private static final CLogger log = CLogger.getCLogger(WPAttributeInstance.class); @@ -323,6 +327,10 @@ public class WPAttributeInstance extends Window implements EventListener } // actionPerformed private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + m_M_AttributeSetInstance_ID = -1; m_M_AttributeSetInstanceName = null; detach(); diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPostIt.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPostIt.java index cc121902eb..ea30cf1948 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPostIt.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WPostIt.java @@ -26,7 +26,9 @@ import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.VerticalBox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.compiere.model.MPostIt; +import org.compiere.model.MSysConfig; import org.compiere.util.Env; import org.compiere.util.Language; import org.zkforge.ckez.CKeditor; @@ -58,6 +60,8 @@ public class WPostIt extends Window implements EventListener{ private String created; private String updated; private MPostIt m_postIt; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @param title @@ -208,6 +212,10 @@ public class WPostIt extends Window implements EventListener{ } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java index 33bcc4ca59..d4d1e0b7a9 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WRecordInfo.java @@ -33,6 +33,7 @@ import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.SimpleListModel; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.DataStatusEvent; @@ -44,6 +45,7 @@ import org.compiere.model.MColumn; import org.compiere.model.MLookup; import org.compiere.model.MLookupFactory; import org.compiere.model.MRole; +import org.compiere.model.MSysConfig; import org.compiere.model.MTable; import org.compiere.model.MUser; import org.compiere.model.PO; @@ -150,6 +152,8 @@ public class WRecordInfo extends Window implements EventListener private Toolbarbutton m_permalink = new Toolbarbutton(); /** Copy Select */ private Toolbarbutton m_copySelect = new Toolbarbutton(); + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** Date Time Format */ private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat @@ -569,6 +573,10 @@ public class WRecordInfo extends Window implements EventListener private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + this.detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportExportDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportExportDialog.java index 51eeeea87a..f43aecf747 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportExportDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportExportDialog.java @@ -33,7 +33,9 @@ import org.adempiere.webui.component.Label; import org.adempiere.webui.component.ListItem; import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -59,6 +61,8 @@ public class WReportExportDialog extends Window implements EventListener private Listbox cboType = new Listbox(); private ConfirmPanel confirmPanel = new ConfirmPanel(true); private IReportViewerExportSource viewer; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** Logger */ private static final CLogger log = CLogger.getCLogger(WReportExportDialog.class); @@ -132,6 +136,10 @@ public class WReportExportDialog extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + onClose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportUploadDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportUploadDialog.java index a18b26d7f4..1c12fcc949 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportUploadDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WReportUploadDialog.java @@ -40,9 +40,11 @@ import org.adempiere.webui.component.ListItem; import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Window; import org.adempiere.webui.report.LinkWindow; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.util.ReaderInputStream; import org.adempiere.webui.util.ZKUpdateUtil; import org.compiere.model.MAuthorizationAccount; +import org.compiere.model.MSysConfig; import org.compiere.util.CLogger; import org.compiere.util.Env; import org.compiere.util.Msg; @@ -69,6 +71,8 @@ public class WReportUploadDialog extends Window implements EventListener private Listbox cboActions = new Listbox(); private ConfirmPanel confirmPanel = new ConfirmPanel(true); private IReportViewerExportSource viewer; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** Logger */ private static final CLogger log = CLogger.getCLogger(WReportUploadDialog.class); @@ -168,6 +172,10 @@ public class WReportUploadDialog extends Window implements EventListener } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + onClose(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java index 69109748bd..7d93ba272d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/WTextEditorDialog.java @@ -26,8 +26,10 @@ import org.adempiere.webui.component.Tabpanels; import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Window; +import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.util.ZKUpdateUtil; +import org.compiere.model.MSysConfig; import org.compiere.util.Env; import org.compiere.util.Language; import org.compiere.util.Msg; @@ -65,6 +67,8 @@ public class WTextEditorDialog extends Window implements EventListener{ private Label status; private Tab htmlTab; private boolean isShowHTMLTab = true; + /* SysConfig USE_ESC_FOR_TAB_CLOSING */ + private boolean isUseEscForTabClosing = MSysConfig.getBooleanValue(MSysConfig.USE_ESC_FOR_TAB_CLOSING, false, Env.getAD_Client_ID(Env.getCtx())); /** * @@ -284,6 +288,10 @@ public class WTextEditorDialog extends Window implements EventListener{ } private void onCancel() { + // do not allow to close tab for Events.ON_CTRL_KEY event + if(isUseEscForTabClosing) + SessionManager.getAppDesktop().setCloseTabWithShortcut(false); + cancelled = true; detach(); } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java index 64c273a151..d224618e74 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkJRViewer.java @@ -173,6 +173,7 @@ public class ZkJRViewer extends Window implements EventListener, ITabOnCl super.onPageAttached(newpage, oldpage); try { SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } catch (Exception e) {} } @@ -181,6 +182,7 @@ public class ZkJRViewer extends Window implements EventListener, ITabOnCl super.onPageDetached(page); try { SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); + removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } catch (Exception e) {} } @@ -659,15 +661,20 @@ public class ZkJRViewer extends Window implements EventListener, ITabOnCl if (LayoutUtils.isReallyVisible(this)) this.onCtrlKeyEvent(keyEvent); } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_WindowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_WindowNo); + else + desktop.setCloseTabWithShortcut(true); + } } private void onCtrlKeyEvent(KeyEvent keyEvent) { if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC - if (m_WindowNo > 0) { - keyEvent.stopPropagation(); - SessionManager.getAppDesktop().closeWindow(m_WindowNo); - } + keyEvent.stopPropagation(); + Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this)); } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java index 2647b51028..f9457ce943 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/ZkReportViewer.java @@ -414,6 +414,7 @@ public class ZkReportViewer extends Window implements EventListener, IRep init(); dynInit(); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); + addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } catch(Exception e) { @@ -429,6 +430,7 @@ public class ZkReportViewer extends Window implements EventListener, IRep super.onPageDetached(page); try { SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); + removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this); } catch (Exception e) {} cleanUp(); } @@ -1173,21 +1175,28 @@ public class ZkReportViewer extends Window implements EventListener, IRep onRenderReportEvent(); } else if (event.getName().equals(Events.ON_CTRL_KEY)) { KeyEvent keyEvent = (KeyEvent) event; - if (LayoutUtils.isReallyVisible(this)) + if (LayoutUtils.isReallyVisible(this)) this.onCtrlKeyEvent(keyEvent); } else if (event.getTarget() instanceof ProcessModalDialog) { - if(DialogEvents.ON_WINDOW_CLOSE.equals(event.getName())) - { - hideBusyMask(); - ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget(); - if (dialog.isCancel()) + if(DialogEvents.ON_WINDOW_CLOSE.equals(event.getName())) { - if (getDesktop() != null) - clearTabOnCloseHandler(); + hideBusyMask(); + ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget(); + if (dialog.isCancel()) + { + if (getDesktop() != null) + clearTabOnCloseHandler(); + } } - } + } + else if(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT.equals(event.getName())) { + IDesktop desktop = SessionManager.getAppDesktop(); + if (m_WindowNo > 0 && desktop.isCloseTabWithShortcut()) + desktop.closeWindow(m_WindowNo); + else + desktop.setCloseTabWithShortcut(true); } }