Package com.iizix.swt
Class IzSubMenu
- java.lang.Object
- com.iizix.swt.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 anObject []
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 Constructor Description IzSubMenu(java.lang.String text, org.eclipse.swt.graphics.Image image)
Constructs the submenu.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IzSubMenu
add(java.lang.Object... items)
Adds the items that must be either instance of IAction of IzSubMenu, or null entries for separators.IzSubMenu
addSeparator()
Adds a separator.org.eclipse.swt.graphics.Image
getImage()
Returns the image for the submenu.java.lang.Object[]
getItems()
Gets the array of items.java.lang.String
getText()
Returns the text of the submenu.boolean
hasEnabledVisibleItems()
Returns if there are any visible and enabled items.boolean
isEnabled()
Gets the enabled state.boolean
isVisible()
Gets the enabled state.IzSubMenu
setEnabled(boolean enabled)
Enables the submenu with all its items.IzSubMenu
setImage(org.eclipse.swt.graphics.Image image)
Changes the image of the submenu.IzSubMenu
setText(java.lang.String text)
Changes the text of the submenu.IzSubMenu
setVisible(boolean visible)
Set the visibility state for the submenu with all its items.
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().