From bc9148858cfc1e177396263d06e5e1aaede60f7f Mon Sep 17 00:00:00 2001 From: Richard Morales Date: Tue, 28 May 2013 20:37:40 -0500 Subject: [PATCH] IDEMPIERE-943 Menu Lookup not showing dup names --- .../webui/component/AutoComplete.java | 18 ++++++++++ .../webui/panel/MenuTreeSearchPanel.java | 36 ++++++++++++++++++- .../webui/panel/TreeSearchPanel.java | 14 +++++--- 3 files changed, 62 insertions(+), 6 deletions(-) diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java index c48fb34e89..86963c2e3b 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/AutoComplete.java @@ -45,6 +45,8 @@ public class AutoComplete extends Combobox private String[] strDescription; private String[] images; + + private String[] contents; /** * Set menu labels @@ -73,6 +75,17 @@ public class AutoComplete extends Combobox strDescription = vals; } + /** + * Set content of menu items + * + * @param vals Content of menu items + */ + + public void setContents(String[] vals) + { + contents = vals; + } + public void setImages(String[] images) { this.images = images; @@ -151,10 +164,15 @@ public class AutoComplete extends Combobox comboitem.setLabel(comboItems[i]); comboitem.setDescription(strDescription[i]); + if (images != null && i < images.length && images[i] != null && images[i].trim().length() > 0) { comboitem.setImage(images[i]); } + if (contents != null && i < contents.length && contents[i] != null && contents[i].trim().length() > 0) + { + comboitem.setContent(contents[i]); + } } } while (it != null && it.hasNext()) { diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuTreeSearchPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuTreeSearchPanel.java index 0fec6fd65e..a85644a7be 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuTreeSearchPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/MenuTreeSearchPanel.java @@ -143,6 +143,7 @@ public class MenuTreeSearchPanel extends TreeSearchPanel { List valueList = new ArrayList(); List descriptionList = new ArrayList(); List imageList = new ArrayList(); + List typeList = new ArrayList(); for (Object value : treeNodeItemMap.values()) { @@ -160,6 +161,7 @@ public class MenuTreeSearchPanel extends TreeSearchPanel { valueList.add(getLabel(treeItem)); descriptionList.add(treeItem.getTooltiptext()); + typeList.add(String.valueOf(treeItem.getAttribute("menu.type"))); String image = getImage(treeItem); if (image == null || image.length() == 0) { @@ -185,14 +187,17 @@ public class MenuTreeSearchPanel extends TreeSearchPanel { imageList.add(mNode.getImagePath()); } } - + treeDescription = descriptionList.toArray(new String[0]); treeValues = valueList.toArray(new String[0]); treeImages = imageList.toArray(new String[0]); + treeTypes = typeList.toArray(new String[0]); + orderArrays(); cmbSearch.setDescription(treeDescription); cmbSearch.setDict(treeValues); cmbSearch.setImages(treeImages); + cmbSearch.setContents(treeTypes); cmbSearch.refresh(""); } @@ -216,4 +221,33 @@ public class MenuTreeSearchPanel extends TreeSearchPanel { Events.postEvent(event); Events.echoEvent(ON_POST_FIRE_TREE_EVENT, this, null); } + + protected void orderArrays() + { + String aux; + for (int i = 1; i < treeValues.length; i++) + { + for(int j = 0;j < treeValues.length-i;j++) + { + if(treeValues[j].compareTo(treeValues[j+1]) > 0) + { + aux = treeValues[j]; + treeValues[j] = treeValues[j+1]; + treeValues[j+1]=aux; + + aux = treeDescription[j]; + treeDescription[j] = treeDescription[j+1]; + treeDescription[j+1]=aux; + + aux = treeTypes[j]; + treeTypes[j] = treeTypes[j+1]; + treeTypes[j+1]=aux; + + aux = treeImages[j]; + treeImages[j] = treeImages[j+1]; + treeImages[j+1]=aux; + } + } + } + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java index 70d21e73a0..745fb58b80 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/panel/TreeSearchPanel.java @@ -72,6 +72,7 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree private static final long serialVersionUID = 3478451169922775667L; protected TreeMap treeNodeItemMap = new TreeMap(); protected String[] treeValues; + protected String[] treeTypes; protected String[] treeDescription; protected String[] treeImages; @@ -176,8 +177,8 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree protected void addTreeItem(Treeitem treeItem) { - String key = getLabel(treeItem); - treeNodeItemMap.put(key, treeItem); + StringBuilder key = new StringBuilder(getLabel(treeItem)).append(".").append(treeItem.getAttribute("menu.type")); + treeNodeItemMap.put(key.toString(), treeItem); } protected void addTreeItem(DefaultTreeNode node) { @@ -221,9 +222,9 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree treeValues = new String[treeNodeItemMap.size()]; treeDescription = new String[treeNodeItemMap.size()]; treeImages = new String[treeNodeItemMap.size()]; + treeTypes = new String[treeNodeItemMap.size()]; int i = -1; - for (Object value : treeNodeItemMap.values()) { i++; @@ -231,6 +232,7 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree { Treeitem treeItem = (Treeitem) value; treeValues[i] = getLabel(treeItem); + treeTypes[i]= String.valueOf(treeItem.getAttribute("menu.type")); treeDescription[i] = treeItem.getTooltiptext(); treeImages[i] = getImage(treeItem); if ((treeImages[i] == null || treeImages[i].trim().length() == 0) && isFolder(treeItem)) @@ -267,6 +269,7 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree cmbSearch.setDescription(treeDescription); cmbSearch.setDict(treeValues); cmbSearch.setImages(treeImages); + cmbSearch.setContents(treeTypes); } protected boolean isFolder(Treeitem treeItem) { @@ -353,8 +356,9 @@ public class TreeSearchPanel extends Panel implements EventListener, Tree if (comp.getUuid().equals(uuid)) { Comboitem item = (Comboitem) comp; - String value = item.getLabel(); - selectTreeitem(value); + String value = item.getLabel(); + String type = item.getContent(); + selectTreeitem(value+"."+type); } } }