summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ui/VMenuBar.java81
1 files changed, 50 insertions, 31 deletions
diff --git a/client/src/com/vaadin/client/ui/VMenuBar.java b/client/src/com/vaadin/client/ui/VMenuBar.java
index 4a090899f9..9948940717 100644
--- a/client/src/com/vaadin/client/ui/VMenuBar.java
+++ b/client/src/com/vaadin/client/ui/VMenuBar.java
@@ -245,7 +245,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* This is called by the items in the menu and it communicates the
* information to the server
- *
+ *
* @param clickedItemId
* id of the item that was clicked
*/
@@ -282,7 +282,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Returns the containing element of the menu
- *
+ *
* @return
*/
@Override
@@ -292,7 +292,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Add a new item to this menu
- *
+ *
* @param html
* items text
* @param cmd
@@ -309,7 +309,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Add a new item to this menu
- *
+ *
* @param item
*/
public void addItem(CustomMenuItem item) {
@@ -334,7 +334,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Remove the given item from this menu
- *
+ *
* @param item
*/
public void removeItem(CustomMenuItem item) {
@@ -431,7 +431,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* When an item is clicked
- *
+ *
* @param item
*/
public void itemClick(CustomMenuItem item) {
@@ -462,7 +462,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* When the user hovers the mouse over the item
- *
+ *
* @param item
*/
public void itemOver(CustomMenuItem item) {
@@ -487,7 +487,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* When the mouse is moved away from an item
- *
+ *
* @param item
*/
public void itemOut(CustomMenuItem item) {
@@ -545,7 +545,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Shows the child menu of an item. The caller must ensure that the item has
* a submenu.
- *
+ *
* @param item
*/
public void showChildMenu(CustomMenuItem item) {
@@ -667,7 +667,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Hides the submenu of an item
- *
+ *
* @param item
*/
public void hideChildMenu(CustomMenuItem item) {
@@ -731,7 +731,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Returns the parent menu of this menu, or null if this is the top-level
* menu
- *
+ *
* @return
*/
public VMenuBar getParentMenu() {
@@ -740,7 +740,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Set the parent menu of this menu
- *
+ *
* @param parent
*/
public void setParentMenu(VMenuBar parent) {
@@ -750,7 +750,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Returns the currently selected item of this menu, or null if nothing is
* selected
- *
+ *
* @return
*/
public CustomMenuItem getSelected() {
@@ -759,7 +759,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Set the currently selected item of this menu
- *
+ *
* @param item
*/
public void setSelected(CustomMenuItem item) {
@@ -776,9 +776,9 @@ public class VMenuBar extends SimpleFocusablePanel implements
}
/**
- *
+ *
* A class to hold information on menu items
- *
+ *
*/
public static class CustomMenuItem extends Widget implements HasHTML {
@@ -797,7 +797,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Default menu item {@link Widget} constructor for GWT.create().
- *
+ *
* Use {@link #setHTML(String)} and {@link #setCommand(Command)} after
* constructing a menu item.
*/
@@ -807,7 +807,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Creates a menu item {@link Widget}.
- *
+ *
* @param html
* @param cmd
* @deprecated use the default constructor and {@link #setHTML(String)}
@@ -1041,7 +1041,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Checks if the item can be selected.
- *
+ *
* @return true if it is possible to select this item, false otherwise
*/
public boolean isSelectable() {
@@ -1200,7 +1200,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Get the key that moves the selection upwards. By default it is the up
* arrow key but by overriding this you can change the key to whatever you
* want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationUpKey() {
@@ -1211,7 +1211,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Get the key that moves the selection downwards. By default it is the down
* arrow key but by overriding this you can change the key to whatever you
* want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationDownKey() {
@@ -1222,7 +1222,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Get the key that moves the selection left. By default it is the left
* arrow key but by overriding this you can change the key to whatever you
* want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationLeftKey() {
@@ -1233,7 +1233,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Get the key that moves the selection right. By default it is the right
* arrow key but by overriding this you can change the key to whatever you
* want.
- *
+ *
* @return The keycode of the key
*/
protected int getNavigationRightKey() {
@@ -1243,7 +1243,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Get the key that selects a menu item. By default it is the Enter key but
* by overriding this you can change the key to whatever you want.
- *
+ *
* @deprecated use {@link #isNavigationSelectKey(int)} instead
* @return
*/
@@ -1256,7 +1256,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
* Checks whether key code selects a menu item. By default it is the Enter
* and Space keys but by overriding this you can change the keys to whatever
* you want.
- *
+ *
* @since 7.2
* @param keycode
* @return true if key selects menu item
@@ -1269,7 +1269,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Get the key that closes the menu. By default it is the escape key but by
* overriding this yoy can change the key to whatever you want.
- *
+ *
* @return
*/
protected int getCloseMenuKey() {
@@ -1278,7 +1278,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Handles the keyboard events handled by the MenuBar
- *
+ *
* @param event
* The keyboard event received
* @return true iff the navigation event was handled
@@ -1565,12 +1565,31 @@ public class VMenuBar extends SimpleFocusablePanel implements
private boolean isItemNamed(CustomMenuItem item, String name) {
Element lastChildElement = getLastChildElement(item);
- if (lastChildElement.getInnerText().equals(name)) {
+ if (getText(lastChildElement).equals(name)) {
return true;
}
return false;
}
+ /*
+ * Returns the text content of element without including the text of
+ * possible nested elements. It is assumed that the last child of element
+ * contains the text of interest and that the last child does not itself
+ * have children with text content. This method is used by
+ * getSubPartElement(String) so that possible text icons are not included in
+ * the textual matching (#14879).
+ */
+ private native String getText(Element element)
+ /*-{
+ var n = element.childNodes.length;
+ if(n > 0){
+ return element.childNodes[n - 1].textContent;
+ }
+ else{
+ return "";
+ }
+ }-*/;
+
private Element getLastChildElement(CustomMenuItem item) {
Element lastChildElement = item.getElement().getFirstChildElement();
while (lastChildElement.getNextSiblingElement() != null) {
@@ -1604,7 +1623,7 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Get menu item with given DOM element
- *
+ *
* @param element
* Element used in search
* @return Menu item or null if not found
@@ -1633,11 +1652,11 @@ public class VMenuBar extends SimpleFocusablePanel implements
/**
* Get menu item with given DOM element
- *
+ *
* @param element
* Element used in search
* @return Menu item or null if not found
- *
+ *
* @since 7.2
*/
public CustomMenuItem getMenuItemWithElement(Element element) {