net.sourceforge.tapestry_jsmenu.api
Class BasicJSCookMenuItem

java.lang.Object
  extended by net.sourceforge.tapestry_jsmenu.api.BasicJSCookMenuItem
All Implemented Interfaces:
IJSCookMenuItem

public class BasicJSCookMenuItem
extends java.lang.Object
implements IJSCookMenuItem

Convenience implementation of IJSCookMenuItem This class introduces a value field filled in the constructors and retrieved in the getValue() method that might be called in ognl bindings to retrieve some value to be rendered in some component that renders the menu content.

Author:
Burkhard Eggers
See Also:
IJSCookMenuItem

Field Summary
 
Fields inherited from interface net.sourceforge.tapestry_jsmenu.api.IJSCookMenuItem
MENU_SEPARATOR
 
Constructor Summary
BasicJSCookMenuItem(java.lang.Object value)
          Constructs an item with no icons
BasicJSCookMenuItem(java.lang.Object value, IAsset asset)
          Constructs an item with an icon that is shown both in normal mode and mouse over mode.
BasicJSCookMenuItem(java.lang.Object value, IAsset asset, IAsset hoverAsset)
          Constructs an item with normal mode and mouse over icons.
 
Method Summary
 void addItem(IJSCookMenuItem item)
          Adds a menu item to the sub menu of this item
 java.lang.Iterable<IJSCookMenuItem> getChildren()
          Retrieves the items of the submenu belonging to this item.
 IAsset getIconAsset()
          retrieves the normal icon
 IAsset getIconHoverAsset()
          retrieves the mouse over icon
 java.lang.Object getValue()
          Retrieves the value that characterizes this item.
 boolean isSeparator()
          When the item is a menu separator, all other methods of this interface are ignored and a separator is displayed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicJSCookMenuItem

public BasicJSCookMenuItem(java.lang.Object value)
Constructs an item with no icons

Parameters:
value - some arbitrary object characterizing this item. Might be just a literal.

BasicJSCookMenuItem

public BasicJSCookMenuItem(java.lang.Object value,
                           IAsset asset)
Constructs an item with an icon that is shown both in normal mode and mouse over mode.

Parameters:
value - some arbitrary object characterizing this item. Might be just a literal
asset - the icon

BasicJSCookMenuItem

public BasicJSCookMenuItem(java.lang.Object value,
                           IAsset asset,
                           IAsset hoverAsset)
Constructs an item with normal mode and mouse over icons.

Parameters:
value - some arbitrary object characterizing this item. Might be just a literal
asset - the icon for the normal mode. Use null if no icon shall be shown in normal mode
hoverAsset - the icon that is displayed on mouse over. Use null, if you want the icon to disappear in mouse over mode.
Method Detail

addItem

public void addItem(IJSCookMenuItem item)
Adds a menu item to the sub menu of this item

Parameters:
item - the item to be added to the submenu

getChildren

public java.lang.Iterable<IJSCookMenuItem> getChildren()
Retrieves the items of the submenu belonging to this item.

Specified by:
getChildren in interface IJSCookMenuItem
Returns:
a List of items of null when there is no submenu.

isSeparator

public boolean isSeparator()
Description copied from interface: IJSCookMenuItem
When the item is a menu separator, all other methods of this interface are ignored and a separator is displayed. There is a static

Specified by:
isSeparator in interface IJSCookMenuItem
Returns:
false, since this is no separator

getValue

public java.lang.Object getValue()
Retrieves the value that characterizes this item. Typically this field will be bound to properties of components rendering the menu item.

Returns:
the value given in the constructors

getIconAsset

public IAsset getIconAsset()
retrieves the normal icon

Specified by:
getIconAsset in interface IJSCookMenuItem
Returns:
the asset being displayed when the mouse is not over the item

getIconHoverAsset

public IAsset getIconHoverAsset()
retrieves the mouse over icon

Specified by:
getIconHoverAsset in interface IJSCookMenuItem
Returns:
the asset being displayed when the mouse is not over the item