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 */ /** Login completed event */
private static final String ON_LOGIN_COMPLETED = "onLoginCompleted"; 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 * default constructor
*/ */
@ -249,6 +252,9 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
*/ */
public void onCancel() public void onCancel()
{ {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
} }
/* (non-Javadoc) /* (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.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.component.ZkCssHelper; import org.adempiere.webui.component.ZkCssHelper;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogMgt; import org.compiere.util.CLogMgt;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -256,6 +258,8 @@ public class ValuePreference extends Window implements EventListener<Event>
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private Button bDelete; 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 * 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() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); 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(Window.INSERT_POSITION_KEY, Window.INSERT_NEXT);
setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_windowNo); // for closing the window with shortcut setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_windowNo); // for closing the window with shortcut
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
AEnv.showWindow(this); AEnv.showWindow(this);
} }
catch(Exception e) catch(Exception e)
@ -802,9 +803,16 @@ public class WAcctViewer extends Window implements EventListener<Event>
} }
else if (e.getName().equals(Events.ON_CTRL_KEY)) { else if (e.getName().equals(Events.ON_CTRL_KEY)) {
KeyEvent keyEvent = (KeyEvent) e; KeyEvent keyEvent = (KeyEvent) e;
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); 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 } // onEvent
/** /**
@ -1416,10 +1424,8 @@ public class WAcctViewer extends Window implements EventListener<Event>
private void onCtrlKeyEvent(KeyEvent keyEvent) { private void onCtrlKeyEvent(KeyEvent keyEvent) {
if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (m_windowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(m_windowNo);
}
} }
} }
} }

View File

@ -35,6 +35,7 @@ import org.adempiere.webui.component.Combobox;
import org.adempiere.webui.component.Tabpanel; import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBar; import org.adempiere.webui.component.ToolBar;
import org.adempiere.webui.component.ToolBarButton; import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.desktop.IDesktop;
import org.adempiere.webui.event.ToolbarListener; import org.adempiere.webui.event.ToolbarListener;
import org.adempiere.webui.part.WindowContainer; import org.adempiere.webui.part.WindowContainer;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
@ -592,6 +593,10 @@ public class ADWindowToolbar extends ToolBar implements EventListener<Event>
doOnClick(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)) if ((keyEvent.getKeyCode() == VK_X))
{ {
closeWindow(keyEvent); onCloseWithShortcut(keyEvent);
} }
else else
{ {
@ -924,7 +929,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener<Event>
} }
} }
else if (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing) { // ESC else if (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing) { // ESC
closeWindow(keyEvent); onCloseWithShortcut(keyEvent);
} }
else if (!keyEvent.isAltKey() && keyEvent.isCtrlKey() && !keyEvent.isShiftKey()) else if (!keyEvent.isAltKey() && keyEvent.isCtrlKey() && !keyEvent.isShiftKey())
{ {
@ -964,12 +969,9 @@ public class ADWindowToolbar extends ToolBar implements EventListener<Event>
* Close Window * Close Window
* @param keyEvent * @param keyEvent
*/ */
private void closeWindow(KeyEvent keyEvent) { private void onCloseWithShortcut(KeyEvent keyEvent) {
if (windowNo > 0) keyEvent.stopPropagation();
{ Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
keyEvent.stopPropagation();
SessionManager.getAppDesktop().closeWindow(windowNo);
}
} }
/** /**
@ -1204,6 +1206,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener<Event>
super.onPageDetached(page); super.onPageDetached(page);
try { try {
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} catch (Exception e) {} } catch (Exception e) {}
} }
@ -1212,6 +1215,7 @@ public class ADWindowToolbar extends ToolBar implements EventListener<Event>
super.onPageAttached(newpage, oldpage); super.onPageAttached(newpage, oldpage);
if (newpage != null) { if (newpage != null) {
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); 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); super.onPageAttached(newpage, oldpage);
try { try {
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
Component parentTab = this.getParent(); Component parentTab = this.getParent();
if (parentTab != null && parentTab instanceof Tabpanel) { if (parentTab != null && parentTab instanceof Tabpanel) {
@ -185,6 +186,7 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
super.onPageDetached(page); super.onPageDetached(page);
try { try {
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
SessionManager.getAppDesktop().unregisterWindow(m_WindowNo); SessionManager.getAppDesktop().unregisterWindow(m_WindowNo);
} catch (Exception e) {} } catch (Exception e) {}
} }
@ -235,9 +237,17 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
} }
} else if (event.getName().equals(Events.ON_CTRL_KEY)) { } else if (event.getName().equals(Events.ON_CTRL_KEY)) {
KeyEvent keyEvent = (KeyEvent) event; KeyEvent keyEvent = (KeyEvent) event;
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); 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); super.onEvent(event);
} }
} }
@ -266,10 +276,8 @@ public class ProcessDialog extends AbstractProcessDialog implements EventListene
private void onCtrlKeyEvent(KeyEvent keyEvent) { private void onCtrlKeyEvent(KeyEvent keyEvent) {
if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (m_WindowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(m_WindowNo);
}
} }
} }

View File

@ -24,8 +24,10 @@ import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.panel.ITabOnCloseHandler; import org.adempiere.webui.panel.ITabOnCloseHandler;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MPInstance; import org.compiere.model.MPInstance;
import org.compiere.model.MSysConfig;
import org.compiere.print.MPrintFormat; import org.compiere.print.MPrintFormat;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -72,6 +74,8 @@ public class ProcessModalDialog extends AbstractProcessDialog implements EventLi
private ITabOnCloseHandler originalOnCloseHandler; private ITabOnCloseHandler originalOnCloseHandler;
private Tabpanel parentTabPanel; 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 * @param WindowNo
@ -350,6 +354,10 @@ public class ProcessModalDialog extends AbstractProcessDialog implements EventLi
* Handle ON_Click event from {@link #bCancel} * Handle ON_Click event from {@link #bCancel}
*/ */
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
cancelProcess(); cancelProcess();
} }

View File

@ -39,6 +39,7 @@ import org.compiere.model.DataStatusEvent;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.zkforge.keylistener.Keylistener; import org.zkforge.keylistener.Keylistener;
@ -88,6 +89,8 @@ public class WQuickForm extends Window implements IQuickForm
private int windowNo; private int windowNo;
private boolean stayInParent; 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 * @param winContent
@ -419,6 +422,10 @@ public class WQuickForm extends Window implements IQuickForm
{ {
super.dispose(); super.dispose();
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
gridTab.setQuickForm(false); gridTab.setQuickForm(false);
onIgnore(); onIgnore();
gridTab.removeDataStatusListener(this); gridTab.removeDataStatusListener(this);

View File

@ -81,6 +81,7 @@ public class WFPanel extends Borderlayout implements EventListener<Event>, IHelp
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this); m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo); // for closing the window with shortcut setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo); // for closing the window with shortcut
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} // WFPanel } // WFPanel
/** Window No */ /** Window No */
@ -289,9 +290,16 @@ public class WFPanel extends Borderlayout implements EventListener<Event>, IHelp
} }
else if (event.getName().equals(Events.ON_CTRL_KEY)) { else if (event.getName().equals(Events.ON_CTRL_KEY)) {
KeyEvent keyEvent = (KeyEvent) event; KeyEvent keyEvent = (KeyEvent) event;
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); 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) { private void start(MWFNode wfn) {
@ -318,10 +326,8 @@ public class WFPanel extends Borderlayout implements EventListener<Event>, IHelp
private void onCtrlKeyEvent(KeyEvent keyEvent) { private void onCtrlKeyEvent(KeyEvent keyEvent) {
if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (m_WindowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(m_WindowNo);
}
} }
} }
} // WFPanel } // WFPanel

View File

