Class AbstractMenu

All Implemented Interfaces:
com.globalmentor.beans.PropertyBindable, com.globalmentor.beans.PropertyConstrainable, io.clogr.Clogged, ActionControl, Component, CompositeComponent, Container, ContainerControl, Control, InputFocusableComponent, LabelDisplayableComponent, LayoutComponent, Menu, ActionListenable, ActionModel, Displayable, Enableable, InfoModel, LabelModel, Model, PresentationModel, DepictedObject, Iterable<Component>
Direct Known Subclasses:
AccordionMenu, DropMenu

public abstract class AbstractMenu extends AbstractContainerControl implements Menu
An abstract menu component. This implementation initially closes any child menu added to this menu.
Author:
Garret Wilson
  • Constructor Details

    • AbstractMenu

      public AbstractMenu(InfoModel infoModel, ActionModel actionModel, Enableable enableable, MenuLayout layout)
      Info model, action model, enableable, and menu layout constructor.
      Parameters:
      infoModel - The component info model.
      actionModel - The component action model.
      enableable - The enableable object in which to store enabled status.
      layout - The layout definition for the container.
      Throws:
      NullPointerException - if the given info model, action model, enableable, and/or layout is null.
  • Method Details

    • getLayout

      public MenuLayout getLayout()
      Specified by:
      getLayout in interface LayoutComponent
      Specified by:
      getLayout in interface Menu
      Overrides:
      getLayout in class AbstractLayoutComponent
      Returns:
      The layout definition for the container.
    • getActionModel

      protected ActionModel getActionModel()
      Returns:
      The action model used by this component.
    • isIconDisplayed

      public boolean isIconDisplayed()
      Specified by:
      isIconDisplayed in interface LabelDisplayableComponent
      Returns:
      Whether the icon is displayed.
    • setIconDisplayed

      public void setIconDisplayed(boolean newIconDisplayed)
      Description copied from interface: LabelDisplayableComponent
      Sets whether the icon is displayed. This is a bound property of type Boolean.
      Specified by:
      setIconDisplayed in interface LabelDisplayableComponent
      Parameters:
      newIconDisplayed - true if the icon should be displayed, else false if the icon should not be displayed and take up no space.
      See Also:
    • isLabelDisplayed

      public boolean isLabelDisplayed()
      Specified by:
      isLabelDisplayed in interface LabelDisplayableComponent
      Returns:
      Whether the label is displayed.
    • setLabelDisplayed

      public void setLabelDisplayed(boolean newLabelDisplayed)
      Description copied from interface: LabelDisplayableComponent
      Sets whether the label is displayed. This is a bound property of type Boolean.
      Specified by:
      setLabelDisplayed in interface LabelDisplayableComponent
      Parameters:
      newLabelDisplayed - true if the label should be displayed, else false if the label should not be displayed and take up no space.
      See Also:
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Menu
      Returns:
      Whether the menu is open.
    • setOpen

      public void setOpen(boolean newOpen)
      Description copied from interface: Menu
      Sets whether the menu is open. This is a bound property of type Boolean.
      Specified by:
      setOpen in interface Menu
      Parameters:
      newOpen - true if the menu should be open.
      See Also:
    • isRollover

      public boolean isRollover()
      Specified by:
      isRollover in interface ActionControl
      Returns:
      Whether the component is in a rollover state.
    • setRollover

      public void setRollover(boolean newRollover)
      Description copied from interface: ActionControl
      Sets whether the component is in a rollover state. This is a bound property of type Boolean.
      Specified by:
      setRollover in interface ActionControl
      Parameters:
      newRollover - true if the component should be in a rollover state, else false.
      See Also:
    • isRolloverOpenEnabled

      public boolean isRolloverOpenEnabled()
      Specified by:
      isRolloverOpenEnabled in interface Menu
      Returns:
      Whether the menu children will be shown during rollover.
    • setRolloverOpenEnabled

      public void setRolloverOpenEnabled(boolean newRolloverOpenEnabled)
      Description copied from interface: Menu
      Sets whether the menu children will be shown during rollover. If rollover open is enabled, the open state will not actually be changed during rollover. This is a bound property of type Boolean.
      Specified by:
      setRolloverOpenEnabled in interface Menu
      Parameters:
      newRolloverOpenEnabled - true if the component should allow display during rollover, else false.
      See Also:
    • addActionListener

      public void addActionListener(ActionListener actionListener)
      Description copied from interface: ActionListenable
      Adds an action listener.
      Specified by:
      addActionListener in interface ActionListenable
      Parameters:
      actionListener - The action listener to add.
    • removeActionListener

      public void removeActionListener(ActionListener actionListener)
      Description copied from interface: ActionListenable
      Removes an action listener.
      Specified by:
      removeActionListener in interface ActionListenable
      Parameters:
      actionListener - The action listener to remove.
    • getActionListeners

      public Iterable<ActionListener> getActionListeners()
      Specified by:
      getActionListeners in interface ActionModel
      Returns:
      all registered action listeners.
    • performAction

      public void performAction()
      Description copied from interface: ActionModel
      Performs the action with default force and default option. An ActionEvent is fired to all registered ActionListeners. This method delegates to ActionModel.performAction(int, int).
      Specified by:
      performAction in interface ActionModel
    • performAction

      public void performAction(int force, int option)
      Description copied from interface: ActionModel
      Performs the action with the given force and option. An ActionEvent is fired to all registered ActionListeners.
      Specified by:
      performAction in interface ActionModel
      Parameters:
      force - The zero-based force, such as 0 for no force or 1 for an action initiated by from a mouse single click.
      option - The zero-based option, such as 0 for an event initiated by a mouse left button click or 1 for an event initiated by a mouse right button click.
    • fireActionPerformed

      protected void fireActionPerformed(int force, int option)
      Fires an action event to all registered action listeners. This method delegates to fireActionPerformed(ActionEvent).
      Parameters:
      force - The zero-based force, such as 0 for no force or 1 for an action initiated by from a mouse single click.
      option - The zero-based option, such as 0 for an event initiated by a mouse left button click or 1 for an event initiaged by a mouse right button click.
      See Also:
    • fireActionPerformed

      protected void fireActionPerformed(ActionEvent actionEvent)
      Fires a given action event to all registered action listeners.
      Parameters:
      actionEvent - The action event to fire.
    • addComponent

      protected void addComponent(int index, Component childComponent)
      Description copied from class: AbstractListCompositeComponent
      Adds a child component at the specified index. This version adds the component to the component list. Any class that overrides this method must call this version.
      Overrides:
      addComponent in class AbstractLayoutComponent
      Parameters:
      index - The index at which the component should be added.
      childComponent - The component to add to this component.
    • createComponent

      public Component createComponent(Prototype prototype)
      Creates a component appropriate for the context of this component from the given prototype. This version creates the following components, in order of priority:
      ActionPrototype
      Button
      LabelPrototype
      Label
      MenuPrototype
      DropMenu
      TogglePrototype
      BooleanSelectButton
      ValuePrototype<Boolean>
      CheckControl
      ValuePrototype<Number> with installed RangeValidator
      SliderControl
      ValuePrototype<?>
      TextControl

      Creates a component appropriate for the context of this component from the given prototype. This implementation creates the following components, in order of priority:

      ActionPrototype
      Link
      Overrides:
      createComponent in class AbstractContainer
      Parameters:
      prototype - The prototype of the component to create.
      Returns:
      A new component based upon the given prototype.