org.gudy.azureus2.plugins.ui.menus
Interface MenuItem

All Known Subinterfaces:
TableContextMenuItem
All Known Implementing Classes:
MenuItemImpl, TableContextMenuItemImpl

public interface MenuItem

Menu item access for the UI.

Author:
parg (Original ContextMenuItem code), TuxPaper (Generic-izing, commenting)

Field Summary
static int STYLE_CHECK
          check box style menu item - data must be of type Boolean
static int STYLE_MENU
          menu containing submenu items
static int STYLE_PUSH
          normal selection menu, no Data value required
static int STYLE_RADIO
          radio style - data must be Boolean
static int STYLE_SEPARATOR
          separator line
 
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.
 Object getData()
          Get the current data value associated with the menu: Boolean for CHECK style
 Graphic getGraphic()
          get the menu's graphic
 MenuItem getItem(String key_id)
          Get the child item with the given resource key.
 MenuItem[] getItems()
          Get all child items currently associated with this MenuItem.
 String getMenuID()
          Retrieve the menu ID that the menu item belongs to
 MenuItem getParent()
          Retrieve the parent MenuItem.
 String getResourceKey()
          Retrieve the resource key ("name") of this menu item
 int getStyle()
          Get the type of the menu item
 String getText()
          Gets the text to display for this menu item.
 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.
 void setData(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 STYLE_MENU, builder is called when user wants to see the submenu items.
 void setText(String text)
          Sets the text to display for this menu item.
 void setVisible(boolean visible)
          Sets whether the menu item is visible or not.
 

Field Detail

STYLE_PUSH

static final int STYLE_PUSH
normal selection menu, no Data value required

See Also:
Constant Field Values

STYLE_CHECK

static final int STYLE_CHECK
check box style menu item - data must be of type Boolean

See Also:
Constant Field Values

STYLE_RADIO

static final int STYLE_RADIO
radio style - data must be Boolean

See Also:
Constant Field Values

STYLE_SEPARATOR

static final int STYLE_SEPARATOR
separator line

See Also:
Constant Field Values

STYLE_MENU

static final int STYLE_MENU
menu containing submenu items

See Also:
Constant Field Values
Method Detail

getResourceKey

String getResourceKey()
Retrieve the resource key ("name") of this menu item

Returns:
resource key for this menu

getStyle

int getStyle()
Get the type of the menu item


setStyle

void setStyle(int style)
Set the style of the menu item (see STYLE_ constants)

Parameters:
style -

getData

Object getData()
Get the current data value associated with the menu: Boolean for CHECK style

Returns:

setData

void setData(Object data)
Set the current data value associated with the menu: Boolean for CHECK style

Parameters:
data -

isEnabled

boolean isEnabled()
Whether or not this item is enabled or not

Returns:

setEnabled

void setEnabled(boolean enabled)
Set the enabled status of the menu item

Parameters:
enabled -

setGraphic

void setGraphic(Graphic graphic)
set the menu item's icon

Parameters:
graphic -

getGraphic

Graphic getGraphic()
get the menu's graphic

Returns:

addFillListener

void addFillListener(MenuItemFillListener listener)
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).

Parameters:
listener -

removeFillListener

void removeFillListener(MenuItemFillListener listener)

setSubmenuBuilder

void setSubmenuBuilder(MenuBuilder builder)
For STYLE_MENU, builder is called when user wants to see the submenu items. Setting a builder will force clear all submenu items.

Since:
5.5.0.1

addMultiListener

void addMultiListener(MenuItemListener l)
Adds a selection listener for this menu item. This differs from 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.

Parameters:
l - listener to be notified when user has selected the menu item.
Since:
3.0.2

removeMultiListener

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

Parameters:
l - listener to remove
Since:
3.0.2

addListener

void addListener(MenuItemListener l)
Adds a selection listener for this menu item.

Parameters:
l - listener to be notified when user has selected the menu item.

removeListener

void removeListener(MenuItemListener l)
Removes a selection listener from this menu item.

Parameters:
l - listener to remove

getParent

MenuItem getParent()
Retrieve the parent MenuItem.

Returns:
parent menu object, or null if no parent

getItems

MenuItem[] getItems()
Get all child items currently associated with this MenuItem.

Returns:
An array of items (if this object has the menu style associated) or null otherwise.

getItem

MenuItem getItem(String key_id)
Get the child item with the given resource key.

Returns:
The child MenuItem object which has the resource key specified, or null otherwise.

getText

String getText()
Gets the text to display for this menu item.


setText

void setText(String text)
Sets the text to display for this menu item. You can also pass null to revert back to the default behaviour.


getMenuID

String getMenuID()
Retrieve the menu ID that the menu item belongs to

Returns:
MenuManager.MENU_ constant.
Since:
3.0.0.7

remove

void remove()
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.

Since:
3.0.0.7

removeAllChildItems

void removeAllChildItems()
Removes all child menu items from this menu (if any exist).

Since:
3.0.0.7

setVisible

void setVisible(boolean visible)
Sets whether the menu item is visible or not.

Since:
3.0.2.0

isVisible

boolean isVisible()
Returns whether the menu item is visible or not.

Since:
3.0.2.0

isSelected

boolean isSelected()
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.

Since:
3.0.2.4