@ -33,6 +33,7 @@ import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.session.SessionManager; import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MSysConfig;
import org.compiere.model.SystemProperties; import org.compiere.model.SystemProperties;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -128,6 +129,9 @@ public class Messagebox extends Window implements EventListener<Event>
/** Contains no symbols. */ /** Contains no symbols. */
public static final String NONE = null; 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 * Default constructor
*/ */
@ -560,6 +564,10 @@ public class Messagebox extends Window implements EventListener<Event>
*/ */
private void close() { private void close() {
try { try {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); this.detach();
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
if (! (SessionManager.getSessionApplication() == null)) // IDEMPIERE-1937 - ignore when session was closed 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 String predefinedContextVariables;
private boolean menuIsSOTrx; private boolean menuIsSOTrx;
private boolean isCloseTabWithShortcut = true;
@SuppressWarnings("unused") @SuppressWarnings("unused")
private static final CLogger logger = CLogger.getCLogger(AbstractDesktop.class); private static final CLogger logger = CLogger.getCLogger(AbstractDesktop.class);
@ -402,4 +403,14 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
protected boolean isMenuSOTrx() { protected boolean isMenuSOTrx() {
return this.menuIsSOTrx; 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) */ /** {@link EventQueue} name for activities (workflow activities, request, notice and unprocessed documents) */
public static final String ACTIVITIES_EVENT_QUEUE = "ActivitiesEventQueue"; public static final String ACTIVITIES_EVENT_QUEUE = "ActivitiesEventQueue";
public static final String ON_ACTIVITIES_CHANGED_EVENT = "onActivitiesChanged"; 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 * render home tab
*/ */
public void renderHomeTab(); 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.ClientInfo;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Label; import org.adempiere.webui.component.Label;
import org.adempiere.webui.desktop.IDesktop;
import org.adempiere.webui.editor.WEditor; import org.adempiere.webui.editor.WEditor;
import org.adempiere.webui.editor.WLocationEditor; import org.adempiere.webui.editor.WLocationEditor;
import org.adempiere.webui.editor.WebEditorFactory; import org.adempiere.webui.editor.WebEditorFactory;
@ -542,8 +543,13 @@ public class WQuickEntry extends AbstractWQuickEntry implements EventListener<Ev
@Override @Override
public void detach() { public void detach() {
super.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) if(m_WindowNo!=0)
SessionManager.getAppDesktop().unregisterWindow(m_WindowNo); desktop.unregisterWindow(m_WindowNo);
} }
public void valueChange(ValueChangeEvent evt) 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.init(adFormID, name);
form.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, form.getWindowNo()); // for closing the window with shortcut form.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, form.getWindowNo()); // for closing the window with shortcut
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, form); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, form);
form.addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, form);
return form; return form;
} }
else else
@ -234,9 +235,16 @@ public abstract class ADForm extends Window implements EventListener<Event>, IHe
} }
else if (event.getName().equals(Events.ON_CTRL_KEY)) { else if (event.getName().equals(Events.ON_CTRL_KEY)) {
KeyEvent keyEvent = (KeyEvent) event; KeyEvent keyEvent = (KeyEvent) event;
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); 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) { private void onCtrlKeyEvent(KeyEvent keyEvent) {
if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (m_WindowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(m_WindowNo);
}
} }
} }
} }

View File

@ -40,6 +40,7 @@ import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.SimpleListModel; import org.adempiere.webui.component.SimpleListModel;
import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
@ -136,6 +137,8 @@ public class CustomizeGridViewPanel extends Panel
private boolean uiCreated; private boolean uiCreated;
private boolean m_saved = false; private boolean m_saved = false;
private ConfirmPanel confirmPanel = new ConfirmPanel(true, false, true, false, false, 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 * Static Layout
@ -333,6 +336,10 @@ public class CustomizeGridViewPanel extends Panel
* cancel form * cancel form
*/ */
public void onCancel() { public void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
getParent().detach(); 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))){ }else if (event.getName().equals(Events.ON_CANCEL) || (event.getTarget().equals(this) && event.getName().equals(Events.ON_CLOSE))){
onCancel(); 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 //when user push enter keyboard at input parameter field
else else
{ {
@ -2442,6 +2449,10 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
* handle cancel event * handle cancel event
*/ */
protected void onCancel() { protected void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_cancel = true; m_cancel = true;
dispose(false); 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 // 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 } else if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (p_WindowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(p_WindowNo);
}
} }
} }
@ -3264,12 +3273,15 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0, this); SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0, this);
} }
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} }
@Override @Override
public void onPageDetached(Page page) { public void onPageDetached(Page page) {
super.onPageDetached(page); super.onPageDetached(page);
try { try {
removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
if (SessionManager.getSessionApplication() != null && if (SessionManager.getSessionApplication() != null &&
SessionManager.getSessionApplication().getKeylistener() != null) SessionManager.getSessionApplication().getKeylistener() != null)
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); 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.component.Window;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
@ -149,6 +150,9 @@ public class WAttachment extends Window implements EventListener<Event>
private static List<String> autoPreviewList; 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 { static {
autoPreviewList = new ArrayList<String>(); autoPreviewList = new ArrayList<String>();
autoPreviewList.add("image/jpeg"); autoPreviewList.add("image/jpeg");
@ -732,6 +736,9 @@ public class WAttachment extends Window implements EventListener<Event>
} // onEvent } // 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 // Cancel
dispose(); dispose();
} }

View File

@ -26,12 +26,14 @@ import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Panel; import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.VerticalBox; import org.adempiere.webui.component.VerticalBox;
import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MPInstancePara; import org.compiere.model.MPInstancePara;
import org.compiere.model.MProcessDrillRule; import org.compiere.model.MProcessDrillRule;
import org.compiere.model.MScheduler; import org.compiere.model.MScheduler;
import org.compiere.model.MSysConfig;
import org.compiere.process.ProcessInfo; import org.compiere.process.ProcessInfo;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -70,6 +72,9 @@ public class WProcessParameterForm extends ADForm
private ProcessParameterPanel parameterPanel; 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); private final static CLogger log = CLogger.getCLogger(WProcessParameterForm.class);
public WProcessParameterForm(WProcessParameter wpp) { public WProcessParameterForm(WProcessParameter wpp) {
@ -106,6 +111,10 @@ public class WProcessParameterForm extends ADForm
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.dispose(); 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.Rows;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ReaderInputStream; import org.adempiere.webui.util.ReaderInputStream;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MImportTemplate; import org.compiere.model.MImportTemplate;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MSysConfig;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -92,6 +94,8 @@ public class CSVImportAction implements EventListener<Event>
private Listbox fTemplates = new Listbox(); private Listbox fTemplates = new Listbox();
private Listbox fImportMode = new Listbox(); private Listbox fImportMode = new Listbox();
private InputStream m_file_istream = null; 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 * @param panel
@ -245,6 +249,10 @@ public class CSVImportAction implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
winImportFile.onClose(); 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.Rows;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
import org.compiere.model.GridTab; import org.compiere.model.GridTab;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.zkoss.util.media.AMedia; import org.zkoss.util.media.AMedia;
@ -81,6 +83,8 @@ public class ExportAction implements EventListener<Event>
private Row childTabSelectionRow = null; private Row childTabSelectionRow = null;
private List<Checkbox> chkSelectChildTabs = null; private List<Checkbox> chkSelectChildTabs = null;
private IGridTabExporter exporter; 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 * @param panel
@ -296,6 +300,10 @@ public class ExportAction implements EventListener<Event>
* Close export file dialog * Close export file dialog
*/ */
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
winExportFile.onClose(); winExportFile.onClose();
} }

View File

@ -48,6 +48,7 @@ import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ReaderInputStream; import org.adempiere.webui.util.ReaderInputStream;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.adempiere.webui.window.Dialog; import org.adempiere.webui.window.Dialog;
@ -55,6 +56,7 @@ import org.compiere.model.GridTab;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MLookupInfo; import org.compiere.model.MLookupInfo;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Ini; import org.compiere.util.Ini;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -90,6 +92,8 @@ public class FileImportAction implements EventListener<Event>
private Listbox fCharset = new Listbox(); private Listbox fCharset = new Listbox();
private WTableDirEditor fImportMode; private WTableDirEditor fImportMode;
private InputStream m_file_istream = null; 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 * @param panel
@ -257,6 +261,10 @@ public class FileImportAction implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
winImportFile.onClose(); winImportFile.onClose();
} }

