Class WSubMenu

    • 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 text
        accessKey - 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.
      • isTopLevelMenu

        public boolean isTopLevelMenu()
        Indicates whether this is a top-level menu (ie. attached to a menu bar).
        Returns:
        true if this is a top-level menu.
      • addSeparator

        public void addSeparator()
        Adds a separator to the sub-menu.
      • 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.
      • isDisabled

        public boolean isDisabled()
        Indicates whether this sub menu is disabled in the given context.
        Specified by:
        isDisabled in interface Disableable
        Returns:
        true if this sub menu is disabled.
      • setDisabled

        public void setDisabled​(boolean disabled)
        Sets whether this sub menu is disabled.
        Specified by:
        setDisabled in interface Disableable
        Parameters:
        disabled - true to disable this sub menu, false to enable.
      • getAccessKey

        public char getAccessKey()
        Specified by:
        getAccessKey in interface AccessKeyable
        Returns:
        the component's access key.
      • setAccessKey

        public void setAccessKey​(char accessKey)
        Description copied from interface: AccessKeyable
        Set the access key on the component.
        Specified by:
        setAccessKey in interface AccessKeyable
        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 use WTree.
        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 use WTree.
        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 use WTree.
        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 use MenuItemSelectable.isSelectAllowed().
        Specified by:
        getSelectability in interface MenuItemSelectable
        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 use WTree.
        Specified by:
        setSelectability in interface MenuItemSelectable
        Parameters:
        selectability - true if this item is selectable, false if not, or null to default to the 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:
        isSelected in interface MenuItemSelectable
        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:
        handleRequest in interface WComponent
        Overrides:
        handleRequest in class AbstractWComponent
        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:
        preparePaintComponent in class AbstractWComponent
        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: AbstractWComponent
        Creates a String representation of this component; usually for debugging purposes.
        Overrides:
        toString in class AbstractWComponent
        Returns:
        a String representation of this component, for debugging purposes.
      • 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:
        getComponentModel in class AbstractWComponent
        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:
        getOrCreateComponentModel in class AbstractWComponent
        Returns:
        the model for this component