Package com.iizix.swt
Class IzSubMenu
java.lang.Object
com.iizix.swt.IzSubMenu
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
Method Summary
Modifier and TypeMethodDescriptionAdds the items that must be either instance of IAction of IzSubMenu, or null entries for separators.Adds a separator.getImage()
Returns the image for the submenu.Object[]
getItems()
Gets the array of items.getText()
Returns the text of the submenu.boolean
Returns if there are any visible and enabled items.boolean
Gets the enabled state.boolean
Gets the enabled state.setEnabled
(boolean enabled) Enables the submenu with all its items.Changes the image of the submenu.Changes the text of the submenu.setVisible
(boolean visible) Set the visibility state for the submenu with all its items.
Constructor Details
IzSubMenu
Constructs the submenu.- Parameters:
text
- The text.image
- The image, or null for none.- Throws:
NullPointerException
- If text is null.
Method Details
setText
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
Returns the text of the submenu.- Returns:
- The text, never null.
setImage
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
Returns the image for the submenu.- Returns:
- The image, or null for none.
addSeparator
Adds a separator.- Returns:
- The
this
instance for concatenation.
add
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
Gets the array of items.- Returns:
- An array of Object's as null for separator, IAction or IzSubMenu instances.
setEnabled
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
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().