Class VMenuBar

  • All Implemented Interfaces:
    com.google.gwt.event.dom.client.FocusHandler, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.KeyPressHandler, com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.EventHandler, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.AcceptsOneWidget, com.google.gwt.user.client.ui.HasOneWidget, com.google.gwt.user.client.ui.HasVisibility, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.HasWidgets.ForIsWidget, com.google.gwt.user.client.ui.IsWidget, Focusable, SubPartAware, Iterable<com.google.gwt.user.client.ui.Widget>

    public class VMenuBar
    extends SimpleFocusablePanel
    implements com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>, com.google.gwt.event.dom.client.KeyPressHandler, com.google.gwt.event.dom.client.KeyDownHandler, com.google.gwt.event.dom.client.FocusHandler, SubPartAware
    • Field Detail

      • uidlId

        public String uidlId
        For server connections.

        For internal use only. May be removed or replaced in the future.

      • client

        public ApplicationConnection client
        For internal use only. May be removed or replaced in the future.
      • hostReference

        public final VMenuBar hostReference
        For internal use only. May be removed or replaced in the future.
      • moreItem

        public VMenuBar.CustomMenuItem moreItem
        For internal use only. May be removed or replaced in the future.
      • collapsedRootItems

        public VMenuBar collapsedRootItems
        For internal use only. May be removed or replaced in the future.
      • emptyCommand

        public static final com.google.gwt.user.client.Command emptyCommand
        An empty command to be used when the item has no command associated

        For internal use only. May be removed or replaced in the future.

      • subMenu

        protected boolean subMenu
        Widget fields
      • containerElement

        protected com.google.gwt.dom.client.Element containerElement
      • visibleChildMenu

        protected VMenuBar visibleChildMenu
      • menuVisible

        protected boolean menuVisible
      • parentMenu

        protected VMenuBar parentMenu
      • enabled

        public boolean enabled
        For internal use only. May be removed or replaced in the future.
      • openRootOnHover

        public boolean openRootOnHover
        For internal use only. May be removed or replaced in the future.
      • mouseDownPressed

        public boolean mouseDownPressed
      • htmlContentAllowed

        public boolean htmlContentAllowed
        For internal use only. May be removed or replaced in the future.
    • Constructor Detail

      • VMenuBar

        public VMenuBar()
      • VMenuBar

        public VMenuBar​(boolean subMenu,
                        VMenuBar parentMenu)
    • Method Detail

      • setStyleName

        public void setStyleName​(String style)
        Overrides:
        setStyleName in class com.google.gwt.user.client.ui.UIObject
      • setStylePrimaryName

        public void setStylePrimaryName​(String style)
        Overrides:
        setStylePrimaryName in class com.google.gwt.user.client.ui.UIObject
      • updateStyleNames

        protected void updateStyleNames()
      • onDetach

        protected void onDetach()
        Overrides:
        onDetach in class com.google.gwt.user.client.ui.Widget
      • buildItemHTML

        public String buildItemHTML​(UIDL item)
        Build the HTML content for a menu item.

        For internal use only. May be removed or replaced in the future.

      • onMenuClick

        public void onMenuClick​(int clickedItemId)
        This is called by the items in the menu and it communicates the information to the server
        Parameters:
        clickedItemId - id of the item that was clicked
      • clearItems

        public void clearItems()
        Remove all the items in this menu
      • getContainerElement

        public com.google.gwt.user.client.Element getContainerElement()
        Returns the containing element of the menu
        Overrides:
        getContainerElement in class com.google.gwt.user.client.ui.SimplePanel
        Returns:
      • addItem

        public VMenuBar.CustomMenuItem addItem​(String html,
                                               com.google.gwt.user.client.Command cmd)
        Add a new item to this menu
        Parameters:
        html - items text
        cmd - items command
        Returns:
        the item created
      • removeItem

        public void removeItem​(VMenuBar.CustomMenuItem item)
        Remove the given item from this menu
        Parameters:
        item -
      • onBrowserEvent

        public void onBrowserEvent​(com.google.gwt.user.client.Event e)
        Specified by:
        onBrowserEvent in interface com.google.gwt.user.client.EventListener
        Overrides:
        onBrowserEvent in class com.google.gwt.user.client.ui.Widget
      • itemOver

        public void itemOver​(VMenuBar.CustomMenuItem item)
        When the user hovers the mouse over the item
        Parameters:
        item -
      • itemOut

        public void itemOut​(VMenuBar.CustomMenuItem item)
        When the mouse is moved away from an item
        Parameters:
        item -
      • showChildMenu

        public void showChildMenu​(VMenuBar.CustomMenuItem item)
        Shows the child menu of an item. The caller must ensure that the item has a submenu.
        Parameters:
        item -
      • createOverlay

        protected VOverlay createOverlay()
        Create an overlay for the menu bar. This method can be overridden to use a custom overlay.
        Returns:
        overlay to use
        Since:
        7.6
      • hideChildMenu

        public void hideChildMenu​(VMenuBar.CustomMenuItem item)
        Hides the submenu of an item
        Parameters:
        item -
      • onShow

        public void onShow()
        When the menu is shown.
      • onClose

        public void onClose​(com.google.gwt.event.logical.shared.CloseEvent<com.google.gwt.user.client.ui.PopupPanel> event)
        Listener method, fired when this menu is closed
        Specified by:
        onClose in interface com.google.gwt.event.logical.shared.CloseHandler<com.google.gwt.user.client.ui.PopupPanel>
      • hideChildren

        public void hideChildren()
        Recursively hide all child menus
      • hideChildren

        public void hideChildren​(boolean animateIn,
                                 boolean animateOut)
        Recursively hide all child menus
        Parameters:
        animateIn - enable/disable animate-in animation when hide popup
        animateOut - enable/disable animate-out animation when hide popup
        Since:
        7.3.7
      • hideParents

        public void hideParents​(boolean autoClosed)
        Recursively hide all parent menus
      • getParentMenu

        public VMenuBar getParentMenu()
        Returns the parent menu of this menu, or null if this is the top-level menu
        Returns:
      • setParentMenu

        public void setParentMenu​(VMenuBar parent)
        Set the parent menu of this menu
        Parameters:
        parent -
      • getSelected

        public VMenuBar.CustomMenuItem getSelected()
        Returns the currently selected item of this menu, or null if nothing is selected
        Returns:
      • setSelected

        public void setSelected​(VMenuBar.CustomMenuItem item)
        Set the currently selected item of this menu
        Parameters:
        item -
      • iLayout

        public void iLayout()
      • iLayout

        public void iLayout​(boolean iconLoadEvent)
      • onKeyPress

        public void onKeyPress​(com.google.gwt.event.dom.client.KeyPressEvent event)
        Specified by:
        onKeyPress in interface com.google.gwt.event.dom.client.KeyPressHandler
      • onKeyDown

        public void onKeyDown​(com.google.gwt.event.dom.client.KeyDownEvent event)
        Specified by:
        onKeyDown in interface com.google.gwt.event.dom.client.KeyDownHandler
      • getNavigationUpKey

        protected int getNavigationUpKey()
        Get the key that moves the selection upwards. By default it is the up arrow key but by overriding this you can change the key to whatever you want.
        Returns:
        The keycode of the key
      • getNavigationDownKey

        protected int getNavigationDownKey()
        Get the key that moves the selection downwards. By default it is the down arrow key but by overriding this you can change the key to whatever you want.
        Returns:
        The keycode of the key
      • getNavigationLeftKey

        protected int getNavigationLeftKey()
        Get the key that moves the selection left. By default it is the left arrow key but by overriding this you can change the key to whatever you want.
        Returns:
        The keycode of the key
      • getNavigationRightKey

        protected int getNavigationRightKey()
        Get the key that moves the selection right. By default it is the right arrow key but by overriding this you can change the key to whatever you want.
        Returns:
        The keycode of the key
      • getNavigationSelectKey

        @Deprecated
        protected int getNavigationSelectKey()
        Deprecated.
        Get the key that selects a menu item. By default it is the Enter key but by overriding this you can change the key to whatever you want.
        Returns:
      • isNavigationSelectKey

        protected boolean isNavigationSelectKey​(int keycode)
        Checks whether key code selects a menu item. By default it is the Enter and Space keys but by overriding this you can change the keys to whatever you want.
        Parameters:
        keycode -
        Returns:
        true if key selects menu item
        Since:
        7.2
      • getCloseMenuKey

        protected int getCloseMenuKey()
        Get the key that closes the menu. By default it is the escape key but by overriding this yoy can change the key to whatever you want.
        Returns:
      • handleNavigation

        public boolean handleNavigation​(int keycode,
                                        boolean ctrl,
                                        boolean shift)
        Handles the keyboard events handled by the MenuBar
        Parameters:
        event - The keyboard event received
        Returns:
        true iff the navigation event was handled
      • onFocus

        public void onFocus​(com.google.gwt.event.dom.client.FocusEvent event)
        Specified by:
        onFocus in interface com.google.gwt.event.dom.client.FocusHandler
      • getSubPartElement

        public com.google.gwt.user.client.Element getSubPartElement​(String subPart)
        Description copied from interface: SubPartAware
        Locates an element inside a component using the identifier provided in subPart. The subPart identifier is component specific and may be any string of characters, numbers, space characters and brackets.
        Specified by:
        getSubPartElement in interface SubPartAware
        Parameters:
        subPart - The identifier for the element inside the component
        Returns:
        The element identified by subPart or null if the element could not be found.
      • getSubPartName

        public String getSubPartName​(com.google.gwt.user.client.Element subElement)
        Description copied from interface: SubPartAware
        Provides an identifier that identifies the element within the component. The subElement is a part of the component and must never be null.

        Note! getSubPartElement(getSubPartName(element)) == element is not always true. A component can choose to provide a more generic identifier for any given element if the results of all interactions with subElement are the same as interactions with the element identified by the return value. For example a button can return an identifier for the root element even though a DIV inside the button was passed as subElement because interactions with the DIV and the root button element produce the same result.

        Specified by:
        getSubPartName in interface SubPartAware
        Parameters:
        subElement - The element the identifier string should uniquely identify
        Returns:
        An identifier that uniquely identifies subElement or null if no identifier could be provided.
      • getMenuItemWithElement

        @Deprecated
        public VMenuBar.CustomMenuItem getMenuItemWithElement​(com.google.gwt.user.client.Element element)
        Deprecated.
        As of 7.2, call or override getMenuItemWithElement(Element) instead
        Get menu item with given DOM element
        Parameters:
        element - Element used in search
        Returns:
        Menu item or null if not found
      • getMenuItemWithElement

        public VMenuBar.CustomMenuItem getMenuItemWithElement​(com.google.gwt.dom.client.Element element)
        Get menu item with given DOM element
        Parameters:
        element - Element used in search
        Returns:
        Menu item or null if not found
        Since:
        7.2