Class 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 Detail

      • 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
      • display_text

        private java.lang.String display_text
      • visible

        private boolean visible
      • 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 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
      • 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.
      • 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 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.
      • 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.
        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)
      • 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
      • 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 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
      • 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 interface MenuItem
      • 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 interface MenuItem
      • setMinUserMode

        public void setMinUserMode​(int minUserMode)
        Specified by:
        setMinUserMode in interface MenuItem
      • 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 interface MenuItem
      • 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()