Class QMenuItemSubMenu
- All Implemented Interfaces:
QMenuItemInterface,QMenuItemContainerInterface,QMetaDataObject,Serializable,Cloneable
Sub-menus are used to create hierarchical menu structures. They differ from sub-lists in that they typically render as a nested menu that opens when selected, rather than displaying items inline. Sub-menus are useful for organizing large numbers of menu items into logical groups for users to see.
This class implements QMenuItemContainerInterface to allow
it to contain other menu items. Sub-menus can have their own label and
icon, which are displayed in the parent menu.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates and returns a deep copy of this sub-menu menu item.getItems()Getter for itemsReturns the item type identifier for sub-menu menu items.Returns the values map containing the list of items in this sub-menu.voidsetItems(List<QMenuItemInterface> items) Setter for itemsvoidvalidate(QInstanceValidator validator, QInstance qInstance, QMetaDataObject parentObject) Validates all menu items contained within this sub-menu.Fluent setter for icon that returns this sub-menu for method chaining.withItem(QMenuItemInterface item) Fluently add a single itemwithItems(List<QMenuItemInterface> items) Fluent setter for itemsFluent setter for label that returns this sub-menu for method chaining.Methods inherited from class com.kingsrook.qqq.backend.core.model.metadata.menus.items.QMenuItemBase
getIcon, getLabel, setIcon, setLabel
-
Constructor Details
-
QMenuItemSubMenu
public QMenuItemSubMenu()
-
-
Method Details
-
getItemType
Returns the item type identifier for sub-menu menu items.- Specified by:
getItemTypein interfaceQMenuItemInterface- Returns:
- always returns "SUB_MENU"
-
getValues
Returns the values map containing the list of items in this sub-menu.- Specified by:
getValuesin interfaceQMenuItemInterface- Returns:
- a map containing the items list under the key "items"
-
validate
public void validate(QInstanceValidator validator, QInstance qInstance, QMetaDataObject parentObject) Validates all menu items contained within this sub-menu.Recursively validates each item in the sub-menu, passing this sub-menu as the parent object for validation context.
- Specified by:
validatein interfaceQMenuItemInterface- Parameters:
validator- the validator instance to use for reporting errorsqInstance- the QQQ instance being validatedparentObject- the parent metadata object containing this sub-menu
-
withLabel
Fluent setter for label that returns this sub-menu for method chaining.- Overrides:
withLabelin classQMenuItemBase- Parameters:
label- user-facing text to display as the label for this sub-menu- Returns:
- this sub-menu instance
-
withIcon
Fluent setter for icon that returns this sub-menu for method chaining.- Overrides:
withIconin classQMenuItemBase- Parameters:
icon- optional icon to display with this sub-menu- Returns:
- this sub-menu instance
-
getItems
Getter for items- Specified by:
getItemsin interfaceQMenuItemContainerInterface- Returns:
- the list of menu items, which may be empty but should not be null
- See Also:
-
setItems
-
withItems
Fluent setter for items- Parameters:
items- Contents of the sub Menu- Returns:
- this
-
clone
Creates and returns a deep copy of this sub-menu menu item.The cloned sub-menu will have its own copy of the items list, with each item also being cloned. This ensures that modifications to the cloned sub-menu or its items will not affect the original.
- Specified by:
clonein interfaceQMenuItemInterface- Overrides:
clonein classQMenuItemBase- Returns:
- a deep clone of this sub-menu menu item
-