IDEMPIERE-443 Lookup not working until you click somewhere else. Refactoring.
This commit is contained in:
parent
6982daaaa6
commit
bfdd3f4fc0
|
@ -141,7 +141,7 @@ public class Combobox extends org.zkoss.zul.Combobox implements IdSpace
|
||||||
//http://jira.idempiere.com/browse/IDEMPIERE-443
|
//http://jira.idempiere.com/browse/IDEMPIERE-443
|
||||||
//undocumented api hack to ensure onSelect always fire for mouse selection
|
//undocumented api hack to ensure onSelect always fire for mouse selection
|
||||||
public void clearLastSel() {
|
public void clearLastSel() {
|
||||||
String script = "zk('#"+getUuid()+"').$()._lastsel='';";
|
String script = "zk('#"+getUuid()+"').$()._lastsel=null;";
|
||||||
AuScript response = new AuScript(script);
|
AuScript response = new AuScript(script);
|
||||||
Clients.response(response);
|
Clients.response(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,6 +61,9 @@ import org.zkoss.zul.impl.LabelImageElement;
|
||||||
*/
|
*/
|
||||||
public class TreeSearchPanel extends Panel implements EventListener<Event>, TreeDataListener, IdSpace
|
public class TreeSearchPanel extends Panel implements EventListener<Event>, TreeDataListener, IdSpace
|
||||||
{
|
{
|
||||||
|
private static final String ON_COMBO_SELECT_ECHO_EVENT = "onComboSelectEcho";
|
||||||
|
private static final String ON_POST_SELECT_TREEITEM_EVENT = "onPostSelectTreeitem";
|
||||||
|
private static final String ON_POST_FIRE_TREE_EVENT = "onPostFireTreeEvent";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -118,6 +121,13 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String onComboSelectEchoScript = "var combo=zk('@combo').$();"
|
||||||
|
+ "var panel=zk('@this').$();"
|
||||||
|
+ "var comboitem=zk('@item').$();"
|
||||||
|
+ "var popupheight=combo.getPopupNode_().offsetHeight;"
|
||||||
|
+ "var evt = new zk.Event(panel, 'onComboSelectEcho', [comboitem.uuid, popupheight], {toServer: true});"
|
||||||
|
+ "zAu.send(evt);";
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
Hlayout hLayout = new Hlayout();
|
Hlayout hLayout = new Hlayout();
|
||||||
|
@ -138,20 +148,17 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
Set<Comboitem> set = event.getSelectedItems();
|
Set<Comboitem> set = event.getSelectedItems();
|
||||||
if (set.size() > 0) {
|
if (set.size() > 0) {
|
||||||
Comboitem item = set.iterator().next();
|
Comboitem item = set.iterator().next();
|
||||||
String script = "var combo=zk('#"+cmbSearch.getUuid()+"').$();";
|
String script = onComboSelectEchoScript.replaceFirst("@combo", cmbSearch.getUuid())
|
||||||
script = script + "var panel=zk('#"+TreeSearchPanel.this.getUuid()+"').$();";
|
.replaceFirst("@this", TreeSearchPanel.this.getUuid())
|
||||||
script = script + "var comboitem=zk('#"+item.getUuid()+"').$();console.log(comboitem);";
|
.replaceFirst("@item", item.getUuid());
|
||||||
script = script + "var popupheight=combo.getPopupNode_().offsetHeight;console.log(popupheight);";
|
|
||||||
script = script + "var evt = new zk.Event(panel, 'onComboSelectEcho', [comboitem.uuid, popupheight], {toServer: true});";
|
|
||||||
script = script + "zAu.send(evt);";
|
|
||||||
AuScript response = new AuScript(script);
|
AuScript response = new AuScript(script);
|
||||||
Clients.response(response);
|
Clients.response(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventListener("onComboSelectEcho", this);
|
addEventListener(ON_COMBO_SELECT_ECHO_EVENT, this);
|
||||||
addEventListener("onPostSelectTreeitem", this);
|
addEventListener(ON_POST_SELECT_TREEITEM_EVENT, this);
|
||||||
if (AEnv.isInternetExplorer())
|
if (AEnv.isInternetExplorer())
|
||||||
{
|
{
|
||||||
cmbSearch.setWidth("200px");
|
cmbSearch.setWidth("200px");
|
||||||
|
@ -161,7 +168,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
hLayout.appendChild(cmbSearch);
|
hLayout.appendChild(cmbSearch);
|
||||||
this.appendChild(hLayout);
|
this.appendChild(hLayout);
|
||||||
|
|
||||||
addEventListener("onPostFireTreeEvent", this);
|
addEventListener(ON_POST_FIRE_TREE_EVENT, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addTreeItem(Treeitem treeItem)
|
private void addTreeItem(Treeitem treeItem)
|
||||||
|
@ -309,12 +316,12 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
selectTreeitem(value);
|
selectTreeitem(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event.getName().equals("onPostFireTreeEvent"))
|
else if (event.getName().equals(ON_POST_FIRE_TREE_EVENT))
|
||||||
{
|
{
|
||||||
cmbSearch.setEnabled(true);
|
cmbSearch.setEnabled(true);
|
||||||
cmbSearch.clearLastSel();
|
cmbSearch.clearLastSel();
|
||||||
}
|
}
|
||||||
else if (event.getName().equals("onComboSelectPostBack"))
|
else if (event.getName().equals(ON_COMBO_SELECT_ECHO_EVENT))
|
||||||
{
|
{
|
||||||
Object[] data = (Object[]) event.getData();
|
Object[] data = (Object[]) event.getData();
|
||||||
String uuid = (String) data[0];
|
String uuid = (String) data[0];
|
||||||
|
@ -337,7 +344,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
cmbSearch.clearLastSel();
|
cmbSearch.clearLastSel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (event.getName().equals("onPostSelectTreeitem"))
|
else if (event.getName().equals(ON_POST_SELECT_TREEITEM_EVENT))
|
||||||
{
|
{
|
||||||
onPostSelectTreeitem();
|
onPostSelectTreeitem();
|
||||||
}
|
}
|
||||||
|
@ -367,7 +374,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
|
|
||||||
select(treeItem);
|
select(treeItem);
|
||||||
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"));
|
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"));
|
||||||
Events.echoEvent("onPostSelectTreeitem", this, null);
|
Events.echoEvent(ON_POST_SELECT_TREEITEM_EVENT, this, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,7 +395,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
||||||
else
|
else
|
||||||
event = new Event(eventToFire, tree);
|
event = new Event(eventToFire, tree);
|
||||||
Events.postEvent(event);
|
Events.postEvent(event);
|
||||||
Events.echoEvent("onPostFireTreeEvent", this, null);
|
Events.echoEvent(ON_POST_FIRE_TREE_EVENT, this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void select(Treeitem selectedItem) {
|
public static void select(Treeitem selectedItem) {
|
||||||
|
|
Loading…
Reference in New Issue