Package io.jmix.ui.action
Class BaseAction
java.lang.Object
io.jmix.ui.action.AbstractAction
io.jmix.ui.action.BaseAction
- All Implemented Interfaces:
- Action,- Action.HasPrimaryState,- Action.SecuredAction
- Direct Known Subclasses:
- AbstractLookupAction,- DateIntervalAction,- DialogAction,- EditorScreenShowEntityInfoAction,- EntityOpenAction,- FilterAction,- ListAction,- ReportExecutionBrowser.DownloadDocumentAction,- SubstituteUserAction,- ValueClearAction,- ValuesSelectAction
Action that can change its enabled and visible properties depending on the user permissions and current context.
 
The BaseAction is visible if the following conditions are met:
- setVisible(false) method was not called;
- there is no "hide" UI permission for this action.
The action is enabled if the following conditions are met:
- setEnabled(false) method was not called;
- there are no "hide" and "read-only" UI permissions for this action;
- isPermitted() method returns true;
- isApplicable() method returns true;
- all BaseAction.EnabledRules (if any) return true.
 Descendants may override isPermitted() and isApplicable() methods to define conditions in which
 action will be enabled.
 Also, you can use fluent API to create instances of BaseAction and assign handlers to them:
 
     Action action = new BaseAction("printAll")
             .withCaption("Print all")
             .withIcon(JmixIcon.PRINT.source())
             .withHandler(event -> {
                 // action logic here
              });
     docsTable.addAction(action);
 - 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceCallback interface which is invoked by the action to determine its enabled state.Nested classes/interfaces inherited from interface io.jmix.ui.action.ActionAction.ActionPerformedEvent, Action.AdjustWhenScreenReadOnly, Action.ExecutableAction, Action.HasPrimaryState, Action.HasSecurityConstraint, Action.HasTarget, Action.MainTabSheetAction, Action.ScreenOpeningAction, Action.SecuredAction, Action.Status
- 
Field SummaryFields inherited from class io.jmix.ui.action.AbstractActioncaption, description, enabled, eventHub, icon, id, owners, primary, shortcut, visibleFields inherited from interface io.jmix.ui.action.ActionPROP_CAPTION, PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_VISIBLE
- 
Constructor SummaryConstructorsModifierConstructorDescriptionBaseAction(String id) protectedBaseAction(String id, String shortcut) 
- 
Method SummaryModifier and TypeMethodDescriptionvoidactionPerform(Component component) Invoked by owning component to execute the action.voidaddEnabledRule(BaseAction.EnabledRule enabledRule) Add new enabled rule for the action.protected booleanCallback method which is invoked by the action to determine its enabled state.protected booleanbooleanprotected booleanCallback method which is invoked by the action to determine its enabled state.booleanvoidRefresh internal state of the action to initialize enabled, visible, caption, icon, etc.voidremoveEnabledRule(BaseAction.EnabledRule enabledRule) Remove enabled rule.voidsetEnabled(boolean enabled) voidsetEnabledByUiPermissions(boolean enabledByUiPermissions) protected voidsetEnabledInternal(boolean enabled) voidsetVisible(boolean visible) voidsetVisibleByUiPermissions(boolean visibleByUiPermissions) protected voidsetVisibleInternal(boolean visible) withCaption(String caption) Set caption using fluent API method.withDescription(String description) Set description using fluent API method.withHandler(Consumer<Action.ActionPerformedEvent> handler) Set action performed event handler using fluent API method.Set icon using fluent API method.withPrimary(boolean primary) Set whether this action is primary using fluent API method.withShortcut(String shortcut) Set shortcut using fluent API method.Methods inherited from class io.jmix.ui.action.AbstractActionaddOwner, addPropertyChangeListener, firePropertyChange, getCaption, getDescription, getEventHub, getIcon, getId, getOwner, getOwners, getShortcutCombination, hasSubscriptions, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setPrimary, setShortcut, setShortcutCombinationMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jmix.ui.action.ActionaddOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setShortcut, setShortcutCombination
- 
Constructor Details- 
BaseAction
- 
BaseAction
 
- 
- 
Method Details- 
isPermittedprotected boolean isPermitted()Callback method which is invoked by the action to determine its enabled state.- Returns:
- true if the action is enabled for the current user
 
- 
isApplicableprotected boolean isApplicable()Callback method which is invoked by the action to determine its enabled state.- Returns:
- true if the action is enabled for the current context, e.g. there is a selected row in a table
 
- 
isEnabledByRuleprotected boolean isEnabledByRule()
- 
setVisiblepublic void setVisible(boolean visible) - Specified by:
- setVisiblein interface- Action
- Overrides:
- setVisiblein class- AbstractAction
 
- 
setEnabledpublic void setEnabled(boolean enabled) - Specified by:
- setEnabledin interface- Action
- Overrides:
- setEnabledin class- AbstractAction
 
- 
setVisibleInternalprotected void setVisibleInternal(boolean visible) 
- 
setEnabledInternalprotected void setEnabledInternal(boolean enabled) 
- 
refreshStatepublic void refreshState()Description copied from interface:ActionRefresh 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:
- refreshStatein interface- Action
- Overrides:
- refreshStatein class- AbstractAction
 
- 
isEnabledByUiPermissionspublic boolean isEnabledByUiPermissions()- Specified by:
- isEnabledByUiPermissionsin interface- Action.SecuredAction
 
- 
setEnabledByUiPermissionspublic void setEnabledByUiPermissions(boolean enabledByUiPermissions) - Specified by:
- setEnabledByUiPermissionsin interface- Action.SecuredAction
 
- 
isVisibleByUiPermissionspublic boolean isVisibleByUiPermissions()- Specified by:
- isVisibleByUiPermissionsin interface- Action.SecuredAction
 
- 
setVisibleByUiPermissionspublic void setVisibleByUiPermissions(boolean visibleByUiPermissions) - Specified by:
- setVisibleByUiPermissionsin interface- Action.SecuredAction
 
- 
addEnabledRuleAdd new enabled rule for the action.- Parameters:
- enabledRule- boolean rule for the action enabled state
 
- 
removeEnabledRuleRemove enabled rule.- Parameters:
- enabledRule- boolean rule for the action enabled state
 
- 
actionPerformDescription copied from interface:ActionInvoked by owning component to execute the action.- Specified by:
- actionPerformin interface- Action
- Parameters:
- component- invoking component
 
- 
addActionPerformedListener
- 
withCaptionSet caption using fluent API method.- Parameters:
- caption- caption
- Returns:
- current instance of action
 
- 
withDescriptionSet description using fluent API method.- Parameters:
- description- description
- Returns:
- current instance of action
 
- 
withIconSet icon using fluent API method.- Parameters:
- icon- icon
- Returns:
- current instance of action
 
- 
withShortcutSet shortcut using fluent API method.- Parameters:
- shortcut- shortcut
- Returns:
- current instance of action
 
- 
withHandlerSet action performed event handler using fluent API method. Can be used instead of subclassing BaseAction class.- Parameters:
- handler- action performed handler
- Returns:
- current instance of action
 
- 
withPrimarySet whether this action is primary using fluent API method. Can be used instead of subclassing BaseAction class.- Parameters:
- primary- primary
- Returns:
- current instance of action
 
 
-