/**
* The menu where the suggestions are rendered
*/
- public class SuggestionMenu extends MenuBar {
+ public class SuggestionMenu extends MenuBar implements SubPartAware {
/**
* Default constructor
}
super.onBrowserEvent(event);
}
+
+ private static final String SUBPART_PREFIX = "item";
+
+ public Element getSubPartElement(String subPart) {
+ int index = Integer.parseInt(subPart.substring(SUBPART_PREFIX
+ .length()));
+
+ MenuItem item = (MenuItem) getItems().get(index);
+
+ return item.getElement();
+ }
+
+ public String getSubPartName(Element subElement) {
+ if (!getElement().isOrHasChild(subElement)) {
+ return null;
+ }
+
+ Element menuItemRoot = subElement;
+ while (menuItemRoot != null
+ && !menuItemRoot.getTagName().equalsIgnoreCase("td")) {
+ menuItemRoot = menuItemRoot.getParentElement().cast();
+ }
+ // "menuItemRoot" is now the root of the menu item
+
+ final int itemCount = getItems().size();
+ for (int i = 0; i < itemCount; i++) {
+ if (((MenuItem) getItems().get(i)).getElement() == menuItemRoot) {
+ String name = SUBPART_PREFIX + i;
+ return name;
+ }
+ }
+ return null;
+ }
}
public static final int FILTERINGMODE_OFF = 0;