View File

@ -80,6 +80,7 @@ import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.factory.ButtonFactory; import org.adempiere.webui.factory.ButtonFactory;
import org.adempiere.webui.panel.StatusBarPanel; import org.adempiere.webui.panel.StatusBarPanel;
import org.adempiere.webui.part.MultiTabPart; import org.adempiere.webui.part.MultiTabPart;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.GridField; import org.compiere.model.GridField;
@ -297,6 +298,9 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
/** Column name attribute set instance */ /** Column name attribute set instance */
private static final String COLUMNNAME_M_AttributeSetInstance_ID = "M_AttributeSetInstance_ID"; 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 * FindWindow Constructor
* @param targetWindowNo targetWindowNo * @param targetWindowNo targetWindowNo
@ -1965,6 +1969,10 @@ public class FindWindow extends Window implements EventListener<Event>, ValueCha
* user cancellation, close dialog * user cancellation, close dialog
*/ */
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_isCancel = true; m_isCancel = true;
dispose(); dispose();
} }

View File

@ -178,6 +178,7 @@ public class InfoSchedule extends Window implements EventListener<Event>
m_windowNo = SessionManager.getAppDesktop().registerWindow(this); m_windowNo = SessionManager.getAppDesktop().registerWindow(this);
setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_windowNo); // for closing the window with shortcut setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_windowNo); // for closing the window with shortcut
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} // InfoSchedule } // InfoSchedule
@ -501,13 +502,24 @@ public class InfoSchedule extends Window implements EventListener<Event>
displayCalendar(); displayCalendar();
else if (event.getName().equals(Events.ON_CTRL_KEY)) { else if (event.getName().equals(Events.ON_CTRL_KEY)) {
KeyEvent keyEvent = (KeyEvent) event; KeyEvent keyEvent = (KeyEvent) event;
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); 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() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_cancel = true; m_cancel = true;
dispose(); dispose();
} }
@ -692,10 +704,8 @@ public class InfoSchedule extends Window implements EventListener<Event>
private void onCtrlKeyEvent(KeyEvent keyEvent) { private void onCtrlKeyEvent(KeyEvent keyEvent) {
if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (m_windowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(m_windowNo);
}
} }
} }
} // InfoSchedule } // InfoSchedule

View File

