Class WMenu
- java.lang.Object
-
- com.github.bordertech.wcomponents.AbstractWComponent
-
- com.github.bordertech.wcomponents.AbstractContainer
-
- com.github.bordertech.wcomponents.AbstractNamingContextContainer
-
- com.github.bordertech.wcomponents.WMenu
-
- All Implemented Interfaces:
AjaxTarget,Container,Disableable,Marginable,MenuContainer,MenuSelectContainer,NamingContextable,WComponent,WebComponent,Serializable
public class WMenu extends AbstractNamingContextContainer implements Disableable, AjaxTarget, Marginable, MenuSelectContainer
This component enables rendering of a menuing system for an application. A menu bar consists of a collection of either "Menu Items" (see
WMenuItemor "Sub Menus" (seeWSubMenu).- Since:
- 1.0.0
- Author:
- Adam Millard, Yiannis Paschalidis, Jonathan Austin
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWMenu.MenuModelHolds the state information for a WMenu.static classWMenu.MenuTypeThe available types of client-side menus.static classWMenu.SelectModeDeprecated.UseMenuSelectContainer.getSelectionMode()instead.-
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
-
-
Constructor Summary
Constructors Constructor Description WMenu()Creates a WMenu which is displayed as a menu bar.WMenu(WMenu.MenuType type)Creates a WMenu of the given type.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidadd(WMenuItem item)voidadd(WMenuItemGroup item)Deprecated.menu groups are not compatible with WCAG 2.0.voidadd(WSeparator item)voidadd(WSubMenu item)voidaddMenuItem(MenuItem item)voidaddSeparator()Adds a separator to the end of the menu.protected voidafterPaint(RenderContext renderContext)Subclasses may override this method to output content after the component has been painted.voidclearSelectedItems()Deprecated.UseclearSelectedMenuItems()instead.voidclearSelectedMenuItems()Clears an existing list of selected items.protected WMenu.MenuModelgetComponentModel()Returns the effective component model for this component.MargingetMargin()Get the margin for the component, or null if not set.List<MenuItem>getMenuItems()List<MenuItem>getMenuItems(boolean recurse)protected WMenu.MenuModelgetOrCreateComponentModel()Retrieves the model for this component so that it can be modified.intgetRows()Deprecated.No longer supported, no Java alternative.WComponentgetSelectedItem()Deprecated.UsegetSelectedMenuItem()instead.List<WComponent>getSelectedItems()Deprecated.UsegetSelectedMenuItems()instead.MenuItemSelectablegetSelectedMenuItem()Returns the selected item (WMenUItem/WSubMenu, depending on the menu type) in the given context.List<MenuItemSelectable>getSelectedMenuItems()Returns the selected items (WMenUItems/WSubMenus, depending on the menu type) in the given context.MenuSelectContainer.SelectionModegetSelectionMode()WMenu.SelectModegetSelectMode()Deprecated.UsegetSelectionMode()instead.WMenu.MenuTypegetType()voidhandleRequest(Request request)Override handleRequest in order to perform processing specific to WMenu.booleanisDisabled()Indicates whether this menu is disabled.protected booleanisPresent(Request request)Determine if this WMenu is on the Request.protected WMenu.MenuModelnewComponentModel()Creates a new component model.voidremove(WComponent item)Deprecated.voidremoveAllMenuItems()Remove all menu items.voidremoveMenuItem(MenuItem item)voidsetDisabled(boolean disabled)Sets whether this menu is disabled.voidsetMargin(Margin margin)Set the margin for the component, or null for no margin.voidsetRows(int rows)Deprecated.No longer supported, no Java alternative.voidsetSelectedItem(WComponent selectedItem)Deprecated.voidsetSelectedItems(List<WComponent> selectedItems)Deprecated.UsesetSelectedMenuItems(java.util.List)instead.voidsetSelectedMenuItem(MenuItemSelectable selectedItem)Sets the selected item (WMenuItem and/or WSubMenu, depending on the menu type).voidsetSelectedMenuItems(List<? extends MenuItemSelectable> selectedItems)Sets the selected items (WMenuItems or WSubMenus, depending on the menu type).voidsetSelectionMode(MenuSelectContainer.SelectionMode selectionMode)voidsetSelectMode(WMenu.SelectMode selectMode)Deprecated.-
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, 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, preparePaintComponent, 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, toString, 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.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
-
WMenu
public WMenu()
Creates a WMenu which is displayed as a menu bar.
-
WMenu
public WMenu(WMenu.MenuType type)
Creates a WMenu of the given type.- Parameters:
type- the type of WMenu to create.
-
-
Method Detail
-
getType
public WMenu.MenuType getType()
- Returns:
- the menu type.
-
getRows
public int getRows()
Deprecated.No longer supported, no Java alternative. If this is required use application level CSS.- Returns:
- the number of rows to display for a column menu.
-
setRows
public void setRows(int rows)
Deprecated.No longer supported, no Java alternative. If this is required use application level CSS.Sets the number of rows to display for a column menu.- Parameters:
rows- The rows to set.
-
getMargin
public Margin getMargin()
Get the margin for the component, or null if not set.- Specified by:
getMarginin interfaceMarginable- Returns:
- the margin for the component, or null if not set
-
setMargin
public void setMargin(Margin margin)
Set the margin for the component, or null for no margin.- Specified by:
setMarginin interfaceMarginable- Parameters:
margin- the margin for the component
-
getSelectMode
@Deprecated public WMenu.SelectMode getSelectMode()
Deprecated.UsegetSelectionMode()instead.- Returns:
- the selection mode of the container
-
setSelectMode
@Deprecated public void setSelectMode(WMenu.SelectMode selectMode)
Deprecated.- 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.
-
isDisabled
public boolean isDisabled()
Indicates whether this menu is disabled.- Specified by:
isDisabledin interfaceDisableable- Returns:
- true if this menu is disabled.
-
setDisabled
public void setDisabled(boolean disabled)
Sets whether this menu is disabled.- Specified by:
setDisabledin interfaceDisableable- Parameters:
disabled- if true, the menu will be disabled.
-
addSeparator
public void addSeparator()
Adds a separator to the end of the menu.
-
add
public void add(WSeparator item)
- Parameters:
item- add aWSeparator
-
add
@Deprecated public void add(WMenuItemGroup item)
Deprecated.menu groups are not compatible with WCAG 2.0.- 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
-
getMenuItems
public List<MenuItem> getMenuItems(boolean recurse)
- Parameters:
recurse- true if recurse into child items that are menu containers (ie group items and submenus).- Returns:
- the list of menu items
-
getSelectedItem
@Deprecated public WComponent getSelectedItem()
Deprecated.UsegetSelectedMenuItem()instead.Returns the selected item (WMenUItem/WSubMenu, depending on the menu type) in the given context.- Returns:
- the selected item, or null if no item has been selected.
-
setSelectedItem
@Deprecated public void setSelectedItem(WComponent selectedItem)
Deprecated.Sets the selected item (WMenuItem and/or WSubMenu, depending on the menu type).- Parameters:
selectedItem- the selected item.
-
getSelectedItems
@Deprecated public List<WComponent> getSelectedItems()
Deprecated.UsegetSelectedMenuItems()instead.Returns the selected items (WMenUItems/WSubMenus, depending on the menu type) in the given context.- Returns:
- the selected items, or an empty list if nothing is selected.
-
setSelectedItems
@Deprecated public void setSelectedItems(List<WComponent> selectedItems)
Deprecated.UsesetSelectedMenuItems(java.util.List)instead.Sets the selected items (WMenuItems or WSubMenus, depending on the menu type).- Parameters:
selectedItems- the selected items.
-
clearSelectedItems
@Deprecated public void clearSelectedItems()
Deprecated.UseclearSelectedMenuItems()instead.Clears an existing list of selected items.
-
getSelectedMenuItem
public MenuItemSelectable getSelectedMenuItem()
Returns the selected item (WMenUItem/WSubMenu, depending on the menu type) in the given context.- Returns:
- the selected item, or null if no item has been selected.
-
setSelectedMenuItem
public void setSelectedMenuItem(MenuItemSelectable selectedItem)
Sets the selected item (WMenuItem and/or WSubMenu, depending on the menu type).- Parameters:
selectedItem- the selected item.
-
getSelectedMenuItems
public List<MenuItemSelectable> getSelectedMenuItems()
Returns the selected items (WMenUItems/WSubMenus, depending on the menu type) in the given context.- Returns:
- the selected items, or an empty list if nothing is selected.
-
setSelectedMenuItems
public void setSelectedMenuItems(List<? extends MenuItemSelectable> selectedItems)
Sets the selected items (WMenuItems or WSubMenus, depending on the menu type).- Parameters:
selectedItems- the selected items.
-
clearSelectedMenuItems
public void clearSelectedMenuItems()
Clears an existing list of selected items.
-
handleRequest
public void handleRequest(Request request)
Override handleRequest in order to perform processing specific to WMenu.- Specified by:
handleRequestin interfaceWComponent- Overrides:
handleRequestin classAbstractWComponent- Parameters:
request- the request being handled.
-
afterPaint
protected void afterPaint(RenderContext renderContext)
Subclasses may override this method to output content after the component has been painted. When overriding this method, it is good practice to call the superclass implementation before emitting any additional content.- Overrides:
afterPaintin classAbstractWComponent- Parameters:
renderContext- the context to render to.
-
isPresent
protected boolean isPresent(Request request)
Determine if this WMenu is on the Request.- Parameters:
request- the request being responded to.- Returns:
- true if this WMenu is on the Request, otherwise return false.
-
newComponentModel
protected WMenu.MenuModel newComponentModel()
Creates a new component model.- Overrides:
newComponentModelin classAbstractWComponent- Returns:
- a new MenuModel.
-
getComponentModel
protected WMenu.MenuModel 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 WMenu.MenuModel 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
-
-