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
This commit is contained in:
Peter Takács 2023-07-26 15:35:05 +02:00 committed by GitHub
parent a86e23932a
commit 15e178c110
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 396 additions and 55 deletions

View File

@ -148,6 +148,9 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, 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<Event>, IWeb
*/
public void onCancel()
{
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
}
/* (non-Javadoc)

View File

@ -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<Event>
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<Event>
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach();
}

View File

@ -244,6 +244,7 @@ public class WAcctViewer extends Window implements EventListener<Event>
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<Event>
}
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<Event>
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));
}
}
}

View File

@ -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<Event>
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<Event>
{
if ((keyEvent.getKeyCode() == VK_X))
{
closeWindow(keyEvent);
onCloseWithShortcut(keyEvent);
}
else
{
@ -924,7 +929,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener<Event>
}
}
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<Event>
* 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<Event>
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<Event>
super.onPageAttached(newpage, oldpage);
if (newpage != null) {
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
}
}

View File

@ -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));
}
}

View File

@ -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();
}

View File

@ -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);

View File

@ -81,6 +81,7 @@ public class WFPanel extends Borderlayout implements EventListener<Event>, 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<Event>, 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<Event>, 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

View File

@ -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;
@ -128,6 +129,9 @@ public class Messagebox extends Window implements EventListener<Event>
/** 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<Event>
*/
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

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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<Ev
@Override
public void detach() {
super.detach();
IDesktop desktop = SessionManager.getAppDesktop();
// do not allow to close tab for Events.ON_CTRL_KEY event
desktop.setCloseTabWithShortcut(false);
if(m_WindowNo!=0)
SessionManager.getAppDesktop().unregisterWindow(m_WindowNo);
desktop.unregisterWindow(m_WindowNo);
}
public void valueChange(ValueChangeEvent evt)

View File

@ -215,6 +215,7 @@ public abstract class ADForm extends Window implements EventListener<Event>, 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<Event>, 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<Event>, 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));
}
}
}

View File

@ -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();
}

View File

@ -2431,6 +2431,13 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
}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<Event>,
* 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<Event>,
// 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<Event>,
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);

View File

@ -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;
@ -149,6 +150,9 @@ public class WAttachment extends Window implements EventListener<Event>
private static List<String> 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<String>();
autoPreviewList.add("image/jpeg");
@ -732,6 +736,9 @@ public class WAttachment extends Window implements EventListener<Event>
} // onEvent
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
// Cancel
dispose();
}

View File

@ -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();
}

View File

@ -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<Event>
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<Event>
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
winImportFile.onClose();
}

View File

@ -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<Event>
private Row childTabSelectionRow = null;
private List<Checkbox> 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<Event>
* 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();
}

View File

@ -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<Event>
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<Event>
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
winImportFile.onClose();
}

View File

@ -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;
@ -297,6 +298,9 @@ public class FindWindow extends Window implements EventListener<Event>, 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
* @param targetWindowNo targetWindowNo
@ -1965,6 +1969,10 @@ public class FindWindow extends Window implements EventListener<Event>, 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();
}

View File

@ -178,6 +178,7 @@ public class InfoSchedule extends Window implements EventListener<Event>
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<Event>
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<Event>
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

View File

@ -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<Integer> 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();
}

View File

@ -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;
@ -77,6 +79,9 @@ public class WAssignmentDialog extends Window implements EventListener<Event>
*/
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.
* <pre>
@ -424,6 +429,10 @@ public class WAssignmentDialog extends Window implements EventListener<Event>
}
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();
}

View File

@ -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;
@ -71,6 +73,9 @@ public class WChat extends Window implements EventListener<Event>, 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.
* loads Chat, if ID &lt;&gt; 0
@ -383,6 +388,10 @@ public class WChat extends Window implements EventListener<Event>, 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

View File

@ -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<Event> {
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<Event> {
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach();
}

View File

@ -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<Event>, 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<Event>, ValueC
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
onClose();
}

View File

@ -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<Event>
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<Event>
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach();
}

View File

@ -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<Event> {
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<Event> {
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach();
}

View File

@ -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<Event>{
protected ArrayList<MDashboardContent> noItems =new ArrayList<MDashboardContent>();
protected Map<Integer, MDashboardPreference> dirtyList = new LinkedHashMap<Integer, MDashboardPreference>();
/* 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<Event>{
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach();
}

View File

@ -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<Event>
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<String> autoPreviewList;
@ -327,6 +331,10 @@ public class WImageDialog extends Window implements EventListener<Event>
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
cancel = true;
detach();
}

View File

@ -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<Event>
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<Event>
}
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();
}

View File

@ -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<Event>
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<Event>
}
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();
}

View File

@ -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<Event>
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<Event>
} // 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();
}

View File

@ -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<Event>
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<Event>
} // 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;

View File

@ -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<Event>
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<Event>
} // 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();

View File

@ -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<Event>{
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<Event>{
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
detach();
}

View File

@ -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<Event>
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<Event>
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach();
}

View File

@ -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<Event>
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<Event>
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
onClose();
}

View File

@ -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<Event>
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<Event>
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
onClose();
}

View File

@ -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<Event>{
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<Event>{
}
private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
cancelled = true;
detach();
}

View File

@ -173,6 +173,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, 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<Event>, 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<Event>, 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));
}
}

View File

@ -414,6 +414,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, 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<Event>, 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<Event>, 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);
}
}