@ -55,6 +55,7 @@ import org.compiere.model.MAccountLookup;
import org.compiere.model.MAcctSchema; import org.compiere.model.MAcctSchema;
import org.compiere.model.MAcctSchemaElement; import org.compiere.model.MAcctSchemaElement;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; import org.compiere.util.Env;
@ -90,6 +91,8 @@ public final class WAccountDialog extends Window
private static final long serialVersionUID = 3041802296879719489L; private static final long serialVersionUID = 3041802296879719489L;
private Callback<Integer> m_callback; 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 * Constructor
@ -791,6 +794,10 @@ public final class WAccountDialog extends Window
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_changed = false; m_changed = false;
dispose(); dispose();
} }

View File

@ -44,10 +44,12 @@ import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Timebox; import org.adempiere.webui.component.Timebox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MResourceAssignment; import org.compiere.model.MResourceAssignment;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.model.MUOMConversion; import org.compiere.model.MUOMConversion;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -77,6 +79,9 @@ public class WAssignmentDialog extends Window implements EventListener<Event>
*/ */
private static final long serialVersionUID = -1762339564864115852L; 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. * Assignment Dialog.
* <pre> * <pre>
@ -424,6 +429,10 @@ public class WAssignmentDialog extends Window implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_cancel = true; m_cancel = true;
detach(); detach();
} }

View File

@ -29,10 +29,12 @@ import org.adempiere.webui.component.Label;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.event.DialogEvents; import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MChat; import org.compiere.model.MChat;
import org.compiere.model.MChatEntry; import org.compiere.model.MChatEntry;
import org.compiere.model.MSysConfig;
import org.compiere.model.MUser; import org.compiere.model.MUser;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DisplayType; 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 USER_LABEL_STYLE = "font-weight: bold";
private static final String TIME_LABEL_STYLE = "font-size:xx-small;color:gray;margin-left:20px"; 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. * Constructor.
* loads Chat, if ID &lt;&gt; 0 * loads Chat, if ID &lt;&gt; 0
@ -383,6 +388,10 @@ public class WChat extends Window implements EventListener<Event>, DialogEvents
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); this.detach();
} }
} // WChat } // WChat

View File

@ -8,6 +8,7 @@ import java.util.List;
import org.adempiere.webui.component.ConfirmPanel; import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.compiere.model.I_AD_CtxHelpMsg; import org.compiere.model.I_AD_CtxHelpMsg;
import org.compiere.model.MCtxHelp; import org.compiere.model.MCtxHelp;
import org.compiere.model.MCtxHelpMsg; import org.compiere.model.MCtxHelpMsg;
@ -15,6 +16,7 @@ import org.compiere.model.MCtxHelpSuggestion;
import org.compiere.model.MForm; import org.compiere.model.MForm;
import org.compiere.model.MInfoWindow; import org.compiere.model.MInfoWindow;
import org.compiere.model.MProcess; import org.compiere.model.MProcess;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTab; import org.compiere.model.MTab;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.MTask; import org.compiere.model.MTask;
@ -62,6 +64,8 @@ public class WCtxHelpSuggestion extends Window implements EventListener<Event> {
private String baseContent; private String baseContent;
private String translatedContent; 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 * default constructor
@ -172,6 +176,10 @@ public class WCtxHelpSuggestion extends Window implements EventListener<Event> {
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); this.detach();
} }

View File

@ -53,6 +53,7 @@ import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WSearchEditor; import org.adempiere.webui.editor.WSearchEditor;
import org.adempiere.webui.event.ValueChangeEvent; import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.event.ValueChangeListener; import org.adempiere.webui.event.ValueChangeListener;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.Lookup; import org.compiere.model.Lookup;
@ -61,6 +62,7 @@ import org.compiere.model.MAttachmentEntry;
import org.compiere.model.MClient; import org.compiere.model.MClient;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MMailText; import org.compiere.model.MMailText;
import org.compiere.model.MSysConfig;
import org.compiere.model.MUser; import org.compiere.model.MUser;
import org.compiere.model.MUserMail; import org.compiere.model.MUserMail;
import org.compiere.model.PrintInfo; import org.compiere.model.PrintInfo;
@ -270,6 +272,8 @@ public class WEMailDialog extends Window implements EventListener<Event>, ValueC
private Button bAddDefaultMailText; private Button bAddDefaultMailText;
private Div attachmentBox; private Div attachmentBox;
private Checkbox isAcknowledgmentReceipt = new Checkbox(); 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 @Override
public void onPageAttached(Page newpage, Page oldpage) { public void onPageAttached(Page newpage, Page oldpage) {
@ -646,6 +650,10 @@ public class WEMailDialog extends Window implements EventListener<Event>, ValueC
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
onClose(); onClose();
} }

View File

@ -30,6 +30,7 @@ import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.SimpleListModel; import org.adempiere.webui.component.SimpleListModel;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WEditorPopupMenu; import org.adempiere.webui.editor.WEditorPopupMenu;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.GridField; import org.compiere.model.GridField;
@ -38,6 +39,7 @@ import org.compiere.model.MColumn;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.MUser; import org.compiere.model.MUser;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -72,6 +74,8 @@ public class WFieldRecordInfo extends Window implements EventListener<Event>
private int AD_Column_ID; private int AD_Column_ID;
private int Record_ID; private int Record_ID;
private String Record_UU; 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 * Record Info
@ -377,6 +381,10 @@ public class WFieldRecordInfo extends Window implements EventListener<Event>
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); 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.Row;
import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MField; import org.compiere.model.MField;
import org.compiere.model.MFieldSuggestion; import org.compiere.model.MFieldSuggestion;
import org.compiere.model.MSysConfig;
import org.compiere.model.PO; import org.compiere.model.PO;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -46,6 +48,8 @@ public class WFieldSuggestion extends Window implements EventListener<Event> {
private Textbox descriptionTextbox; private Textbox descriptionTextbox;
private Textbox helpTextbox; 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 * default constructor
@ -139,6 +143,10 @@ public class WFieldSuggestion extends Window implements EventListener<Event> {
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); this.detach();
} }

View File

@ -41,6 +41,7 @@ import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MDashboardContent; import org.compiere.model.MDashboardContent;
import org.compiere.model.MDashboardPreference; import org.compiere.model.MDashboardPreference;
import org.compiere.model.MSysConfig;
import org.compiere.model.Query; import org.compiere.model.Query;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; 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 ArrayList<MDashboardContent> noItems =new ArrayList<MDashboardContent>();
protected Map<Integer, MDashboardPreference> dirtyList = new LinkedHashMap<Integer, MDashboardPreference>(); 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() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); 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.Panel;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.compiere.model.MImage; import org.compiere.model.MImage;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.MimeType; import org.compiere.util.MimeType;
@ -132,6 +134,8 @@ public class WImageDialog extends Window implements EventListener<Event>
private Div captureDiv; private Div captureDiv;
private String defaultNameForCaptureImage = "CapturedImage"; private String defaultNameForCaptureImage = "CapturedImage";
private Button cancelCaptureButton; 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; private static List<String> autoPreviewList;
@ -327,6 +331,10 @@ public class WImageDialog extends Window implements EventListener<Event>
} }
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 = true; cancel = true;
detach(); detach();
} }

View File

@ -45,6 +45,7 @@ import org.adempiere.webui.component.Row;
import org.adempiere.webui.component.Rows; import org.adempiere.webui.component.Rows;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.GridField; import org.compiere.model.GridField;
@ -155,6 +156,8 @@ public class WLocationDialog extends Window implements EventListener<Event>
private GridField m_GridField = null; private GridField m_GridField = null;
private boolean onSaveError = false; 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 //END
public WLocationDialog(String title, MLocation location) public WLocationDialog(String title, MLocation location)
@ -931,6 +934,10 @@ public class WLocationDialog extends Window implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_change = false; m_change = false;
this.dispose(); 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.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.editor.WTableDirEditor; import org.adempiere.webui.editor.WTableDirEditor;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MLocator; import org.compiere.model.MLocator;
import org.compiere.model.MLocatorLookup; import org.compiere.model.MLocatorLookup;
import org.compiere.model.MLocatorType; import org.compiere.model.MLocatorType;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.util.AdempiereUserError; import org.compiere.util.AdempiereUserError;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -124,6 +126,8 @@ public class WLocatorDialog extends Window implements EventListener<Event>
private boolean m_change; private boolean m_change;
private String title; 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); private static final CLogger log = CLogger.getCLogger(WLocatorDialog.class);
@ -695,6 +699,10 @@ public class WLocatorDialog extends Window implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
m_change = false; m_change = false;
this.detach(); 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.Panel;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.component.ZkCssHelper; import org.adempiere.webui.component.ZkCssHelper;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -83,6 +85,8 @@ public class WMediaDialog extends Window implements EventListener<Event>
private Hbox confirmPanel = new Hbox(); private Hbox confirmPanel = new Hbox();
private boolean m_cancel; 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. * Constructor.
@ -343,6 +347,10 @@ public class WMediaDialog extends Window implements EventListener<Event>
} // onEvent } // 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);
m_cancel = true; m_cancel = true;
dispose(); dispose();
} }

View File

