Class MenuItemImpl
- java.lang.Object
-
- com.biglybt.pifimpl.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 Modifier and Type Field Description private MenuBuilder
builder
private CopyOnWriteList
children
private java.lang.Object
data
private java.lang.String
display_text
private boolean
enabled
private CopyOnWriteList
fill_listeners
private Graphic
graphic
private java.lang.String
headerCategory
private CopyOnWriteList
listeners
private CopyOnWriteList
m_listeners
private MenuContextImpl
menu_context
private int
minUserMode
private MenuItemImpl
parent
private PluginInterface
pi
private java.lang.String
sMenuID
private java.lang.String
sName
private int
style
private java.lang.String
uiType
private boolean
visible
-
Fields inherited from interface com.biglybt.pif.ui.menus.MenuItem
HEADER_CONTENT, HEADER_CONTROL, HEADER_ORGANIZE, HEADER_OTHER, HEADER_SOCIAL, STYLE_CHECK, STYLE_MENU, STYLE_PUSH, STYLE_RADIO, STYLE_SEPARATOR
-
-
Constructor Summary
Constructors Constructor Description MenuItemImpl(PluginInterface _pi, java.lang.String menuID, java.lang.String key)
MenuItemImpl(MenuItemImpl ti, java.lang.String key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addChildMenuItem(MenuItem child)
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 stylejava.lang.String
getDisposeWithUIDetach()
Graphic
getGraphic()
get the menu's graphicjava.lang.String
getHeaderCategory()
The header that a top menu item will be placed under for the fancy menuMenuItem
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 toint
getMinUserMode()
MenuItem
getParent()
Retrieve the parent MenuItem.java.lang.String
getResourceKey()
Retrieve the resource key ("name") of this menu itemint
getStyle()
Get the type of the menu itemMenuBuilder
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)
private void
invokeListenersSingle(java.lang.Object o)
void
invokeMenuWillBeShownListeners(java.lang.Object target)
boolean
isEnabled()
Whether or not this item is enabled or notboolean
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
removeSelf()
void
setContext(MenuContextImpl context)
void
setData(java.lang.Object _data)
Set the current data value associated with the menu: Boolean for CHECK stylevoid
setDisposeWithUIDetach(java.lang.String uiType)
Auto-dispose of MenuItem when a specific UI is detached (See {@link com.biglybt.pif.ui.UIInstance#UIT_*} for typesvoid
setEnabled(boolean _enabled)
Set the enabled status of the menu itemvoid
setGraphic(Graphic _graphic)
set the menu item's iconvoid
setHeaderCategory(java.lang.String header)
Sets which header to place the menu item under for top level fancy menuvoid
setMinUserMode(int minUserMode)
void
setStyle(int _style)
Set the style of the menu item (see STYLE_ constants)void
setSubmenuBuilder(MenuBuilder builder)
ForMenuItem.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.
-
-
-
Field Detail
-
pi
private PluginInterface pi
-
sMenuID
private java.lang.String sMenuID
-
sName
private java.lang.String sName
-
style
private int style
-
enabled
private boolean enabled
-
data
private java.lang.Object data
-
graphic
private Graphic graphic
-
listeners
private CopyOnWriteList listeners
-
m_listeners
private CopyOnWriteList m_listeners
-
fill_listeners
private CopyOnWriteList fill_listeners
-
children
private CopyOnWriteList children
-
parent
private MenuItemImpl parent
-
display_text
private java.lang.String display_text
-
visible
private boolean visible
-
menu_context
private MenuContextImpl menu_context
-
builder
private MenuBuilder builder
-
headerCategory
private java.lang.String headerCategory
-
minUserMode
private int minUserMode
-
uiType
private java.lang.String uiType
-
-
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 interfaceMenuItem
- 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 interfaceMenuItem
- Returns:
MenuManager
.MENU_ constant.
-
getStyle
public int getStyle()
Description copied from interface:MenuItem
Get the type of the menu item
-
setStyle
public void setStyle(int _style)
Description copied from interface:MenuItem
Set the style of the menu item (see STYLE_ constants)
-
getData
public java.lang.Object getData()
Description copied from interface:MenuItem
Get the current data value associated with the menu: Boolean for CHECK style
-
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
-
isEnabled
public boolean isEnabled()
Description copied from interface:MenuItem
Whether or not this item is enabled or not
-
setEnabled
public void setEnabled(boolean _enabled)
Description copied from interface:MenuItem
Set the enabled status of the menu item- Specified by:
setEnabled
in interfaceMenuItem
-
setGraphic
public void setGraphic(Graphic _graphic)
Description copied from interface:MenuItem
set the menu item's icon- Specified by:
setGraphic
in interfaceMenuItem
-
getGraphic
public Graphic getGraphic()
Description copied from interface:MenuItem
get the menu's graphic- Specified by:
getGraphic
in interfaceMenuItem
- 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 interfaceMenuItem
-
removeFillListener
public void removeFillListener(MenuItemFillListener listener)
- Specified by:
removeFillListener
in interfaceMenuItem
-
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 fromMenuItem.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 interfaceMenuItem
- 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 viaMenuItem.addMultiListener(MenuItemListener)
.- Specified by:
removeMultiListener
in interfaceMenuItem
- Parameters:
l
- listener to remove
-
invokeListenersSingle
private void invokeListenersSingle(java.lang.Object o)
-
addListener
public void addListener(MenuItemListener l)
Description copied from interface:MenuItem
Adds a selection listener for this menu item.- Specified by:
addListener
in interfaceMenuItem
- 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 interfaceMenuItem
- Parameters:
l
- listener to remove
-
getParent
public MenuItem getParent()
Description copied from interface:MenuItem
Retrieve the parent MenuItem.
-
getItems
public MenuItem[] getItems()
Description copied from interface:MenuItem
Get all child items currently associated with this MenuItem.
-
getItem
public MenuItem getItem(java.lang.String key)
Description copied from interface:MenuItem
Get the child item with the given resource key.
-
addChildMenuItem
private void addChildMenuItem(MenuItem child)
-
getText
public java.lang.String getText()
Description copied from interface:MenuItem
Gets the text to display for this menu item.
-
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.
-
invokeListenersOnList
protected void invokeListenersOnList(CopyOnWriteList listeners_to_notify, java.lang.Object target)
-
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.
-
removeSelf
protected void removeSelf()
-
removeAllChildItems
public void removeAllChildItems()
Description copied from interface:MenuItem
Removes all child menu items from this menu (if any exist).- Specified by:
removeAllChildItems
in interfaceMenuItem
-
isVisible
public boolean isVisible()
Description copied from interface:MenuItem
Returns whether the menu item is visible or not.
-
setVisible
public void setVisible(boolean visible)
Description copied from interface:MenuItem
Sets whether the menu item is visible or not.- Specified by:
setVisible
in interfaceMenuItem
-
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 interfaceMenuItem
-
setHeaderCategory
public void setHeaderCategory(java.lang.String header)
Description copied from interface:MenuItem
Sets which header to place the menu item under for top level fancy menu- Specified by:
setHeaderCategory
in interfaceMenuItem
-
getHeaderCategory
public java.lang.String getHeaderCategory()
Description copied from interface:MenuItem
The header that a top menu item will be placed under for the fancy menu- Specified by:
getHeaderCategory
in interfaceMenuItem
-
setMinUserMode
public void setMinUserMode(int minUserMode)
- Specified by:
setMinUserMode
in interfaceMenuItem
-
setDisposeWithUIDetach
public void setDisposeWithUIDetach(java.lang.String uiType)
Description copied from interface:MenuItem
Auto-dispose of MenuItem when a specific UI is detached (See {@link com.biglybt.pif.ui.UIInstance#UIT_*} for types- Specified by:
setDisposeWithUIDetach
in interfaceMenuItem
-
getDisposeWithUIDetach
public java.lang.String getDisposeWithUIDetach()
- Specified by:
getDisposeWithUIDetach
in interfaceMenuItem
-
getMinUserMode
public int getMinUserMode()
- Specified by:
getMinUserMode
in interfaceMenuItem
-
setContext
public void setContext(MenuContextImpl context)
-
setSubmenuBuilder
public void setSubmenuBuilder(MenuBuilder builder)
Description copied from interface:MenuItem
ForMenuItem.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 interfaceMenuItem
-
getSubmenuBuilder
public MenuBuilder getSubmenuBuilder()
-
-