IDEMPIERE-2112 improve shortcuts for master detail data entry windows / WIP, enabled shortcut Shift+Alt+N for new detail button
This commit is contained in:
parent
e8228d6fbe
commit
79f99b8d81
|
@ -76,7 +76,6 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
private int windowNo;
|
||||
|
||||
private HashMap<String, ToolBarButton> buttons = new HashMap<String, ToolBarButton>();
|
||||
private Map<Integer, ToolBarButton> altKeyMap = new HashMap<Integer, ToolBarButton>();
|
||||
|
||||
private DataStatusEvent m_dse;
|
||||
|
||||
|
@ -128,12 +127,7 @@ public class BreadCrumb extends Div implements EventListener<Event> {
|
|||
btnLast = createButton("Last", "Last", "Last");
|
||||
btnLast.setTooltiptext(btnLast.getTooltiptext()+" Alt+End");
|
||||
toolbar.appendChild(btnLast);
|
||||
|
||||
altKeyMap.put(KeyEvent.UP, btnPrevious);
|
||||
altKeyMap.put(KeyEvent.DOWN, btnNext);
|
||||
altKeyMap.put(KeyEvent.PAGE_UP, btnFirst);
|
||||
altKeyMap.put(KeyEvent.PAGE_DOWN, btnLast);
|
||||
|
||||
|
||||
toolbar.setStyle("background-image: none; background-color: transparent; border: none;");
|
||||
setWidgetAttribute(AdempiereWebUI.WIDGET_INSTANCE_NAME, "breadcrumb");
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.component.ADTabListModel.ADTabLabel;
|
||||
import org.adempiere.webui.component.Label;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.Tab;
|
||||
|
@ -16,13 +17,13 @@ import org.adempiere.webui.component.Tabpanel;
|
|||
import org.adempiere.webui.component.ToolBar;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.component.ADTabListModel.ADTabLabel;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
import org.compiere.util.Util;
|
||||
import org.zkoss.zhtml.Text;
|
||||
import org.zkoss.zk.au.out.AuScript;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Execution;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
@ -31,6 +32,7 @@ import org.zkoss.zk.ui.Page;
|
|||
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;
|
||||
import org.zkoss.zk.ui.sys.ExecutionCtrl;
|
||||
import org.zkoss.zk.ui.util.Clients;
|
||||
import org.zkoss.zul.Div;
|
||||
|
@ -45,6 +47,10 @@ import org.zkoss.zul.Toolbar;
|
|||
*
|
||||
*/
|
||||
public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -5714780894880069158L;
|
||||
|
||||
private static final String BTN_PROCESS_ID = "BtnProcess";
|
||||
|
||||
|
@ -67,11 +73,10 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
private static final String NEW_IMAGE = "images/New16.png";
|
||||
private static final String PROCESS_IMAGE = "images/Process16.png";
|
||||
|
||||
/**
|
||||
* generated serial id
|
||||
*/
|
||||
private static final long serialVersionUID = -7914602940626352282L;
|
||||
|
||||
private ToolBarButton btnNew;
|
||||
private long prevKeyEventTime = 0;
|
||||
private KeyEvent prevKeyEvent;
|
||||
|
||||
private Tabbox tabbox;
|
||||
|
||||
private EventListener<Event> eventListener;
|
||||
|
@ -251,19 +256,19 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
tp.setSclass("adwindow-detailpane-tabpanel");
|
||||
ToolBar toolbar = new ToolBar();
|
||||
tp.appendChild(toolbar);
|
||||
ToolBarButton button = new ToolBarButton();
|
||||
|
||||
button = new ToolBarButton();
|
||||
button.setImage(ThemeManager.getThemeResource(NEW_IMAGE));
|
||||
button.setId(BTN_NEW_ID);
|
||||
toolbar.appendChild(button);
|
||||
button.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||
btnNew = new ToolBarButton();
|
||||
btnNew.setImage(ThemeManager.getThemeResource(NEW_IMAGE));
|
||||
btnNew.setId(BTN_NEW_ID);
|
||||
toolbar.appendChild(btnNew);
|
||||
btnNew.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
onNew();
|
||||
}
|
||||
});
|
||||
button.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "New")));
|
||||
btnNew.setTooltiptext(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "New")) + " Shift+Alt+N");
|
||||
|
||||
ToolBarButton button = new ToolBarButton();
|
||||
|
||||
button = new ToolBarButton();
|
||||
button.setImage(ThemeManager.getThemeResource(EDIT_IMAGE));
|
||||
|
@ -483,7 +488,25 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
return;
|
||||
}
|
||||
LayoutUtils.redraw(this);
|
||||
}
|
||||
} else if (event.getName().equals(Events.ON_CTRL_KEY)) {
|
||||
KeyEvent keyEvent = (KeyEvent) event;
|
||||
if (LayoutUtils.isReallyVisible(this)) {
|
||||
//filter same key event that is too close
|
||||
//firefox fire key event twice when grid is visible
|
||||
long time = System.currentTimeMillis();
|
||||
if (prevKeyEvent != null && prevKeyEventTime > 0 &&
|
||||
prevKeyEvent.getKeyCode() == keyEvent.getKeyCode() &&
|
||||
prevKeyEvent.getTarget() == keyEvent.getTarget() &&
|
||||
prevKeyEvent.isAltKey() == keyEvent.isAltKey() &&
|
||||
prevKeyEvent.isCtrlKey() == keyEvent.isCtrlKey() &&
|
||||
prevKeyEvent.isShiftKey() == keyEvent.isShiftKey()) {
|
||||
if ((time - prevKeyEventTime) <= 300) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.onCtrlKeyEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void createPopupContent(String status) {
|
||||
|
@ -518,6 +541,17 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
super.onPageDetached(page);
|
||||
if (msgPopup != null)
|
||||
msgPopup.detach();
|
||||
try {
|
||||
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
|
||||
} catch (Exception e){}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageAttached(Page newpage, Page oldpage) {
|
||||
super.onPageAttached(newpage, oldpage);
|
||||
if (newpage != null) {
|
||||
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -715,4 +749,27 @@ public class DetailPane extends Panel implements EventListener<Event>, IdSpace {
|
|||
Event openEvent = new Event(ON_NEW_EVENT, DetailPane.this);
|
||||
eventListener.onEvent(openEvent);
|
||||
}
|
||||
|
||||
public static final int VK_N = 0x4E;
|
||||
private void onCtrlKeyEvent(KeyEvent keyEvent) {
|
||||
ToolBarButton btn = null;
|
||||
if (keyEvent.isAltKey() && !keyEvent.isCtrlKey() && keyEvent.isShiftKey()) { // Shift+Alt key
|
||||
if (keyEvent.getKeyCode() == VK_N) { // Shift+Alt+N
|
||||
btn = btnNew;
|
||||
}
|
||||
}
|
||||
if (btn != null) {
|
||||
prevKeyEventTime = System.currentTimeMillis();
|
||||
prevKeyEvent = keyEvent;
|
||||
keyEvent.stopPropagation();
|
||||
if (!btn.isDisabled() && btn.isVisible()) {
|
||||
Events.sendEvent(btn, new Event(Events.ON_CLICK, btn));
|
||||
//client side script to close combobox popup
|
||||
String script = "var w=zk.Widget.$('#" + btn.getUuid()+"'); " +
|
||||
"zWatch.fire('onFloatUp', w);";
|
||||
Clients.response(new AuScript(script));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,9 +25,11 @@ import org.adempiere.webui.LayoutUtils;
|
|||
*/
|
||||
public class ToolBarButton extends org.zkoss.zul.Toolbarbutton
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -1214319982911389339L;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean pressed; // Elaine 2008/12/09
|
||||
|
|
Loading…
Reference in New Issue