IDEMPIERE-442 Menu Lookup not working if you repeat search

This commit is contained in:
Heng Sin Low 2012-11-09 16:32:21 +08:00
parent ad5d338dfd
commit 4993ffe5bf
3 changed files with 32 additions and 4 deletions

View File

@ -17,6 +17,7 @@ import java.util.Enumeration;
import org.adempiere.webui.adwindow.ADWindow;
import org.adempiere.webui.exception.ApplicationException;
import org.adempiere.webui.panel.TreeSearchPanel;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.FDialog;
import org.compiere.model.GridTab;
@ -36,6 +37,7 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.A;
import org.zkoss.zul.Box;
import org.zkoss.zul.Combobox;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Image;
import org.zkoss.zul.Label;
@ -214,6 +216,24 @@ public class DPFavourites extends DashboardPanel implements EventListener<Event>
addItem(treeitem);
}
else if(dragged instanceof Combobox)
{
TreeSearchPanel tsp = null;
Component parent = dragged.getParent();
while(tsp == null && parent != null) {
if (parent instanceof TreeSearchPanel) {
tsp = (TreeSearchPanel) parent;
} else {
parent = parent.getParent();
}
}
if (tsp != null) {
Treeitem treeitem = tsp.getSelectedItem();
if (treeitem != null) {
addItem(treeitem);
}
}
}
}
else if(comp instanceof Image)
{
@ -222,7 +242,7 @@ public class DPFavourites extends DashboardPanel implements EventListener<Event>
A btn = (A) dragged;
removeLink(btn);
}
}
}
}
//
}

View File

@ -20,7 +20,6 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.EventQueues;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Checkbox;
import org.zkoss.zul.Style;
import org.zkoss.zul.Toolbar;
/**
@ -46,6 +45,7 @@ public class MenuSearchPanel extends AbstractMenuPanel
{
super.init();
pnlSearch.initialise();
pnlSearch.cmbSearch.setDraggable("favourite");
EventQueues.lookup(MenuTreeFilterPanel.MENU_TREE_FILTER_CHECKED_QUEUE, EventQueues.APPLICATION, true).subscribe(new EventListener<Event>() {
public void onEvent(Event event) throws Exception {

View File

@ -66,13 +66,14 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
private String[] treeImages;
private Label lblSearch;
private AutoComplete cmbSearch;
protected AutoComplete cmbSearch;
private Tree tree;
private String eventToFire;
private int m_windowno = 0;
private int m_tabno = 0;
private Treeitem selectedItem;
private static final String PREFIX_DOCUMENT_SEARCH = "/";
@ -123,6 +124,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
cmbSearch.setAttribute(AdempiereIdGenerator.ZK_COMPONENT_PREFIX_ATTRIBUTE, "unqCmbSearch" + "_" + m_windowno + "_" + m_tabno);
cmbSearch.addEventListener(Events.ON_CHANGE, this);
cmbSearch.addEventListener(Events.ON_OK, this);
if (AEnv.isInternetExplorer())
{
cmbSearch.setWidth("200px");
@ -256,8 +258,9 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
*/
public void onEvent(Event event)
{
if (cmbSearch.equals(event.getTarget()) && (event.getName().equals(Events.ON_CHANGE)))
if (cmbSearch.equals(event.getTarget()) && ((event.getName().equals(Events.ON_CHANGE) || event.getName().equals(Events.ON_OK))))
{
selectedItem = null;
String value = cmbSearch.getValue();
if (value != null && value.trim().length() > 0
@ -283,6 +286,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
}
if (treeItem != null)
{
selectedItem = treeItem;
select(treeItem);
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"));
Events.echoEvent("onPostSelect", this, null);
@ -330,4 +334,8 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
public void onChange(TreeDataEvent event) {
refreshSearchList();
}
public Treeitem getSelectedItem() {
return selectedItem;
}
}