IDEMPIERE-2112 improve shortcuts for master detail data entry windows / WIP, enable shortcuts on info windows, Shift+Alt+Down to navigate to the searched records, Enter to select the current row, Escape to cancel

This commit is contained in:
Carlos Ruiz 2014-08-15 23:36:53 +02:00
parent 79f99b8d81
commit 739c51847a
1 changed files with 47 additions and 2 deletions

View File

@ -35,6 +35,7 @@ import java.util.logging.Level;
import org.adempiere.model.MInfoProcess; import org.adempiere.model.MInfoProcess;
import org.adempiere.webui.AdempiereWebUI; import org.adempiere.webui.AdempiereWebUI;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv; import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog; import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.apps.ProcessModalDialog; import org.adempiere.webui.apps.ProcessModalDialog;
@ -79,6 +80,7 @@ import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.KeyEvent;
import org.zkoss.zk.ui.event.MouseEvent; import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zk.ui.event.SelectEvent; import org.zkoss.zk.ui.event.SelectEvent;
import org.zkoss.zk.ui.util.Clients; import org.zkoss.zk.ui.util.Clients;
@ -108,7 +110,7 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
/** /**
* *
*/ */
private static final long serialVersionUID = 7393899696081833013L; private static final long serialVersionUID = 6027970576265023451L;
private final static int DEFAULT_PAGE_SIZE = 100; private final static int DEFAULT_PAGE_SIZE = 100;
protected List<Button> btProcessList = new ArrayList<Button>(); protected List<Button> btProcessList = new ArrayList<Button>();
@ -1360,13 +1362,46 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
else else
SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0); SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0);
} }
else if (event.getName().equals(Events.ON_CTRL_KEY))
{
KeyEvent keyEvent = (KeyEvent) event;
if (LayoutUtils.isReallyVisible(this)) {
this.onCtrlKeyEvent(keyEvent);
}
}
//when user push enter keyboard at input parameter field //when user push enter keyboard at input parameter field
else else
{ {
onUserQuery(); // onUserQuery(); // captured now on control key
} }
} // onEvent } // onEvent
public static final int VK_ENTER = '\r';
public static final int VK_ESCAPE = 0x1B;
private void onCtrlKeyEvent(KeyEvent keyEvent) {
if (keyEvent.isAltKey() && !keyEvent.isCtrlKey() && keyEvent.isShiftKey()) { // Shift+Alt
if (keyEvent.getKeyCode() == KeyEvent.DOWN) { // Shift+Alt+Down
// navigate to results
if (contentPanel.getRowCount() > 0) {
contentPanel.setFocus(true);
contentPanel.setSelectedIndex(0);
}
}
} else if (keyEvent.getKeyCode() == VK_ENTER) { // Enter
// enter in contentpanel to select
//when user push enter keyboard at input parameter field
if (contentPanel.getSelectedIndex() >= 0) {
onOk();
} else {
onUserQuery();
}
} else if (keyEvent.getKeyCode() == VK_ESCAPE) { // Escape
// Escape for cancel
m_cancel = true;
dispose(false);
}
}
/** /**
* Call query when user click to query button enter in parameter field * Call query when user click to query button enter in parameter field
*/ */
@ -1753,6 +1788,16 @@ public abstract class InfoPanel extends Window implements EventListener<Event>,
else else
SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0); SessionManager.getAppDesktop().updateHelpContext(X_AD_CtxHelp.CTXTYPE_Home, 0);
} }
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
} }
@Override
public void onPageDetached(Page page) {
super.onPageDetached(page);
try {
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
} catch (Exception e){}
}
} // Info } // Info