@ -67,6 +67,7 @@ import org.compiere.model.MLotCtl;
import org.compiere.model.MQuery; import org.compiere.model.MQuery;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSerNoCtl; import org.compiere.model.MSerNoCtl;
import org.compiere.model.MSysConfig;
import org.compiere.model.X_M_MovementLine; import org.compiere.model.X_M_MovementLine;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
@ -211,6 +212,8 @@ public class WPAttributeDialog extends Window implements EventListener<Event>
protected ConfirmPanel confirmPanel = new ConfirmPanel (true); protected ConfirmPanel confirmPanel = new ConfirmPanel (true);
protected String m_columnName = null; 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 * Layout
@ -839,6 +842,10 @@ public class WPAttributeDialog extends Window implements EventListener<Event>
} // actionPerformed } // actionPerformed
protected void onCancel() { 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_changed = false;
m_M_AttributeSetInstance_ID = 0; m_M_AttributeSetInstance_ID = 0;
m_M_Locator_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.Panel;
import org.adempiere.webui.component.WListbox; import org.adempiere.webui.component.WListbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.minigrid.ColumnInfo; import org.compiere.minigrid.ColumnInfo;
import org.compiere.minigrid.IDColumn; import org.compiere.minigrid.IDColumn;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.Env; 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 int m_M_AttributeSetInstance_ID = -1;
private String m_M_AttributeSetInstanceName = null; private String m_M_AttributeSetInstanceName = null;
private String m_sql; 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 */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WPAttributeInstance.class); private static final CLogger log = CLogger.getCLogger(WPAttributeInstance.class);
@ -323,6 +327,10 @@ public class WPAttributeInstance extends Window implements EventListener<Event>
} // actionPerformed } // actionPerformed
private void onCancel() { 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_AttributeSetInstance_ID = -1;
m_M_AttributeSetInstanceName = null; m_M_AttributeSetInstanceName = null;
detach(); detach();

View File

@ -26,7 +26,9 @@ import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.VerticalBox; import org.adempiere.webui.component.VerticalBox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.compiere.model.MPostIt; import org.compiere.model.MPostIt;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Language; import org.compiere.util.Language;
import org.zkforge.ckez.CKeditor; import org.zkforge.ckez.CKeditor;
@ -58,6 +60,8 @@ public class WPostIt extends Window implements EventListener<Event>{
private String created; private String created;
private String updated; private String updated;
private MPostIt m_postIt; 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 * @param title
@ -208,6 +212,10 @@ public class WPostIt extends Window implements EventListener<Event>{
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
detach(); detach();
} }

View File

@ -33,6 +33,7 @@ import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.SimpleListModel; import org.adempiere.webui.component.SimpleListModel;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.DataStatusEvent; import org.compiere.model.DataStatusEvent;
@ -44,6 +45,7 @@ import org.compiere.model.MColumn;
import org.compiere.model.MLookup; import org.compiere.model.MLookup;
import org.compiere.model.MLookupFactory; import org.compiere.model.MLookupFactory;
import org.compiere.model.MRole; import org.compiere.model.MRole;
import org.compiere.model.MSysConfig;
import org.compiere.model.MTable; import org.compiere.model.MTable;
import org.compiere.model.MUser; import org.compiere.model.MUser;
import org.compiere.model.PO; import org.compiere.model.PO;
@ -150,6 +152,8 @@ public class WRecordInfo extends Window implements EventListener<Event>
private Toolbarbutton m_permalink = new Toolbarbutton(); private Toolbarbutton m_permalink = new Toolbarbutton();
/** Copy Select */ /** Copy Select */
private Toolbarbutton m_copySelect = new Toolbarbutton(); 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 */ /** Date Time Format */
private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat private SimpleDateFormat m_dateTimeFormat = DisplayType.getDateFormat
@ -569,6 +573,10 @@ public class WRecordInfo extends Window implements EventListener<Event>
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
this.detach(); 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.ListItem;
import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -59,6 +61,8 @@ public class WReportExportDialog extends Window implements EventListener<Event>
private Listbox cboType = new Listbox(); private Listbox cboType = new Listbox();
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private IReportViewerExportSource viewer; 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 */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WReportExportDialog.class); private static final CLogger log = CLogger.getCLogger(WReportExportDialog.class);
@ -132,6 +136,10 @@ public class WReportExportDialog extends Window implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
onClose(); onClose();
} }

View File

@ -40,9 +40,11 @@ import org.adempiere.webui.component.ListItem;
import org.adempiere.webui.component.Listbox; import org.adempiere.webui.component.Listbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.report.LinkWindow; import org.adempiere.webui.report.LinkWindow;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.ReaderInputStream; import org.adempiere.webui.util.ReaderInputStream;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MAuthorizationAccount; import org.compiere.model.MAuthorizationAccount;
import org.compiere.model.MSysConfig;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -69,6 +71,8 @@ public class WReportUploadDialog extends Window implements EventListener<Event>
private Listbox cboActions = new Listbox(); private Listbox cboActions = new Listbox();
private ConfirmPanel confirmPanel = new ConfirmPanel(true); private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private IReportViewerExportSource viewer; 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 */ /** Logger */
private static final CLogger log = CLogger.getCLogger(WReportUploadDialog.class); private static final CLogger log = CLogger.getCLogger(WReportUploadDialog.class);
@ -168,6 +172,10 @@ public class WReportUploadDialog extends Window implements EventListener<Event>
} }
private void onCancel() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
onClose(); onClose();
} }

View File

@ -26,8 +26,10 @@ import org.adempiere.webui.component.Tabpanels;
import org.adempiere.webui.component.Tabs; import org.adempiere.webui.component.Tabs;
import org.adempiere.webui.component.Textbox; import org.adempiere.webui.component.Textbox;
import org.adempiere.webui.component.Window; import org.adempiere.webui.component.Window;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.theme.ThemeManager; import org.adempiere.webui.theme.ThemeManager;
import org.adempiere.webui.util.ZKUpdateUtil; import org.adempiere.webui.util.ZKUpdateUtil;
import org.compiere.model.MSysConfig;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Language; import org.compiere.util.Language;
import org.compiere.util.Msg; import org.compiere.util.Msg;
@ -65,6 +67,8 @@ public class WTextEditorDialog extends Window implements EventListener<Event>{
private Label status; private Label status;
private Tab htmlTab; private Tab htmlTab;
private boolean isShowHTMLTab = true; 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() { private void onCancel() {
// do not allow to close tab for Events.ON_CTRL_KEY event
if(isUseEscForTabClosing)
SessionManager.getAppDesktop().setCloseTabWithShortcut(false);
cancelled = true; cancelled = true;
detach(); detach();
} }

View File

@ -173,6 +173,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
super.onPageAttached(newpage, oldpage); super.onPageAttached(newpage, oldpage);
try { try {
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} catch (Exception e) {} } catch (Exception e) {}
} }
@ -181,6 +182,7 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
super.onPageDetached(page); super.onPageDetached(page);
try { try {
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} catch (Exception e) {} } catch (Exception e) {}
} }
@ -659,15 +661,20 @@ public class ZkJRViewer extends Window implements EventListener<Event>, ITabOnCl
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); 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) { private void onCtrlKeyEvent(KeyEvent keyEvent) {
if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X if ((keyEvent.isAltKey() && keyEvent.getKeyCode() == 0x58) // Alt-X
|| (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC || (keyEvent.getKeyCode() == 0x1B && isUseEscForTabClosing)) { // ESC
if (m_WindowNo > 0) { keyEvent.stopPropagation();
keyEvent.stopPropagation(); Events.echoEvent(new Event(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this));
SessionManager.getAppDesktop().closeWindow(m_WindowNo);
}
} }
} }

View File

@ -414,6 +414,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
init(); init();
dynInit(); dynInit();
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
addEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} }
catch(Exception e) catch(Exception e)
{ {
@ -429,6 +430,7 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
super.onPageDetached(page); super.onPageDetached(page);
try { try {
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this); SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
removeEventListener(IDesktop.ON_CLOSE_WINDOW_SHORTCUT_EVENT, this);
} catch (Exception e) {} } catch (Exception e) {}
cleanUp(); cleanUp();
} }
@ -1173,21 +1175,28 @@ public class ZkReportViewer extends Window implements EventListener<Event>, IRep
onRenderReportEvent(); onRenderReportEvent();
} else if (event.getName().equals(Events.ON_CTRL_KEY)) { } else if (event.getName().equals(Events.ON_CTRL_KEY)) {
KeyEvent keyEvent = (KeyEvent) event; KeyEvent keyEvent = (KeyEvent) event;
if (LayoutUtils.isReallyVisible(this)) if (LayoutUtils.isReallyVisible(this))
this.onCtrlKeyEvent(keyEvent); this.onCtrlKeyEvent(keyEvent);
} }
else if (event.getTarget() instanceof ProcessModalDialog) else if (event.getTarget() instanceof ProcessModalDialog)
{ {
if(DialogEvents.ON_WINDOW_CLOSE.equals(event.getName())) if(DialogEvents.ON_WINDOW_CLOSE.equals(event.getName()))
{
hideBusyMask();
ProcessModalDialog dialog = (ProcessModalDialog) event.getTarget();
if (dialog.isCancel())
{ {
if (getDesktop() != null) hideBusyMask();
clearTabOnCloseHandler(); 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);
} }
} }