IDEMPIERE-2050 Improvement to Menu Lookup. Fixed binding for enter key not working when header is hidden. Minor layout fix.

This commit is contained in:
Heng Sin Low 2014-07-11 13:14:13 +08:00
parent f48169f81e
commit ec8aa119f0
1 changed files with 22 additions and 18 deletions

View File

@ -14,6 +14,7 @@
package org.adempiere.webui.apps; package org.adempiere.webui.apps;
import org.adempiere.webui.component.Bandbox; import org.adempiere.webui.component.Bandbox;
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;
@ -68,29 +69,23 @@ public class GlobalSearch extends Div implements EventListener<Event> {
bandbox.addEventListener(Events.ON_CTRL_KEY, this); bandbox.addEventListener(Events.ON_CTRL_KEY, this);
Bandpopup popup = new Bandpopup(); Bandpopup popup = new Bandpopup();
popup.setWidth("700px");
popup.setHeight("600px"); popup.setHeight("600px");
bandbox.appendChild(popup); bandbox.appendChild(popup);
Hlayout hlayout = new Hlayout(); Hlayout hlayout = new Hlayout();
hlayout.setHflex("1");
popup.appendChild(hlayout); popup.appendChild(hlayout);
menuController.create(hlayout); menuController.create(hlayout);
Separator separator = new Separator(); Separator separator = new Separator();
separator.setHeight("100%");
separator.setBar(true);
separator.setHflex("0"); separator.setHflex("0");
separator.setOrient("horizontal"); separator.setOrient("vertical");
hlayout.appendChild(separator); hlayout.appendChild(separator);
docController.create(hlayout); docController.create(hlayout);
addEventListener(ON_SEARCH, this); addEventListener(ON_SEARCH, this);
addEventListener(ON_CREATE_ECHO, this); addEventListener(ON_CREATE_ECHO, this);
bandbox.addEventListener(ON_ENTER_KEY, this); bandbox.addEventListener(ON_ENTER_KEY, this);
addEventListener(ON_POST_ENTER_KEY, this); addEventListener(ON_POST_ENTER_KEY, this);
Events.echoEvent(ON_CREATE_ECHO, this, null);
} }
@Override @Override
@ -122,16 +117,16 @@ public class GlobalSearch extends Div implements EventListener<Event> {
docController.search(value); docController.search(value);
bandbox.focus(); bandbox.focus();
} else if (event.getName().equals(ON_CREATE_ECHO)) { } else if (event.getName().equals(ON_CREATE_ECHO)) {
StringBuilder script = new StringBuilder("jq('#") StringBuilder script = new StringBuilder("jq('#")
.append(bandbox.getUuid()) .append(bandbox.getUuid())
.append("').bind('keydown', function(e) {var code=e.keyCode||e.which;console.log(code);if(code==13){") .append("').bind('keydown', function(e) {var code=e.keyCode||e.which;console.log(code);if(code==13){")
.append("var widget=zk.Widget.$('#").append(bandbox.getUuid()).append("');") .append("var widget=zk.Widget.$(this);")
.append("var event=new zk.Event(widget,'") .append("var event=new zk.Event(widget,'")
.append(ON_ENTER_KEY) .append(ON_ENTER_KEY)
.append("',{},{toServer:true});") .append("',{},{toServer:true});")
.append("zAu.send(event);") .append("zAu.send(event);")
.append("}});"); .append("}});");
Clients.evalJavaScript(script.toString()); Clients.evalJavaScript(script.toString());
} else if (event.getName().equals(ON_ENTER_KEY)) { } else if (event.getName().equals(ON_ENTER_KEY)) {
Clients.showBusy(bandbox, null); Clients.showBusy(bandbox, null);
Events.echoEvent(ON_POST_ENTER_KEY, this, null); Events.echoEvent(ON_POST_ENTER_KEY, this, null);
@ -144,4 +139,13 @@ public class GlobalSearch extends Div implements EventListener<Event> {
} }
} }
} }
/* (non-Javadoc)
* @see org.zkoss.zk.ui.AbstractComponent#onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
*/
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
Events.echoEvent(ON_CREATE_ECHO, this, null);
}
} }