Class WSubMenu
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.AbstractContainer
-
- com.github.bordertech.wcomponents.AbstractNamingContextContainer
-
- com.github.bordertech.wcomponents.WSubMenu
-
- All Implemented Interfaces:
AccessKeyable,Container,Disableable,MenuContainer,MenuItem,MenuItemSelectable,MenuSelectContainer,NamingContextable,WComponent,WebComponent,Serializable
public class WSubMenu extends AbstractNamingContextContainer implements Disableable, MenuSelectContainer, MenuItemSelectable, AccessKeyable
This component is used to provide either a dropmenu (when added directly to a
WMenuor nestable sub menus (when added to anotherWSubMenuinstance).Sub Menus may contain the following components:
- Other sub menus.
- Menu items (
WMenuItem) - Menu separators (see
addSeparator())
- Author:
- Adam Millard, Yiannis Paschalidis, Mark Reeves
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWSubMenu.MenuModeThe available types of operation.static classWSubMenu.SubMenuModelHolds the extrinsic state information of a WSubMenu.-
Nested classes/interfaces inherited from class com.github.bordertech.wcomponents.AbstractWComponent
AbstractWComponent.WComponentRef
-
Nested classes/interfaces inherited from interface com.github.bordertech.wcomponents.MenuSelectContainer
MenuSelectContainer.SelectionMode
-
-
Field Summary
-
Fields inherited from interface com.github.bordertech.wcomponents.WComponent
DEFAULT_APPLICATION_ID, DEFAULT_INTERNAL_ID, DEFAULT_NO_ID, ID_CONTEXT_SEPERATOR, ID_FRAMEWORK_ASSIGNED_SEPERATOR, ID_VALIDATION_PATTERN
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(WMenuItem item)voidadd(WMenuItemGroup item)voidadd(WSeparator item)voidadd(WSubMenu item)voidaddMenuItem(MenuItem item)voidaddMenuItemGroup(WMenuItemGroup menuItemGroup)Deprecated.menu groups are not compatible with WCAG 2.0.voidaddSeparator()Adds a separator to the sub-menu.chargetAccessKey()ActiongetAction()StringgetActionCommand()Retrieves this sub-menu's "default" action command.SerializablegetActionObject()Retrieves this sub-menu's "default" action object.protected WSubMenu.SubMenuModelgetComponentModel()Returns the effective component model for this component.WDecoratedLabelgetDecoratedLabel()List<MenuItem>getMenuItems()WSubMenu.MenuModegetMode()protected WSubMenu.SubMenuModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.BooleangetSelectability()Deprecated.WSubMenu is never selectable for a11y reasons.MenuSelectContainer.SelectionModegetSelectionMode()WMenu.SelectModegetSelectMode()Deprecated.UseMenuSelectContainer.getSelectionMode()instead.StringgetText()voidhandleRequest(Request request)Override handleRequest in order to perform processing for this component.booleanisDisabled()Indicates whether this sub menu is disabled in the given context.protected booleanisMenuPresent(Request request)Determine if this WMenuItem's parent WMenu is on the Request.booleanisMultipleSelection()Deprecated.booleanisOpen()Indicates whether this sub-menu is open in the given context.BooleanisSelectable()Deprecated.WSubMenu is never selectable for a11y reasons.booleanisSelectAllowed()booleanisSelected()Deprecated.WSubMenu is never selectable for a11y reasons.booleanisTopLevelMenu()Indicates whether this is a top-level menu (ie. attached to a menu bar).protected WSubMenu.SubMenuModelnewComponentModel()Creates a new component model.voidpaintMenuItems(RenderContext renderContext)Paint the menu items.protected voidpreparePaintComponent(Request request)Override preparePaintComponent in order to correct the visibility of the sub-menu's children before they are rendered.voidremove(WComponent item)Deprecated.voidremoveAllMenuItems()Remove all menu items.voidremoveMenuItem(MenuItem item)voidsetAccessKey(char accessKey)Set the access key on the component.voidsetAction(Action action)Sets the action to execute when the sub-menu is selected.voidsetActionCommand(String actionCommand)Sets this sub-menu's action command.voidsetActionObject(Serializable actionObject)Sets this sub-menu's "default" action object.voidsetDisabled(boolean disabled)Sets whether this sub menu is disabled.voidsetMode(WSubMenu.MenuMode mode)Sets the menu mode.voidsetMultipleSelection(boolean multipleSelection)Deprecated.voidsetOpen(boolean open)Sets whether this menu is open.voidsetSelectability(Boolean selectability)Deprecated.WSubMenu is never selectable for a11y reasons.voidsetSelectable(Boolean selectable)Deprecated.WSubMenu is never selectable for a11y reasons.voidsetSelectionMode(MenuSelectContainer.SelectionMode selectionMode)voidsetSelectMode(WMenu.SelectMode selectMode)Deprecated.UseMenuSelectContainer.setSelectionMode(SelectionMode)instead.voidsetText(String text)Sets the sub-menu text.StringtoString()Creates a String representation of this component; usually for debugging purposes.-
Methods inherited from class com.github.bordertech.wcomponents.AbstractNamingContextContainer
getNamingContextId, isNamingContext, setNamingContext
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractContainer
getChildAt, getChildCount, getChildren, getIndexOfChild
-
Methods inherited from class com.github.bordertech.wcomponents.AbstractWComponent
addHtmlClass, addHtmlClass, addNotify, afterPaint, assertAddSupported, beforePaint, createErrorDiagnostic, createErrorDiagnostic, forward, getAccessibleText, getAttribute, getBaseUrl, getDefaultModel, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getScratchMap, getTabIndex, getTag, getTemplate, getTemplateMarkUp, getToolTip, hasNoComponentModel, hasTabIndex, initialiseComponentModel, invokeLater, invokeLaters, isDebugStructure, isDefaultState, isFlagSet, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, paintComponent, preparePaint, removeAttribute, removeComponentModel, removeHtmlClass, removeHtmlClass, removeNotify, replaceWComponent, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFlag, setFocussed, setHidden, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showErrorIndicatorsForComponent, showWarningIndicators, showWarningIndicatorsForComponent, tidyUpUIContext, tidyUpUIContextForTree, validate, validateComponent, writeReplace
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.github.bordertech.wcomponents.AccessKeyable
getAccessKeyAsString
-
Methods inherited from interface com.github.bordertech.wcomponents.Container
getChildAt, getChildCount, getChildren, getIndexOfChild
-
Methods inherited from interface com.github.bordertech.wcomponents.WComponent
addHtmlClass, addHtmlClass, forward, getAccessibleText, getAttribute, getBaseUrl, getEnvironment, getHeaders, getHtmlClass, getHtmlClasses, getId, getIdName, getInternalId, getLabel, getName, getParent, getTabIndex, getTag, getToolTip, hasTabIndex, invokeLater, isDefaultState, isHidden, isInitialised, isLocked, isTracking, isTrackingEnabled, isValidate, isVisible, paint, preparePaint, removeAttribute, removeHtmlClass, removeHtmlClass, reset, serviceRequest, setAccessibleText, setAttribute, setEnvironment, setFocussed, setHtmlClass, setHtmlClass, setIdName, setInitialised, setLocked, setTag, setToolTip, setTrackingEnabled, setValidate, setVisible, showErrorIndicators, showWarningIndicators, tidyUpUIContextForTree, validate
-
-
-
-
Constructor Detail
-
WSubMenu
public WSubMenu(String text)
Creates a WSubMenu with the given text.- Parameters:
text- the sub menu text.
-
WSubMenu
public WSubMenu(WDecoratedLabel label)
Creates a WSubMenu with the given text.- Parameters:
label- the sub menu label.
-
WSubMenu
@Deprecated public WSubMenu(String text, char accessKey)
Deprecated.access keys are not implemented in menus. See https://www.w3.org/TR/wai-aria-practices/#keyboard-interaction-9 for information regarding key access to menus.Creates a WSubMenu with the given text. The accessKey arg is now ignored for a11y reasons.- Parameters:
text- the sub menu textaccessKey- the access key - not used
-
-
Method Detail
-
setMode
public void setMode(WSubMenu.MenuMode mode)
Sets the menu mode. See #687.- Parameters:
mode- the menu mode.
-
getMode
public WSubMenu.MenuMode getMode()
- Returns:
- the menu mode.
-
isTopLevelMenu
public boolean isTopLevelMenu()
Indicates whether this is a top-level menu (ie. attached to a menu bar).- Returns:
trueif this is a top-level menu.
-
addSeparator
public void addSeparator()
Adds a separator to the sub-menu.
-
add
public void add(WSeparator item)
- Parameters:
item- add aWSeparator
-
addMenuItemGroup
public void addMenuItemGroup(WMenuItemGroup menuItemGroup)
Deprecated.menu groups are not compatible with WCAG 2.0.Adds a menu item group to this sub menu.- Parameters:
menuItemGroup- the menu item group to add.
-
add
public void add(WMenuItemGroup item)
- Parameters:
item- add aWMenuItemGroup
-
addMenuItem
public void addMenuItem(MenuItem item)
- Specified by:
addMenuItemin interfaceMenuContainer- Parameters:
item- the menu item to add
-
remove
@Deprecated public void remove(WComponent item)
Deprecated.
-
removeMenuItem
public void removeMenuItem(MenuItem item)
- Specified by:
removeMenuItemin interfaceMenuContainer- Parameters:
item- the menu item to remove
-
removeAllMenuItems
public void removeAllMenuItems()
Remove all menu items.- Specified by:
removeAllMenuItemsin interfaceMenuContainer
-
getMenuItems
public List<MenuItem> getMenuItems()
- Specified by:
getMenuItemsin interfaceMenuContainer- Returns:
- the items of this menu container
-
isDisabled
public boolean isDisabled()
Indicates whether this sub menu is disabled in the given context.- Specified by:
isDisabledin interfaceDisableable- Returns:
- true if this sub menu is disabled.
-
setDisabled
public void setDisabled(boolean disabled)
Sets whether this sub menu is disabled.- Specified by:
setDisabledin interfaceDisableable- Parameters:
disabled- true to disable this sub menu, false to enable.
-
getAccessKey
public char getAccessKey()
- Specified by:
getAccessKeyin interfaceAccessKeyable- Returns:
- the component's access key.
-
setAccessKey
public void setAccessKey(char accessKey)
Description copied from interface:AccessKeyableSet the access key on the component.- Specified by:
setAccessKeyin interfaceAccessKeyable- Parameters:
accessKey- the key that will form a keyboard shortcut to the component.
-
getText
public String getText()
- Returns:
- the sub-menu text.
-
setText
public void setText(String text)
Sets the sub-menu text.- Parameters:
text- the sub-menu text.
-
isSelectable
@Deprecated public Boolean isSelectable()
Deprecated.WSubMenu is never selectable for a11y reasons. If you need a selectable useWTree.- Returns:
- true if this item is selectable, false if not, or null to default to the container.
-
setSelectable
@Deprecated public void setSelectable(Boolean selectable)
Deprecated.WSubMenu is never selectable for a11y reasons. If you need a selectable useWTree.- Parameters:
selectable- true if this item is selectable, false if not, or null to default to the container.
-
getSelectability
@Deprecated public final Boolean getSelectability()
Deprecated.WSubMenu is never selectable for a11y reasons. If you need a selectable useWTree.Symmetric accessor which should not generally be used. If you need to know if an instance of MenuItemSelectable is selectable then it is better to useMenuItemSelectable.isSelectAllowed().- Specified by:
getSelectabilityin interfaceMenuItemSelectable- Returns:
- true if this item is selectable, false if not, or null if default to its container.
-
setSelectability
@Deprecated public final void setSelectability(Boolean selectability)
Deprecated.WSubMenu is never selectable for a11y reasons. If you need a selectable useWTree.- Specified by:
setSelectabilityin interfaceMenuItemSelectable- Parameters:
selectability- true if this item is selectable, false if not, or null to default to the container.
-
isSelectAllowed
public boolean isSelectAllowed()
- Specified by:
isSelectAllowedin interfaceMenuItemSelectable- Returns:
- always
falsefor WSubMenu.
-
isMultipleSelection
@Deprecated public boolean isMultipleSelection()
Deprecated.- Returns:
- Returns the multipleSelection.
-
setMultipleSelection
@Deprecated public void setMultipleSelection(boolean multipleSelection)
Deprecated.- Parameters:
multipleSelection- The multipleSelection to set.
-
getSelectMode
public WMenu.SelectMode getSelectMode()
Deprecated.UseMenuSelectContainer.getSelectionMode()instead.- Returns:
- the selection mode of the container
-
setSelectMode
public void setSelectMode(WMenu.SelectMode selectMode)
Deprecated.UseMenuSelectContainer.setSelectionMode(SelectionMode)instead.- Parameters:
selectMode- the selection mode for the items in this menu container.
-
getSelectionMode
public MenuSelectContainer.SelectionMode getSelectionMode()
- Specified by:
getSelectionModein interfaceMenuSelectContainer- Returns:
- the selection mode of the container
-
setSelectionMode
public void setSelectionMode(MenuSelectContainer.SelectionMode selectionMode)
- Specified by:
setSelectionModein interfaceMenuSelectContainer- Parameters:
selectionMode- the selection mode for the items in this menu container.
-
getAction
public Action getAction()
- Returns:
- the sub-menu's action, or null if there is no action specified.
-
setAction
public void setAction(Action action)
Sets the action to execute when the sub-menu is selected.- Parameters:
action- the menu item's action.
-
getActionCommand
public String getActionCommand()
Retrieves this sub-menu's "default" action command.- Returns:
- the actionCommand.
-
setActionCommand
public void setActionCommand(String actionCommand)
Sets this sub-menu's action command.- Parameters:
actionCommand- The actionCommand to set.
-
getActionObject
public Serializable getActionObject()
Retrieves this sub-menu's "default" action object.- Returns:
- the actionObject.
-
setActionObject
public void setActionObject(Serializable actionObject)
Sets this sub-menu's "default" action object.- Parameters:
actionObject- The actionObject to set.
-
setOpen
public void setOpen(boolean open)
Sets whether this menu is open. Only has an effect for some menu types.- Parameters:
open- true if the menu should be open, false for closed.
-
isOpen
public boolean isOpen()
Indicates whether this sub-menu is open in the given context.- Returns:
- true if this menu is open in the given context, false otherwise.
-
getDecoratedLabel
public WDecoratedLabel getDecoratedLabel()
- Returns:
- the sub menu's decorated label.
-
isSelected
@Deprecated public boolean isSelected()
Deprecated.WSubMenu is never selectable for a11y reasons. If you need a selectable see WTree.Indicates whether this sub-menu is selected (for menu types which support sub-menu selection).- Specified by:
isSelectedin interfaceMenuItemSelectable- Returns:
- true if this sub-menu is selected, false otherwise.
-
handleRequest
public void handleRequest(Request request)
Override handleRequest in order to perform processing for this component. This implementation checks for submenu selection and executes the associated action if it has been set.- Specified by:
handleRequestin interfaceWComponent- Overrides:
handleRequestin classAbstractWComponent- Parameters:
request- the request being responded to.
-
isMenuPresent
protected boolean isMenuPresent(Request request)
Determine if this WMenuItem's parent WMenu is on the Request.- Parameters:
request- the request being responded to.- Returns:
- true if this WMenuItem's WMenu is on the Request, otherwise return false.
-
preparePaintComponent
protected void preparePaintComponent(Request request)
Override preparePaintComponent in order to correct the visibility of the sub-menu's children before they are rendered.- Overrides:
preparePaintComponentin classAbstractWComponent- Parameters:
request- the request being responded to.
-
paintMenuItems
public void paintMenuItems(RenderContext renderContext)
Paint the menu items.- Parameters:
renderContext- the render context
-
toString
public String toString()
Description copied from class:AbstractWComponentCreates a String representation of this component; usually for debugging purposes.- Overrides:
toStringin classAbstractWComponent- Returns:
- a String representation of this component, for debugging purposes.
-
newComponentModel
protected WSubMenu.SubMenuModel newComponentModel()
Creates a new component model.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new SubMenuModel.
-
getComponentModel
protected WSubMenu.SubMenuModel getComponentModel()
Returns the effective component model for this component. Subclass may override this method to narrow the return type to their specific model type.- Overrides:
getComponentModelin classAbstractWComponent- Returns:
- the effective component model
-
getOrCreateComponentModel
protected WSubMenu.SubMenuModel getOrCreateComponentModel()
Retrieves the model for this component so that it can be modified. If this method is called during request processing, and a session specific model does not yet exist, then a new model is created. Subclasses may override this method to narrow the return type to their specific model type.- Overrides:
getOrCreateComponentModelin classAbstractWComponent- Returns:
- the model for this component
-
-