Package com.iizix.swt

Class IzSubMenu

java.lang.Object
com.iizix.swt.IzSubMenu

public class IzSubMenu extends 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 Details

    • IzSubMenu

      public IzSubMenu(String text, Image image)
      Constructs the submenu.
      Parameters:
      text - The text.
      image - The image, or null for none.
      Throws:
      NullPointerException - If text is null.
  • Method Details

    • setText

      public IzSubMenu setText(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:
      NullPointerException - If text is null.
    • getText

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

      public IzSubMenu setImage(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 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(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 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().