summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2010-06-16 10:29:11 +0000
committerArtur Signell <artur.signell@itmill.com>2010-06-16 10:29:11 +0000
commit060fdacf4e76d8550a9d19e9d4b2dc49cfcc2aab (patch)
tree66ef61b476e745a8e7c4a097567b451dce6f7676 /src
parent3e3f2d4d2df107d29efe4e8736bf0ac4ca93ec98 (diff)
downloadvaadin-framework-060fdacf4e76d8550a9d19e9d4b2dc49cfcc2aab.tar.gz
vaadin-framework-060fdacf4e76d8550a9d19e9d4b2dc49cfcc2aab.zip
Added better support for menu identification for TestBench
svn changeset:13695/svn branch:6.4
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
index 0721e8e238..3f25579291 100644
--- a/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
+++ b/src/com/vaadin/terminal/gwt/client/ui/VMenuBar.java
@@ -39,7 +39,7 @@ import com.vaadin.terminal.gwt.client.Util;
public class VMenuBar extends SimpleFocusablePanel implements Paintable,
CloseHandler<PopupPanel>, ContainerResizedListener, KeyPressHandler,
- KeyDownHandler, BlurHandler, FocusHandler {
+ KeyDownHandler, BlurHandler, FocusHandler, SubPartAware {
/** Set the CSS class name to allow styling. */
public static final String CLASSNAME = "v-menubar";
@@ -1288,4 +1288,36 @@ public class VMenuBar extends SimpleFocusablePanel implements Paintable,
focusDelayTimer.schedule(100);
}
+
+ private final String SUBPART_PREFIX = "item";
+
+ public Element getSubPartElement(String subPart) {
+ int index = Integer
+ .parseInt(subPart.substring(SUBPART_PREFIX.length()));
+ CustomMenuItem item = getItems().get(index);
+
+ return item.getElement();
+ }
+
+ public String getSubPartName(Element subElement) {
+ if (!getElement().isOrHasChild(subElement)) {
+ return null;
+ }
+
+ Element menuItemRoot = subElement;
+ while (menuItemRoot != null && menuItemRoot.getParentElement() != null
+ && menuItemRoot.getParentElement() != getElement()) {
+ 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 (getItems().get(i).getElement() == menuItemRoot) {
+ String name = SUBPART_PREFIX + i;
+ return name;
+ }
+ }
+ return null;
+ }
}