* Implemented function key shortcut support for toolbar.
This commit is contained in:
parent
f4e44a99e4
commit
b35f0c2701
|
@ -28,6 +28,9 @@ import java.util.logging.Level;
|
||||||
import org.adempiere.webui.apps.AEnv;
|
import org.adempiere.webui.apps.AEnv;
|
||||||
import org.adempiere.webui.apps.ProcessDialog;
|
import org.adempiere.webui.apps.ProcessDialog;
|
||||||
import org.adempiere.webui.component.Button;
|
import org.adempiere.webui.component.Button;
|
||||||
|
import org.adempiere.webui.component.Grid;
|
||||||
|
import org.adempiere.webui.component.Row;
|
||||||
|
import org.adempiere.webui.component.Rows;
|
||||||
import org.adempiere.webui.component.Tabpanel;
|
import org.adempiere.webui.component.Tabpanel;
|
||||||
import org.adempiere.webui.component.ToolBarButton;
|
import org.adempiere.webui.component.ToolBarButton;
|
||||||
import org.adempiere.webui.component.Window;
|
import org.adempiere.webui.component.Window;
|
||||||
|
@ -69,6 +72,7 @@ import org.zkoss.zul.Caption;
|
||||||
import org.zkoss.zul.Groupbox;
|
import org.zkoss.zul.Groupbox;
|
||||||
import org.zkoss.zul.Hbox;
|
import org.zkoss.zul.Hbox;
|
||||||
import org.zkoss.zul.Iframe;
|
import org.zkoss.zul.Iframe;
|
||||||
|
import org.zkoss.zul.Label;
|
||||||
import org.zkoss.zul.Separator;
|
import org.zkoss.zul.Separator;
|
||||||
import org.zkoss.zul.Vbox;
|
import org.zkoss.zul.Vbox;
|
||||||
|
|
||||||
|
@ -95,7 +99,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
||||||
private Borderlayout layout;
|
private Borderlayout layout;
|
||||||
|
|
||||||
private WindowContainer windowContainer;
|
private WindowContainer windowContainer;
|
||||||
|
|
||||||
private Button btnNotice, btnRequest, btnWorkflow;
|
private Button btnNotice, btnRequest, btnWorkflow;
|
||||||
|
|
||||||
public Desktop()
|
public Desktop()
|
||||||
|
@ -112,8 +116,13 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
||||||
|
|
||||||
layout = new Borderlayout();
|
layout = new Borderlayout();
|
||||||
if (parent != null)
|
if (parent != null)
|
||||||
|
{
|
||||||
layout.setParent(parent);
|
layout.setParent(parent);
|
||||||
else
|
layout.setWidth("100%");
|
||||||
|
layout.setHeight("100%");
|
||||||
|
layout.setStyle("position: absolute");
|
||||||
|
}
|
||||||
|
else
|
||||||
layout.setPage(page);
|
layout.setPage(page);
|
||||||
|
|
||||||
North n = new North();
|
North n = new North();
|
||||||
|
@ -193,7 +202,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
||||||
borderlayout.setWidth("100%");
|
borderlayout.setWidth("100%");
|
||||||
borderlayout.setHeight("100%");
|
borderlayout.setHeight("100%");
|
||||||
borderlayout.setStyle("background-color: transparent; position: absolute;");
|
borderlayout.setStyle("background-color: transparent; position: absolute;");
|
||||||
|
|
||||||
West west = new West();
|
West west = new West();
|
||||||
west.appendChild(gbxFav);
|
west.appendChild(gbxFav);
|
||||||
borderlayout.appendChild(west);
|
borderlayout.appendChild(west);
|
||||||
|
@ -204,12 +213,12 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
||||||
center.appendChild(gbxView);
|
center.appendChild(gbxView);
|
||||||
borderlayout.appendChild(center);
|
borderlayout.appendChild(center);
|
||||||
center.setStyle("background-color: transparent");
|
center.setStyle("background-color: transparent");
|
||||||
|
|
||||||
South south = new South();
|
South south = new South();
|
||||||
south.appendChild(hbox);
|
south.appendChild(hbox);
|
||||||
borderlayout.appendChild(south);
|
borderlayout.appendChild(south);
|
||||||
south.setStyle("background-color: transparent");
|
south.setStyle("background-color: transparent");
|
||||||
|
|
||||||
//register as 0
|
//register as 0
|
||||||
registerWindow(homeTab);
|
registerWindow(homeTab);
|
||||||
|
|
||||||
|
@ -537,7 +546,7 @@ public class Desktop extends AbstractUIPart implements MenuListener, Serializabl
|
||||||
if(menuId > 0) onMenuSelected(menuId);
|
if(menuId > 0) onMenuSelected(menuId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the Client website url
|
* Retrieves the Client website url
|
||||||
|
|
|
@ -20,7 +20,9 @@ package org.adempiere.webui.component;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.adempiere.webui.LayoutUtils;
|
import org.adempiere.webui.LayoutUtils;
|
||||||
|
@ -32,6 +34,7 @@ import org.zkoss.zk.ui.Component;
|
||||||
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.zul.Label;
|
import org.zkoss.zul.Label;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,8 +70,10 @@ public class CWindowToolbar extends FToolbar implements EventListener
|
||||||
// private ToolBarButton btnExit;
|
// private ToolBarButton btnExit;
|
||||||
|
|
||||||
private ArrayList<ToolbarListener> listeners = new ArrayList<ToolbarListener>();
|
private ArrayList<ToolbarListener> listeners = new ArrayList<ToolbarListener>();
|
||||||
|
|
||||||
private Event event;
|
private Event event;
|
||||||
|
|
||||||
|
private Map<Integer, ToolBarButton> keyMap = new HashMap<Integer, ToolBarButton>();
|
||||||
|
|
||||||
public CWindowToolbar()
|
public CWindowToolbar()
|
||||||
{
|
{
|
||||||
|
@ -259,11 +264,28 @@ private Event event;
|
||||||
btnGridToggle.setDisabled(false);
|
btnGridToggle.setDisabled(false);
|
||||||
|
|
||||||
btnZoomAcross.setDisabled(false);
|
btnZoomAcross.setDisabled(false);
|
||||||
|
|
||||||
btnActiveWorkflows.setDisabled(false); // Elaine 2008/07/17
|
btnActiveWorkflows.setDisabled(false); // Elaine 2008/07/17
|
||||||
|
|
||||||
|
configureKeyMap();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addSeparator()
|
private void configureKeyMap() {
|
||||||
|
keyMap.put(KeyEvent.F1, btnHelp);
|
||||||
|
keyMap.put(KeyEvent.F2, btnNew);
|
||||||
|
keyMap.put(KeyEvent.F3, btnDelete);
|
||||||
|
keyMap.put(KeyEvent.F4, btnSave);
|
||||||
|
keyMap.put(KeyEvent.F5, btnRefresh);
|
||||||
|
keyMap.put(KeyEvent.F6, btnFind);
|
||||||
|
keyMap.put(KeyEvent.F7, btnAttachment);
|
||||||
|
keyMap.put(KeyEvent.F8, btnGridToggle);
|
||||||
|
keyMap.put(KeyEvent.F9, btnHistoryRecords);
|
||||||
|
keyMap.put(KeyEvent.F11, btnReport);
|
||||||
|
keyMap.put(KeyEvent.F12, btnPrint);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addSeparator()
|
||||||
{
|
{
|
||||||
Label lblSeparator = new Label();
|
Label lblSeparator = new Label();
|
||||||
lblSeparator.setWidth("3px");
|
lblSeparator.setWidth("3px");
|
||||||
|
@ -286,49 +308,57 @@ private Event event;
|
||||||
{
|
{
|
||||||
String eventName = event.getName();
|
String eventName = event.getName();
|
||||||
Component eventComp = event.getTarget();
|
Component eventComp = event.getTarget();
|
||||||
|
|
||||||
Iterator<ToolbarListener> listenerIter = listeners.iterator();
|
|
||||||
if(eventName.equals(Events.ON_CLICK))
|
if(eventName.equals(Events.ON_CLICK))
|
||||||
{
|
{
|
||||||
if(eventComp instanceof ToolBarButton)
|
if(event.getTarget() instanceof ToolBarButton)
|
||||||
{
|
{
|
||||||
this.event = event;
|
doOnClick(event);
|
||||||
ToolBarButton cComponent = (ToolBarButton) eventComp;
|
|
||||||
String compName = cComponent.getName();
|
|
||||||
String methodName = "on" + compName.substring(3);
|
|
||||||
while(listenerIter.hasNext())
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ToolbarListener tListener = listenerIter.next();
|
|
||||||
Method method = tListener.getClass().getMethod(methodName, (Class[]) null);
|
|
||||||
method.invoke(tListener, (Object[]) null);
|
|
||||||
}
|
|
||||||
catch(SecurityException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
|
||||||
}
|
|
||||||
catch(NoSuchMethodException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
|
||||||
}
|
|
||||||
catch(IllegalArgumentException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
|
||||||
}
|
|
||||||
catch(IllegalAccessException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
|
||||||
}
|
|
||||||
catch(InvocationTargetException e)
|
|
||||||
{
|
|
||||||
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.event = null;
|
|
||||||
}
|
}
|
||||||
|
} else if (eventName.equals(Events.ON_CTRL_KEY))
|
||||||
|
{
|
||||||
|
KeyEvent keyEvent = (KeyEvent) event;
|
||||||
|
this.onCtrlKeyEvent(keyEvent.getKeyCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void doOnClick(Event event) {
|
||||||
|
this.event = event;
|
||||||
|
ToolBarButton cComponent = (ToolBarButton) event.getTarget();
|
||||||
|
String compName = cComponent.getName();
|
||||||
|
String methodName = "on" + compName.substring(3);
|
||||||
|
Iterator<ToolbarListener> listenerIter = listeners.iterator();
|
||||||
|
while(listenerIter.hasNext())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ToolbarListener tListener = listenerIter.next();
|
||||||
|
Method method = tListener.getClass().getMethod(methodName, (Class[]) null);
|
||||||
|
method.invoke(tListener, (Object[]) null);
|
||||||
|
}
|
||||||
|
catch(SecurityException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
||||||
|
}
|
||||||
|
catch(NoSuchMethodException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
||||||
|
}
|
||||||
|
catch(IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
||||||
|
}
|
||||||
|
catch(IllegalAccessException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
||||||
|
}
|
||||||
|
catch(InvocationTargetException e)
|
||||||
|
{
|
||||||
|
log.log(Level.SEVERE, "Could not invoke Toolbar listener method: " + methodName + "()", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.event = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void enableHistoryRecords(boolean enabled)
|
public void enableHistoryRecords(boolean enabled)
|
||||||
{
|
{
|
||||||
|
@ -460,4 +490,26 @@ private Event event;
|
||||||
{
|
{
|
||||||
return event;
|
return event;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onCtrlKeyEvent(int keycode) {
|
||||||
|
if (isRealVisible()) {
|
||||||
|
ToolBarButton btn = keyMap.get(keycode);
|
||||||
|
if (btn != null && !btn.isDisabled() && btn.isVisible()) {
|
||||||
|
Events.sendEvent(btn, new Event(Events.ON_CLICK, btn));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRealVisible() {
|
||||||
|
if (!isVisible())
|
||||||
|
return false;
|
||||||
|
Component parent = this.getParent();
|
||||||
|
while (parent != null) {
|
||||||
|
if (!parent.isVisible())
|
||||||
|
return false;
|
||||||
|
parent = parent.getParent();
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.compiere.model.GridTab;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.event.EventListener;
|
import org.zkoss.zk.ui.event.EventListener;
|
||||||
import org.zkoss.zul.Div;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -45,7 +44,7 @@ public class CompositeADTab extends AbstractADTab
|
||||||
|
|
||||||
private List<ADTabListModel.ADTabLabel> tabLabelList = new ArrayList<ADTabListModel.ADTabLabel>();
|
private List<ADTabListModel.ADTabLabel> tabLabelList = new ArrayList<ADTabListModel.ADTabLabel>();
|
||||||
|
|
||||||
private Div div;
|
private Window window;
|
||||||
|
|
||||||
protected ADButtonTabList tabList;
|
protected ADButtonTabList tabList;
|
||||||
|
|
||||||
|
@ -57,20 +56,21 @@ public class CompositeADTab extends AbstractADTab
|
||||||
|
|
||||||
protected Component doCreatePart(Component parent)
|
protected Component doCreatePart(Component parent)
|
||||||
{
|
{
|
||||||
div = new Div();
|
window = new Window();
|
||||||
if (parent != null) {
|
if (parent != null) {
|
||||||
div.setParent(parent);
|
window.setParent(parent);
|
||||||
LayoutUtils.addSclass("adtab-body", div);
|
LayoutUtils.addSclass("adtab-body", window);
|
||||||
|
window.setContentSclass("adtab-body");
|
||||||
} else {
|
} else {
|
||||||
div.setPage(page);
|
window.setPage(page);
|
||||||
}
|
}
|
||||||
|
window.setCtrlKeys("#f1#f2#f3#f4#f5#f6#f7#f8#f9#f10#f11#f12");
|
||||||
return div;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void doAddTab(GridTab gTab, IADTabpanel tabPanel) {
|
protected void doAddTab(GridTab gTab, IADTabpanel tabPanel) {
|
||||||
tabPanel.setParent(div);
|
tabPanel.setParent(window);
|
||||||
tabPanel.setVisible(false);
|
tabPanel.setVisible(false);
|
||||||
|
|
||||||
ADTabListModel.ADTabLabel tabLabel = new ADTabListModel.ADTabLabel(gTab.getName(), gTab.getTabLevel());
|
ADTabListModel.ADTabLabel tabLabel = new ADTabListModel.ADTabLabel(gTab.getName(), gTab.getTabLevel());
|
||||||
|
@ -141,6 +141,6 @@ public class CompositeADTab extends AbstractADTab
|
||||||
}
|
}
|
||||||
|
|
||||||
public Component getComponent() {
|
public Component getComponent() {
|
||||||
return div;
|
return window;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@
|
||||||
package org.adempiere.webui.component;
|
package org.adempiere.webui.component;
|
||||||
|
|
||||||
import org.zkoss.zk.ui.WrongValueException;
|
import org.zkoss.zk.ui.WrongValueException;
|
||||||
import org.zkoss.zul.Constraint;
|
|
||||||
import org.zkoss.zul.SimpleConstraint;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
@ -29,12 +29,14 @@ import org.adempiere.webui.component.Tabs;
|
||||||
import org.compiere.util.CLogger;
|
import org.compiere.util.CLogger;
|
||||||
import org.zkoss.zk.ui.Component;
|
import org.zkoss.zk.ui.Component;
|
||||||
import org.zkoss.zk.ui.HtmlBasedComponent;
|
import org.zkoss.zk.ui.HtmlBasedComponent;
|
||||||
|
import org.zkoss.zk.ui.event.Events;
|
||||||
import org.zkoss.zkex.zul.Borderlayout;
|
import org.zkoss.zkex.zul.Borderlayout;
|
||||||
import org.zkoss.zkex.zul.Center;
|
import org.zkoss.zkex.zul.Center;
|
||||||
import org.zkoss.zkex.zul.North;
|
import org.zkoss.zkex.zul.North;
|
||||||
import org.zkoss.zkex.zul.South;
|
import org.zkoss.zkex.zul.South;
|
||||||
import org.zkoss.zkex.zul.West;
|
import org.zkoss.zkex.zul.West;
|
||||||
import org.zkoss.zul.Tab;
|
import org.zkoss.zul.Tab;
|
||||||
|
import org.zkoss.zul.Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -69,7 +71,7 @@ public class ADWindowPanel extends AbstractADWindowPanel
|
||||||
protected Component doCreatePart(Component parent)
|
protected Component doCreatePart(Component parent)
|
||||||
{
|
{
|
||||||
layout = new Borderlayout();
|
layout = new Borderlayout();
|
||||||
if (layout != null) {
|
if (parent != null) {
|
||||||
layout.setParent(parent);
|
layout.setParent(parent);
|
||||||
layout.setStyle("position:absolute");
|
layout.setStyle("position:absolute");
|
||||||
layout.setHeight("100%");
|
layout.setHeight("100%");
|
||||||
|
@ -112,6 +114,11 @@ public class ADWindowPanel extends AbstractADWindowPanel
|
||||||
TabOnCloseHanlder handler = new TabOnCloseHanlder();
|
TabOnCloseHanlder handler = new TabOnCloseHanlder();
|
||||||
((Tabpanel)parent).setOnCloseHandler(handler);
|
((Tabpanel)parent).setOnCloseHandler(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (adTab.getComponent() instanceof Window) {
|
||||||
|
Window w = (Window) adTab.getComponent();
|
||||||
|
w.addEventListener(Events.ON_CTRL_KEY, toolbar);
|
||||||
|
}
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ public abstract class AbstractUIPart implements UIPart {
|
||||||
page = (Page)parent;
|
page = (Page)parent;
|
||||||
} else if (parent instanceof Component) {
|
} else if (parent instanceof Component) {
|
||||||
component = (Component)parent;
|
component = (Component)parent;
|
||||||
|
page = component.getPage();
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Parent must of class Page or Component.");
|
throw new IllegalArgumentException("Parent must of class Page or Component.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,15 +188,17 @@ tr.tab-desktop-tb-m {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
border: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.adtab-content {
|
.adtab-content {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
border: none;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.adtab-grid-panel {
|
.adtab-grid-panel {
|
||||||
|
|
Loading…
Reference in New Issue