Package com.iizix.swt

Class IzSubMenu


  • public class IzSubMenu
    extends java.lang.Object
    A submenu item information holder that can be added to the main menu together with a set of actions in order to be able to save an array of item in an Object [] for fast construction or appending to menus while in about-to-display state.

    The enabled and visibility states can be controlled with this submenu BEFORE a menu has been displayed, not during menu is shown, i.e. it will not change the states of the menu or menu items. This state applies to all contained items.

    Author:
    Christopher Mindus
    • Constructor Summary

      Constructors 
      ConstructorDescription
      IzSubMenu​(java.lang.String text, org.eclipse.swt.graphics.Image image)
      Constructs the submenu.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      IzSubMenuadd​(java.lang.Object... items)
      Adds the items that must be either instance of IAction of IzSubMenu, or null entries for separators.
      IzSubMenuaddSeparator()
      Adds a separator.
      org.eclipse.swt.graphics.ImagegetImage()
      Returns the image for the submenu.
      java.lang.Object[]getItems()
      Gets the array of items.
      java.lang.StringgetText()
      Returns the text of the submenu.
      booleanhasEnabledVisibleItems()
      Returns if there are any visible and enabled items.
      booleanisEnabled()
      Gets the enabled state.
      booleanisVisible()
      Gets the enabled state.
      IzSubMenusetEnabled​(boolean enabled)
      Enables the submenu with all its items.
      IzSubMenusetImage​(org.eclipse.swt.graphics.Image image)
      Changes the image of the submenu.
      IzSubMenusetText​(java.lang.String text)
      Changes the text of the submenu.
      IzSubMenusetVisible​(boolean visible)
      Set the visibility state for the submenu with all its items.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IzSubMenu

        public IzSubMenu​(java.lang.String text,
                         org.eclipse.swt.graphics.Image image)
        Constructs the submenu.
        Parameters:
        text - The text.
        image - The image, or null for none.
        Throws:
        java.lang.NullPointerException - If text is null.
    • Method Detail

      • setText

        public IzSubMenu setText​(java.lang.String text)
        Changes the text of the submenu. This does not affect any menu that is currently displayed, only ones to come.
        Parameters:
        text - The new text.
        Returns:
        The this instance for concatenation.
        Throws:
        java.lang.NullPointerException - If text is null.
      • getText

        public java.lang.String getText()
        Returns the text of the submenu.
        Returns:
        The text, never null.
      • setImage

        public IzSubMenu setImage​(org.eclipse.swt.graphics.Image image)
        Changes the image of the submenu. This does not affect any menu that is currently displayed, only ones to come.
        Parameters:
        image - The image or null for none.
        Returns:
        The this instance for concatenation.
      • getImage

        public org.eclipse.swt.graphics.Image getImage()
        Returns the image for the submenu.
        Returns:
        The image, or null for none.
      • addSeparator

        public IzSubMenu addSeparator()
        Adds a separator.
        Returns:
        The this instance for concatenation.
      • add

        public IzSubMenu add​(java.lang.Object... items)
        Adds the items that must be either instance of IAction of IzSubMenu, or null entries for separators.
        Parameters:
        items - The items.
        Returns:
        The this instance for concatenation.
      • getItems

        public java.lang.Object[] getItems()
        Gets the array of items.
        Returns:
        An array of Object's as null for separator, IAction or IzSubMenu instances.
      • setEnabled

        public IzSubMenu setEnabled​(boolean enabled)
        Enables the submenu with all its items.
        Parameters:
        enabled - The new enabled state.
        Returns:
        this submenu to enable concatenation.
      • isEnabled

        public boolean isEnabled()
        Gets the enabled state.
        Returns:
        The enabled state.
      • setVisible

        public IzSubMenu setVisible​(boolean visible)
        Set the visibility state for the submenu with all its items.
        Parameters:
        visible - The new visible state.
        Returns:
        this submenu to enable concatenation.
      • isVisible

        public boolean isVisible()
        Gets the enabled state.
        Returns:
        The enabled state.
      • hasEnabledVisibleItems

        public boolean hasEnabledVisibleItems()
        Returns if there are any visible and enabled items. Separators are ignored.
        Returns:
        true if at least one action is enabled or a submenu hasEnabledVisibleItems().