Class AbstractAction

java.lang.Object
io.jmix.ui.action.AbstractAction
All Implemented Interfaces:
Action, Action.HasPrimaryState
Direct Known Subclasses:
AbstractPresentationAction, AbstractPrintFormAction, BaseAction, InputDialogAction, PropertyFilterImpl.OperationChangeAction

public abstract class AbstractAction extends Object implements Action, Action.HasPrimaryState
Abstract class for GUI actions.
  • Field Details

    • id

      protected String id
    • caption

      protected String caption
    • description

      protected String description
    • icon

      protected String icon
    • enabled

      protected boolean enabled
    • visible

      protected boolean visible
    • owners

      protected List<ActionOwner> owners
    • shortcut

      protected KeyCombination shortcut
    • primary

      protected boolean primary
    • eventHub

      protected EventHub eventHub
  • Constructor Details

    • AbstractAction

      protected AbstractAction()
    • AbstractAction

      protected AbstractAction(String id)
    • AbstractAction

      protected AbstractAction(String id, @Nullable String shortcut)
    • AbstractAction

      protected AbstractAction(String id, Action.Status status)
  • Method Details

    • getEventHub

      protected EventHub getEventHub()
    • hasSubscriptions

      protected boolean hasSubscriptions(Class<?> eventClass)
    • getId

      public String getId()
      Specified by:
      getId in interface Action
      Returns:
      action's identifier
    • getCaption

      @Nullable public String getCaption()
      Specified by:
      getCaption in interface Action
      Returns:
      action's caption
    • setCaption

      public void setCaption(@Nullable String caption)
      Specified by:
      setCaption in interface Action
    • getDescription

      @Nullable public String getDescription()
      Specified by:
      getDescription in interface Action
      Returns:
      action's description
    • setDescription

      public void setDescription(@Nullable String description)
      Specified by:
      setDescription in interface Action
    • getShortcutCombination

      @Nullable public KeyCombination getShortcutCombination()
      Specified by:
      getShortcutCombination in interface Action
      Returns:
      action's keyboard shortcut
    • setShortcutCombination

      public void setShortcutCombination(@Nullable KeyCombination shortcut)
      Specified by:
      setShortcutCombination in interface Action
    • setShortcut

      public void setShortcut(@Nullable String shortcut)
      Description copied from interface: Action
      Set shortcut from string representation.
      Specified by:
      setShortcut in interface Action
      Parameters:
      shortcut - string of type "Modifiers-Key", e.g. "Alt-N". Case-insensitive.
    • getIcon

      @Nullable public String getIcon()
      Specified by:
      getIcon in interface Action
      Returns:
      action's icon
    • setIcon

      public void setIcon(@Nullable String icon)
      Specified by:
      setIcon in interface Action
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface Action
      Returns:
      whether the action is currently enabled
    • setEnabled

      public void setEnabled(boolean enabled)
      Specified by:
      setEnabled in interface Action
    • isVisible

      public boolean isVisible()
      Specified by:
      isVisible in interface Action
      Returns:
      whether the action is currently visible
    • setVisible

      public void setVisible(boolean visible)
      Specified by:
      setVisible in interface Action
    • getOwners

      public Collection<ActionOwner> getOwners()
      Specified by:
      getOwners in interface Action
      Returns:
      the collection of owners
    • getOwner

      @Nullable public ActionOwner getOwner()
      Specified by:
      getOwner in interface Action
      Returns:
      a single component owning the action. If there are several owners, first will be returned.
    • addOwner

      public void addOwner(ActionOwner actionOwner)
      Description copied from interface: Action
      Add an owner component.
      Specified by:
      addOwner in interface Action
      Parameters:
      actionOwner - owner component
    • removeOwner

      public void removeOwner(ActionOwner actionOwner)
      Description copied from interface: Action
      Remove the owner component.
      Specified by:
      removeOwner in interface Action
      Parameters:
      actionOwner - owner component
    • addPropertyChangeListener

      public void addPropertyChangeListener(Consumer<PropertyChangeEvent> listener)
      Description copied from interface: Action
      Adds a listener to be notified about Enabled, Caption or Icon property changes.
      Specified by:
      addPropertyChangeListener in interface Action
      Parameters:
      listener - a listener object
    • removePropertyChangeListener

      public void removePropertyChangeListener(Consumer<PropertyChangeEvent> listener)
      Description copied from interface: Action
      Removes the listener.
      Specified by:
      removePropertyChangeListener in interface Action
      Parameters:
      listener - a listener object
      See Also:
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
    • refreshState

      public void refreshState()
      Description copied from interface: Action
      Refresh internal state of the action to initialize enabled, visible, caption, icon, etc. properties depending on programmatically set values and user permissions set at runtime.

      For example, this method is called by visual components holding actions when they are bound to data. At this moment the action can find out what entity it is connected to and change its state according to the user permissions.

      Specified by:
      refreshState in interface Action
    • isPrimary

      public boolean isPrimary()
      Specified by:
      isPrimary in interface Action.HasPrimaryState
      Returns:
      true if action is primary or false otherwise
    • setPrimary

      public void setPrimary(boolean primary)
      Description copied from interface: Action.HasPrimaryState
      Sets whether action is primary or not.
      Specified by:
      setPrimary in interface Action.HasPrimaryState
      Parameters:
      primary - primary