aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/itmill/toolkit/terminal/gwt
diff options
context:
space:
mode:
authorMatti Tahvonen <matti.tahvonen@itmill.com>2009-05-07 08:13:59 +0000
committerMatti Tahvonen <matti.tahvonen@itmill.com>2009-05-07 08:13:59 +0000
commitb36d7e04dcb55c5feb544f6355cc25019ba0d744 (patch)
tree384cceca098ee1d57f89fee6406fb9bcad67bb56 /src/com/itmill/toolkit/terminal/gwt
parent226a59f058154ad79c5da94d38f7ff2d16d1f77b (diff)
downloadvaadin-framework-b36d7e04dcb55c5feb544f6355cc25019ba0d744.tar.gz
vaadin-framework-b36d7e04dcb55c5feb544f6355cc25019ba0d744.zip
extended component locator to build forward compatible locators for context menu clicks
svn changeset:7646/svn branch:6.0
Diffstat (limited to 'src/com/itmill/toolkit/terminal/gwt')
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java16
-rw-r--r--src/com/itmill/toolkit/terminal/gwt/client/ui/IContextMenu.java45
2 files changed, 58 insertions, 3 deletions
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java
index fee12345aa..da4aea74e3 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ComponentLocator.java
@@ -66,6 +66,15 @@ public class ComponentLocator {
}
if (e == null || pid == null) {
+
+ // Still test for context menu option
+ String subPartName = client.getContextMenu().getSubPartName(
+ targetElement);
+ if (subPartName != null) {
+ // IContextMenu, singleton attached directly to rootpanel
+ return "/IContextMenu[0]" + SUBPART_SEPARATOR + subPartName;
+
+ }
return null;
}
@@ -273,8 +282,11 @@ public class ComponentLocator {
String[] split = part.split("\\[");
Iterator<? extends Widget> i;
- if (split[0].equals("IWindow")) {
+ String widgetClassName = split[0];
+ if (widgetClassName.equals("IWindow")) {
i = client.getView().getSubWindowList().iterator();
+ } else if (widgetClassName.equals("IContextMenu")) {
+ return client.getContextMenu();
} else {
i = parent.iterator();
}
@@ -290,7 +302,7 @@ public class ComponentLocator {
Widget child = i.next();
String simpleName2 = Util.getSimpleName(child);
- if (split[0].equals(simpleName2)) {
+ if (widgetClassName.equals(simpleName2)) {
if (pos == 0) {
w = child;
ok = true;
diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IContextMenu.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IContextMenu.java
index 411e646a0c..ba7f5b509b 100644
--- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IContextMenu.java
+++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IContextMenu.java
@@ -4,12 +4,17 @@
package com.itmill.toolkit.terminal.gwt.client.ui;
+import com.google.gwt.dom.client.NodeList;
+import com.google.gwt.dom.client.TableRowElement;
+import com.google.gwt.dom.client.TableSectionElement;
+import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.PopupPanel;
+import com.itmill.toolkit.terminal.gwt.client.ApplicationConnection;
-public class IContextMenu extends IToolkitOverlay {
+public class IContextMenu extends IToolkitOverlay implements SubPartAware {
private ActionOwner actionOwner;
@@ -112,4 +117,42 @@ public class IContextMenu extends IToolkitOverlay {
* super.onBrowserEvent(event); }
*/
}
+
+ public Element getSubPartElement(String subPart) {
+ int index = Integer.parseInt(subPart.substring(6));
+ ApplicationConnection.getConsole().log(
+ "Searching element for selection index " + index);
+ Element wrapperdiv = menu.getElement();
+ com.google.gwt.dom.client.TableSectionElement tBody = (TableSectionElement) wrapperdiv
+ .getFirstChildElement().getFirstChildElement();
+ TableRowElement item = tBody.getRows().getItem(index);
+ com.google.gwt.dom.client.Element clickableDivElement = item
+ .getFirstChildElement().getFirstChildElement();
+ return clickableDivElement.cast();
+ }
+
+ public String getSubPartName(Element subElement) {
+ if (getElement().isOrHasChild(subElement)) {
+ com.google.gwt.dom.client.Element e = subElement;
+ {
+ while (e != null && !e.getTagName().toLowerCase().equals("tr")) {
+ e = e.getParentElement();
+ ApplicationConnection.getConsole().log("Found row");
+ }
+ }
+ com.google.gwt.dom.client.TableSectionElement parentElement = (TableSectionElement) e
+ .getParentElement();
+ NodeList<TableRowElement> rows = parentElement.getRows();
+ for (int i = 0; i < rows.getLength(); i++) {
+ if (rows.getItem(i) == e) {
+ ApplicationConnection.getConsole().log(
+ "Found index for row" + 1);
+ return "option" + i;
+ }
+ }
+ return null;
+ } else {
+ return null;
+ }
+ }
}