IDEMPIERE-943 Menu Lookup not showing dup names

This commit is contained in:
Richard Morales 2013-05-28 20:37:40 -05:00
parent 603ddd7bc0
commit bc9148858c
3 changed files with 62 additions and 6 deletions

View File

@ -45,6 +45,8 @@ public class AutoComplete extends Combobox
private String[] strDescription; private String[] strDescription;
private String[] images; private String[] images;
private String[] contents;
/** /**
* Set menu labels * Set menu labels
@ -73,6 +75,17 @@ public class AutoComplete extends Combobox
strDescription = vals; 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) public void setImages(String[] images)
{ {
this.images = images; this.images = images;
@ -151,10 +164,15 @@ public class AutoComplete extends Combobox
comboitem.setLabel(comboItems[i]); comboitem.setLabel(comboItems[i]);
comboitem.setDescription(strDescription[i]); comboitem.setDescription(strDescription[i]);
if (images != null && i < images.length && images[i] != null && images[i].trim().length() > 0) if (images != null && i < images.length && images[i] != null && images[i].trim().length() > 0)
{ {
comboitem.setImage(images[i]); 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()) { while (it != null && it.hasNext()) {

View File

@ -143,6 +143,7 @@ public class MenuTreeSearchPanel extends TreeSearchPanel {
List<String> valueList = new ArrayList<String>(); List<String> valueList = new ArrayList<String>();
List<String> descriptionList = new ArrayList<String>(); List<String> descriptionList = new ArrayList<String>();
List<String> imageList = new ArrayList<String>(); List<String> imageList = new ArrayList<String>();
List<String> typeList = new ArrayList<String>();
for (Object value : treeNodeItemMap.values()) for (Object value : treeNodeItemMap.values())
{ {
@ -160,6 +161,7 @@ public class MenuTreeSearchPanel extends TreeSearchPanel {
valueList.add(getLabel(treeItem)); valueList.add(getLabel(treeItem));
descriptionList.add(treeItem.getTooltiptext()); descriptionList.add(treeItem.getTooltiptext());
typeList.add(String.valueOf(treeItem.getAttribute("menu.type")));
String image = getImage(treeItem); String image = getImage(treeItem);
if (image == null || image.length() == 0) if (image == null || image.length() == 0)
{ {
@ -185,14 +187,17 @@ public class MenuTreeSearchPanel extends TreeSearchPanel {
imageList.add(mNode.getImagePath()); imageList.add(mNode.getImagePath());
} }
} }
treeDescription = descriptionList.toArray(new String[0]); treeDescription = descriptionList.toArray(new String[0]);
treeValues = valueList.toArray(new String[0]); treeValues = valueList.toArray(new String[0]);
treeImages = imageList.toArray(new String[0]); treeImages = imageList.toArray(new String[0]);
treeTypes = typeList.toArray(new String[0]);
orderArrays();
cmbSearch.setDescription(treeDescription); cmbSearch.setDescription(treeDescription);
cmbSearch.setDict(treeValues); cmbSearch.setDict(treeValues);
cmbSearch.setImages(treeImages); cmbSearch.setImages(treeImages);
cmbSearch.setContents(treeTypes);
cmbSearch.refresh(""); cmbSearch.refresh("");
} }
@ -216,4 +221,33 @@ public class MenuTreeSearchPanel extends TreeSearchPanel {
Events.postEvent(event); Events.postEvent(event);
Events.echoEvent(ON_POST_FIRE_TREE_EVENT, this, null); 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;
}
}
}
}
} }

View File

@ -72,6 +72,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
private static final long serialVersionUID = 3478451169922775667L; private static final long serialVersionUID = 3478451169922775667L;
protected TreeMap<String, Object> treeNodeItemMap = new TreeMap<String, Object>(); protected TreeMap<String, Object> treeNodeItemMap = new TreeMap<String, Object>();
protected String[] treeValues; protected String[] treeValues;
protected String[] treeTypes;
protected String[] treeDescription; protected String[] treeDescription;
protected String[] treeImages; protected String[] treeImages;
@ -176,8 +177,8 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
protected void addTreeItem(Treeitem treeItem) protected void addTreeItem(Treeitem treeItem)
{ {
String key = getLabel(treeItem); StringBuilder key = new StringBuilder(getLabel(treeItem)).append(".").append(treeItem.getAttribute("menu.type"));
treeNodeItemMap.put(key, treeItem); treeNodeItemMap.put(key.toString(), treeItem);
} }
protected void addTreeItem(DefaultTreeNode<?> node) { protected void addTreeItem(DefaultTreeNode<?> node) {
@ -221,9 +222,9 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
treeValues = new String[treeNodeItemMap.size()]; treeValues = new String[treeNodeItemMap.size()];
treeDescription = new String[treeNodeItemMap.size()]; treeDescription = new String[treeNodeItemMap.size()];
treeImages = new String[treeNodeItemMap.size()]; treeImages = new String[treeNodeItemMap.size()];
treeTypes = new String[treeNodeItemMap.size()];
int i = -1; int i = -1;
for (Object value : treeNodeItemMap.values()) for (Object value : treeNodeItemMap.values())
{ {
i++; i++;
@ -231,6 +232,7 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
{ {
Treeitem treeItem = (Treeitem) value; Treeitem treeItem = (Treeitem) value;
treeValues[i] = getLabel(treeItem); treeValues[i] = getLabel(treeItem);
treeTypes[i]= String.valueOf(treeItem.getAttribute("menu.type"));
treeDescription[i] = treeItem.getTooltiptext(); treeDescription[i] = treeItem.getTooltiptext();
treeImages[i] = getImage(treeItem); treeImages[i] = getImage(treeItem);
if ((treeImages[i] == null || treeImages[i].trim().length() == 0) && isFolder(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.setDescription(treeDescription);
cmbSearch.setDict(treeValues); cmbSearch.setDict(treeValues);
cmbSearch.setImages(treeImages); cmbSearch.setImages(treeImages);
cmbSearch.setContents(treeTypes);
} }
protected boolean isFolder(Treeitem treeItem) { protected boolean isFolder(Treeitem treeItem) {
@ -353,8 +356,9 @@ public class TreeSearchPanel extends Panel implements EventListener<Event>, Tree
if (comp.getUuid().equals(uuid)) if (comp.getUuid().equals(uuid))
{ {
Comboitem item = (Comboitem) comp; Comboitem item = (Comboitem) comp;
String value = item.getLabel(); String value = item.getLabel();
selectTreeitem(value); String type = item.getContent();
selectTreeitem(value+"."+type);
} }
} }
} }