diff options
author | Artur Signell <artur.signell@itmill.com> | 2010-06-24 11:38:41 +0000 |
---|---|---|
committer | Artur Signell <artur.signell@itmill.com> | 2010-06-24 11:38:41 +0000 |
commit | 885bc4718cbf62aa9f7dd8a68c2aa89f3245a172 (patch) | |
tree | 56fd154dd45435bed3754aeef6df90cadc456a6b /src | |
parent | 150bd837f749b4db0a88ddbdaf7f6d73a93005a1 (diff) | |
download | vaadin-framework-885bc4718cbf62aa9f7dd8a68c2aa89f3245a172.tar.gz vaadin-framework-885bc4718cbf62aa9f7dd8a68c2aa89f3245a172.zip |
Allow referencing ComboBox menu items as VFilterSelect$SuggestionMenu[0]#itemX
svn changeset:13908/svn branch:6.4
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java index eb8dc85705..bcda91266c 100644 --- a/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java +++ b/src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java @@ -491,7 +491,7 @@ public class VFilterSelect extends Composite implements Paintable, Field, /** * The menu where the suggestions are rendered */ - public class SuggestionMenu extends MenuBar { + public class SuggestionMenu extends MenuBar implements SubPartAware { /** * Default constructor @@ -659,6 +659,39 @@ public class VFilterSelect extends Composite implements Paintable, Field, } 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; |