IDEMPIERE-5786 - Support Closing Performance Detail with Shortcut (#1933)
This commit is contained in:
parent
eed078308c
commit
beffc74bc0
|
@ -1,8 +1,16 @@
|
||||||
package org.adempiere.webui.apps.graph;
|
package org.adempiere.webui.apps.graph;
|
||||||
|
|
||||||
|
import org.adempiere.webui.LayoutUtils;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
|
import org.adempiere.webui.desktop.IDesktop;
|
||||||
import org.adempiere.webui.session.SessionManager;
|
import org.adempiere.webui.session.SessionManager;
|
||||||
import org.compiere.model.MGoal;
|
import org.compiere.model.MGoal;
|
||||||
|
import org.compiere.model.MSysConfig;
|
||||||
|
import org.compiere.util.Env;
|
||||||
|
import org.zkoss.zk.ui.event.Event;
|
||||||
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
|
import org.zkoss.zk.ui.event.KeyEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Window with Chart and Details for {@link MGoal}
|
* Window with Chart and Details for {@link MGoal}
|
||||||
|
@ -10,13 +18,18 @@ import org.compiere.model.MGoal;
|
||||||
* @author Jorg Janke
|
* @author Jorg Janke
|
||||||
* @version $Id: PerformanceDetail.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
* @version $Id: PerformanceDetail.java,v 1.2 2006/07/30 00:51:28 jjanke Exp $
|
||||||
*/
|
*/
|
||||||
public class WPerformanceDetail extends Window
|
public class WPerformanceDetail extends Window implements EventListener<Event>
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* generated serial id
|
* generated serial id
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 3460594735973451874L;
|
private static final long serialVersionUID = 3460594735973451874L;
|
||||||
|
|
||||||
|
/* Window No. */
|
||||||
|
private int m_windowNo;
|
||||||
|
/* 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.
|
||||||
* Called from {@link WPAPanel} and {@link WPAWidget}
|
* Called from {@link WPAPanel} and {@link WPAWidget}
|
||||||
|
@ -33,6 +46,32 @@ public class WPerformanceDetail extends Window
|
||||||
this.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
this.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
|
||||||
this.setStyle("height: 100%; width: 100%; position: absolute; overflow: auto");
|
this.setStyle("height: 100%; width: 100%; position: absolute; overflow: auto");
|
||||||
graph.setStyle("height: 100%; width: 100%; position: absolute; overflow: visible");
|
graph.setStyle("height: 100%; width: 100%; position: absolute; overflow: visible");
|
||||||
|
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);
|
||||||
SessionManager.getAppDesktop().showWindow(this);
|
SessionManager.getAppDesktop().showWindow(this);
|
||||||
} // PerformanceDetail
|
} // PerformanceDetail
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEvent(Event event) throws Exception {
|
||||||
|
if (event.getName().equals(Events.ON_CTRL_KEY)) {
|
||||||
|
KeyEvent keyEvent = (KeyEvent) event;
|
||||||
|
if (LayoutUtils.isReallyVisible(this))
|
||||||
|
this.onCtrlKeyEvent(keyEvent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle shortcut key event
|
||||||
|
* @param keyEvent
|
||||||
|
*/
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue