org.gudy.azureus2.pluginsimpl.local.ui.menus
Class MenuItemImpl

java.lang.Object
  extended by org.gudy.azureus2.pluginsimpl.local.ui.menus.MenuItemImpl
All Implemented Interfaces:
MenuItem
Direct Known Subclasses:
TableContextMenuItemImpl

public class MenuItemImpl
extends java.lang.Object
implements MenuItem

amc1: This class was largely derived from TableContextMenuImpl.


Field Summary
 
Fields inherited from interface org.gudy.azureus2.plugins.ui.menus.MenuItem
STYLE_CHECK, STYLE_MENU, STYLE_PUSH, STYLE_RADIO, STYLE_SEPARATOR
 
Constructor Summary
MenuItemImpl(MenuItemImpl ti, java.lang.String key)
           
MenuItemImpl(PluginInterface _pi, java.lang.String menuID, java.lang.String key)
           
 
Method Summary
 void addFillListener(MenuItemFillListener listener)
          Adds a listener to be notified when the menu item is about to be displayed.
 void addListener(MenuItemListener l)
          Adds a selection listener for this menu item.
 void addMultiListener(MenuItemListener l)
          Adds a selection listener for this menu item.
 java.lang.Object getData()
          Get the current data value associated with the menu: Boolean for CHECK style
 Graphic getGraphic()
          get the menu's graphic
 MenuItem getItem(java.lang.String key)
          Get the child item with the given resource key.
 MenuItem[] getItems()
          Get all child items currently associated with this MenuItem.
 java.lang.String getMenuID()
          Retrieve the menu ID that the menu item belongs to
 MenuItem getParent()
          Retrieve the parent MenuItem.
 java.lang.String getResourceKey()
          Retrieve the resource key ("name") of this menu item
 int getStyle()
          Get the type of the menu item
 MenuBuilder getSubmenuBuilder()
           
 java.lang.String getText()
          Gets the text to display for this menu item.
 void invokeListenersMulti(java.lang.Object[] rows)
           
protected  void invokeListenersOnList(CopyOnWriteList listeners_to_notify, java.lang.Object target)
           
 void invokeMenuWillBeShownListeners(java.lang.Object target)
           
 boolean isEnabled()
          Whether or not this item is enabled or not
 boolean isSelected()
          Returns whether the menu item is selected or not.
 boolean isVisible()
          Returns whether the menu item is visible or not.
 void remove()
          Removes the menu item.
 void removeAllChildItems()
          Removes all child menu items from this menu (if any exist).
 void removeFillListener(MenuItemFillListener listener)
           
 void removeListener(MenuItemListener l)
          Removes a selection listener from this menu item.
 void removeMultiListener(MenuItemListener l)
          Removes a selection listener from this menu item.
protected  void removeWithEvents(int root_menu_event, int sub_menu_event)
           
 void setContext(MenuContextImpl context)
           
 void setData(java.lang.Object _data)
          Set the current data value associated with the menu: Boolean for CHECK style
 void setEnabled(boolean _enabled)
          Set the enabled status of the menu item
 void setGraphic(Graphic _graphic)
          set the menu item's icon
 void setStyle(int _style)
          Set the style of the menu item (see STYLE_ constants)
 void setSubmenuBuilder(MenuBuilder builder)
          For MenuItem.STYLE_MENU, builder is called when user wants to see the submenu items.
 void setText(java.lang.String text)
          Sets the text to display for this menu item.
 void setVisible(boolean visible)
          Sets whether the menu item is visible or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuItemImpl

public MenuItemImpl(PluginInterface _pi,
                    java.lang.String menuID,
                    java.lang.String key)

MenuItemImpl

public MenuItemImpl(MenuItemImpl ti,
                    java.lang.String key)
Method Detail

getResourceKey

public java.lang.String getResourceKey()
Description copied from interface: MenuItem
Retrieve the resource key ("name") of this menu item

Specified by:
getResourceKey in interface MenuItem
Returns:
resource key for this menu

getMenuID

public java.lang.String getMenuID()
Description copied from interface: MenuItem
Retrieve the menu ID that the menu item belongs to

Specified by:
getMenuID in interface MenuItem
Returns:
MenuManager.MENU_ constant.

getStyle

public int getStyle()
Description copied from interface: MenuItem
Get the type of the menu item

Specified by:
getStyle in interface MenuItem

setStyle

public void setStyle(int _style)
Description copied from interface: MenuItem
Set the style of the menu item (see STYLE_ constants)

Specified by:
setStyle in interface MenuItem

getData

public java.lang.Object getData()
Description copied from interface: MenuItem
Get the current data value associated with the menu: Boolean for CHECK style

Specified by:
getData in interface MenuItem
Returns:

setData

public void setData(java.lang.Object _data)
Description copied from interface: MenuItem
Set the current data value associated with the menu: Boolean for CHECK style

Specified by:
setData in interface MenuItem

isEnabled

public boolean isEnabled()
Description copied from interface: MenuItem
Whether or not this item is enabled or not

Specified by:
isEnabled in interface MenuItem
Returns:

setEnabled

public void setEnabled(boolean _enabled)
Description copied from interface: MenuItem
Set the enabled status of the menu item

Specified by:
setEnabled in interface MenuItem

setGraphic

public void setGraphic(Graphic _graphic)
Description copied from interface: MenuItem
set the menu item's icon

Specified by:
setGraphic in interface MenuItem

getGraphic

public Graphic getGraphic()
Description copied from interface: MenuItem
get the menu's graphic

Specified by:
getGraphic in interface MenuItem
Returns:

invokeMenuWillBeShownListeners

public void invokeMenuWillBeShownListeners(java.lang.Object target)

addFillListener

public void addFillListener(MenuItemFillListener listener)
Description copied from interface: MenuItem
Adds a listener to be notified when the menu item is about to be displayed. The "context" object provided is always going to be either be null (if there is no context) or an array of objects (such as an array of TableRows or an array of Download objects).

Specified by:
addFillListener in interface MenuItem

removeFillListener

public void removeFillListener(MenuItemFillListener listener)
Specified by:
removeFillListener in interface MenuItem

invokeListenersMulti

public void invokeListenersMulti(java.lang.Object[] rows)

addMultiListener

public void addMultiListener(MenuItemListener l)
Description copied from interface: MenuItem
Adds a selection listener for this menu item. This differs from MenuItem.addListener(MenuItemListener), in that the target object which will be passed to the listener will be an array of objects, rather than just a single object.

Specified by:
addMultiListener in interface MenuItem
Parameters:
l - listener to be notified when user has selected the menu item.

removeMultiListener

public void removeMultiListener(MenuItemListener l)
Description copied from interface: MenuItem
Removes a selection listener from this menu item. You only use this method to remove a listener added via MenuItem.addMultiListener(MenuItemListener).

Specified by:
removeMultiListener in interface MenuItem
Parameters:
l - listener to remove

addListener

public void addListener(MenuItemListener l)
Description copied from interface: MenuItem
Adds a selection listener for this menu item.

Specified by:
addListener in interface MenuItem
Parameters:
l - listener to be notified when user has selected the menu item.

removeListener

public void removeListener(MenuItemListener l)
Description copied from interface: MenuItem
Removes a selection listener from this menu item.

Specified by:
removeListener in interface MenuItem
Parameters:
l - listener to remove

getParent

public MenuItem getParent()
Description copied from interface: MenuItem
Retrieve the parent MenuItem.

Specified by:
getParent in interface MenuItem
Returns:
parent menu object, or null if no parent

getItems

public MenuItem[] getItems()
Description copied from interface: MenuItem
Get all child items currently associated with this MenuItem.

Specified by:
getItems in interface MenuItem
Returns:
An array of items (if this object has the menu style associated) or null otherwise.

getItem

public MenuItem getItem(java.lang.String key)
Description copied from interface: MenuItem
Get the child item with the given resource key.

Specified by:
getItem in interface MenuItem
Returns:
The child MenuItem object which has the resource key specified, or null otherwise.

getText

public java.lang.String getText()
Description copied from interface: MenuItem
Gets the text to display for this menu item.

Specified by:
getText in interface MenuItem

setText

public void setText(java.lang.String text)
Description copied from interface: MenuItem
Sets the text to display for this menu item. You can also pass null to revert back to the default behaviour.

Specified by:
setText in interface MenuItem

invokeListenersOnList

protected void invokeListenersOnList(CopyOnWriteList listeners_to_notify,
                                     java.lang.Object target)

removeWithEvents

protected void removeWithEvents(int root_menu_event,
                                int sub_menu_event)

remove

public void remove()
Description copied from interface: MenuItem
Removes the menu item. Calling this will remove the item from the menus, as well as removing all listeners and removing all child menu items (if any exist). The behaviour of this object is undefined after this method has been called. If you need to interact with this object when you are about to destroy it, you should do it before you call the remove method.

Specified by:
remove in interface MenuItem

removeAllChildItems

public void removeAllChildItems()
Description copied from interface: MenuItem
Removes all child menu items from this menu (if any exist).

Specified by:
removeAllChildItems in interface MenuItem

isVisible

public boolean isVisible()
Description copied from interface: MenuItem
Returns whether the menu item is visible or not.

Specified by:
isVisible in interface MenuItem

setVisible

public void setVisible(boolean visible)
Description copied from interface: MenuItem
Sets whether the menu item is visible or not.

Specified by:
setVisible in interface MenuItem

isSelected

public boolean isSelected()
Description copied from interface: MenuItem
Returns whether the menu item is selected or not. This method should only be called if the menu is of type STYLE_RADIO or type STYLE_CHECK and if the menu item has already had a selected or deselected state assigned to it.

Specified by:
isSelected in interface MenuItem

setContext

public void setContext(MenuContextImpl context)

setSubmenuBuilder

public void setSubmenuBuilder(MenuBuilder builder)
Description copied from interface: MenuItem
For MenuItem.STYLE_MENU, builder is called when user wants to see the submenu items. Setting a builder will force clear all submenu items.

Specified by:
setSubmenuBuilder in interface MenuItem

getSubmenuBuilder

public MenuBuilder getSubmenuBuilder()