IDEMPIERE-943 Menu Lookup not showing dup names
This commit is contained in:
parent
603ddd7bc0
commit
bc9148858c
|
@ -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()) {
|
||||
|
|
|
@ -143,6 +143,7 @@ public class MenuTreeSearchPanel extends TreeSearchPanel {
|
|||
List<String> valueList = new ArrayList<String>();
|
||||
List<String> descriptionList = new ArrayList<String>();
|
||||
List<String> imageList = new ArrayList<String>();
|
||||
List<String> typeList = new ArrayList<String>();
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
|
|||
private static final long serialVersionUID = 3478451169922775667L;
|
||||
protected TreeMap<String, Object> treeNodeItemMap = new TreeMap<String, Object>();
|
||||
protected String[] treeValues;
|
||||
protected String[] treeTypes;
|
||||
protected String[] treeDescription;
|
||||
protected String[] treeImages;
|
||||
|
||||
|
@ -176,8 +177,8 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, 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<Event>, 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<Event>, 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<Event>, 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<Event>, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue