org.xwiki.gwt.user.client.ui
Class MenuItem

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.MenuItem
          extended by org.xwiki.gwt.user.client.ui.MenuItem
All Implemented Interfaces:
com.google.gwt.user.client.ui.HasHTML, com.google.gwt.user.client.ui.HasText, SourcesMenuEvents

public class MenuItem
extends com.google.gwt.user.client.ui.MenuItem
implements SourcesMenuEvents

Improves the default menu item widget provided by GWT:

Version:
$Id: MenuItem.java 24888 2009-11-06 02:16:19Z sdumitriu $

Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
MenuItem(java.lang.String text, boolean asHTML, com.google.gwt.user.client.Command cmd)
          Constructs a new menu item that fires a command when it is selected.
MenuItem(java.lang.String text, boolean asHTML, MenuBar subMenu)
          Constructs a new menu item that cascades to a sub-menu when it is selected.
MenuItem(java.lang.String text, com.google.gwt.user.client.Command cmd)
          Constructs a new menu item that fires a command when it is selected.
MenuItem(java.lang.String text, MenuBar subMenu)
          Constructs a new menu item that cascades to a sub-menu when it is selected.
 
Method Summary
 void addMenuListener(MenuListener listener)
          Start notifying the given listener of the menu events generated by this object.
 void addStyleDependentName(java.lang.String styleSuffix)
          
 com.google.gwt.user.client.Command getCommand()
          
 java.lang.String getHTML()
          
 Element getIcon()
           
 com.google.gwt.user.client.ui.MenuBar getSubMenu()
          
 java.lang.String getText()
          
 boolean isEnabled()
           
 void removeMenuListener(MenuListener listener)
          Stop notifying the given listener of the menu events generated by this object.
 void setEnabled(boolean enabled)
          Disables or enables this menu item.
 void setHTML(java.lang.String html)
          
 void setIcon(com.google.gwt.user.client.ui.AbstractImagePrototype.ImagePrototypeElement icon)
          Sets the icon of this menu item using the element created from an AbstractImagePrototype.
 void setIcon(Element icon)
          Sets the icon of this menu item.
 void setText(java.lang.String text)
          
 void xSetSelectionStyle(boolean selected)
          Visually marks this menu item as selected or unselected based on the given argument.
NOTE: This is just a hack required because #setSelectionStyle(boolean) is private.
 
Methods inherited from class com.google.gwt.user.client.ui.MenuItem
getParentMenu, onEnsureDebugId, setCommand, setSelectionStyle, setSubMenu
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MenuItem

public MenuItem(java.lang.String text,
                com.google.gwt.user.client.Command cmd)
Constructs a new menu item that fires a command when it is selected.

Parameters:
text - the item's text
cmd - the command to be fired when it is selected

MenuItem

public MenuItem(java.lang.String text,
                boolean asHTML,
                com.google.gwt.user.client.Command cmd)
Constructs a new menu item that fires a command when it is selected.

Parameters:
text - the item's text
asHTML - true to treat the specified text as html
cmd - the command to be fired when it is selected

MenuItem

public MenuItem(java.lang.String text,
                MenuBar subMenu)
Constructs a new menu item that cascades to a sub-menu when it is selected.

Parameters:
text - the item's text
subMenu - the sub-menu to be displayed when it is selected

MenuItem

public MenuItem(java.lang.String text,
                boolean asHTML,
                MenuBar subMenu)
Constructs a new menu item that cascades to a sub-menu when it is selected.

Parameters:
text - the item's text
asHTML - true to treat the specified text as html
subMenu - the sub-menu to be displayed when it is selected
Method Detail

setEnabled

public void setEnabled(boolean enabled)
Disables or enables this menu item.

Parameters:
enabled - true to enable this menu item, false to disable it

isEnabled

public boolean isEnabled()
Returns:
true if this menu item is enabled, false otherwise

setIcon

public void setIcon(com.google.gwt.user.client.ui.AbstractImagePrototype.ImagePrototypeElement icon)
Sets the icon of this menu item using the element created from an AbstractImagePrototype.

Parameters:
icon - the icon to be displayed on the left of this menu item

setIcon

public void setIcon(Element icon)
Sets the icon of this menu item.

Parameters:
icon - the icon to be displayed on the left of this menu item

getIcon

public Element getIcon()
Returns:
the icon of this menu item

setHTML

public void setHTML(java.lang.String html)

Specified by:
setHTML in interface com.google.gwt.user.client.ui.HasHTML
Overrides:
setHTML in class com.google.gwt.user.client.ui.MenuItem
See Also:
MenuItem.setHTML(String)

getHTML

public java.lang.String getHTML()

Specified by:
getHTML in interface com.google.gwt.user.client.ui.HasHTML
Overrides:
getHTML in class com.google.gwt.user.client.ui.MenuItem
See Also:
MenuItem.getHTML()

setText

public void setText(java.lang.String text)

Specified by:
setText in interface com.google.gwt.user.client.ui.HasText
Overrides:
setText in class com.google.gwt.user.client.ui.MenuItem
See Also:
MenuItem.setText(String)

getText

public java.lang.String getText()

Specified by:
getText in interface com.google.gwt.user.client.ui.HasText
Overrides:
getText in class com.google.gwt.user.client.ui.MenuItem
See Also:
MenuItem.getText()

getCommand

public com.google.gwt.user.client.Command getCommand()

Overrides:
getCommand in class com.google.gwt.user.client.ui.MenuItem
See Also:
MenuItem.getCommand()

getSubMenu

public com.google.gwt.user.client.ui.MenuBar getSubMenu()

Overrides:
getSubMenu in class com.google.gwt.user.client.ui.MenuItem
See Also:
MenuItem.getSubMenu()

addStyleDependentName

public void addStyleDependentName(java.lang.String styleSuffix)

Overrides:
addStyleDependentName in class com.google.gwt.user.client.ui.UIObject
See Also:
UIObject.addStyleDependentName(String)

xSetSelectionStyle

public void xSetSelectionStyle(boolean selected)
Visually marks this menu item as selected or unselected based on the given argument.
NOTE: This is just a hack required because #setSelectionStyle(boolean) is private.

Parameters:
selected - true to select this menu item, false to remove the selection

addMenuListener

public void addMenuListener(MenuListener listener)
Start notifying the given listener of the menu events generated by this object.

Specified by:
addMenuListener in interface SourcesMenuEvents
Parameters:
listener - the listener to be added to the list of menu listeners that are notified by this object
See Also:
SourcesMenuEvents.addMenuListener(MenuListener)

removeMenuListener

public void removeMenuListener(MenuListener listener)
Stop notifying the given listener of the menu events generated by this object.

Specified by:
removeMenuListener in interface SourcesMenuEvents
Parameters:
listener - the listener to be removed from the list of menu listeners that are notified by this object
See Also:
SourcesMenuEvents.removeMenuListener(MenuListener)


Copyright © 2004-2010 XWiki. All Rights Reserved.