public class BaseAction extends AbstractAction implements Action.SecuredAction
The BaseAction is visible if the following conditions are met:
The action is enabled if the following conditions are met:
BaseAction.EnabledRule
s (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("icons/print.png")
.withHandler(event -> {
// action logic here
});
docsTable.addAction(action);
Modifier and Type | Class and Description |
---|---|
static interface |
BaseAction.EnabledRule
Callback interface which is invoked by the action to determine its enabled state.
|
Action.ActionPerformedEvent, Action.BeforeActionPerformedHandler, Action.HasBeforeActionPerformedHandler, Action.HasOpenType, Action.HasSecurityConstraint, Action.HasTarget, Action.SecuredAction, Action.Status
caption, description, enabled, eventHub, icon, id, owners, primary, shortcut, visible
PROP_CAPTION, PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_VISIBLE
Modifier | Constructor and Description |
---|---|
|
BaseAction(java.lang.String id) |
protected |
BaseAction(java.lang.String id,
java.lang.String shortcut) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerform(Component component)
Invoked by owning component when an action occurs.
|
Subscription |
addActionPerformedListener(java.util.function.Consumer<Action.ActionPerformedEvent> listener) |
void |
addEnabledRule(BaseAction.EnabledRule enabledRule)
Add new enabled rule for the action.
|
protected boolean |
isApplicable()
Callback method which is invoked by the action to determine its enabled state.
|
protected boolean |
isEnabledByRule() |
boolean |
isEnabledByUiPermissions() |
protected boolean |
isPermitted()
Callback method which is invoked by the action to determine its enabled state.
|
boolean |
isVisibleByUiPermissions() |
void |
refreshState()
Refresh internal state of the action to initialize enabled, visible, caption, icon, etc.
|
void |
removeEnabledRule(BaseAction.EnabledRule enabledRule)
Remove enabled rule.
|
void |
setEnabled(boolean enabled) |
void |
setEnabledByUiPermissions(boolean enabledByUiPermissions) |
protected void |
setEnabledInternal(boolean enabled) |
void |
setVisible(boolean visible) |
void |
setVisibleByUiPermissions(boolean visibleByUiPermissions) |
protected void |
setVisibleInternal(boolean visible) |
BaseAction |
withCaption(java.lang.String caption)
Set caption using fluent API method.
|
BaseAction |
withDescription(java.lang.String description)
Set description using fluent API method.
|
BaseAction |
withHandler(java.util.function.Consumer<Action.ActionPerformedEvent> handler)
Set action performed event handler using fluent API method.
|
BaseAction |
withIcon(java.lang.String icon)
Set icon using fluent API method.
|
BaseAction |
withPrimary(boolean primary)
Set whether this action is primary using fluent API method.
|
BaseAction |
withShortcut(java.lang.String shortcut)
Set shortcut using fluent API method.
|
addOwner, addPropertyChangeListener, firePropertyChange, getCaption, getDefaultCaption, getDescription, getEventHub, getIcon, getId, getOwner, getOwners, getShortcutCombination, hasSubscriptions, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setIconFromSet, setPrimary, setShortcut, setShortcutCombination
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setIconFromSet, setShortcut, setShortcutCombination
public BaseAction(java.lang.String id)
protected BaseAction(java.lang.String id, @Nullable java.lang.String shortcut)
protected boolean isPermitted()
protected boolean isApplicable()
protected boolean isEnabledByRule()
public void setVisible(boolean visible)
setVisible
in interface Action
setVisible
in class AbstractAction
public void setEnabled(boolean enabled)
setEnabled
in interface Action
setEnabled
in class AbstractAction
protected void setVisibleInternal(boolean visible)
protected void setEnabledInternal(boolean enabled)
public void refreshState()
Action
refreshState
in interface Action
refreshState
in class AbstractAction
public boolean isEnabledByUiPermissions()
isEnabledByUiPermissions
in interface Action.SecuredAction
public void setEnabledByUiPermissions(boolean enabledByUiPermissions)
setEnabledByUiPermissions
in interface Action.SecuredAction
public boolean isVisibleByUiPermissions()
isVisibleByUiPermissions
in interface Action.SecuredAction
public void setVisibleByUiPermissions(boolean visibleByUiPermissions)
setVisibleByUiPermissions
in interface Action.SecuredAction
public void addEnabledRule(BaseAction.EnabledRule enabledRule)
enabledRule
- boolean rule for the action enabled statepublic void removeEnabledRule(BaseAction.EnabledRule enabledRule)
enabledRule
- boolean rule for the action enabled statepublic void actionPerform(Component component)
Action
actionPerform
in interface Action
component
- invoking componentpublic Subscription addActionPerformedListener(java.util.function.Consumer<Action.ActionPerformedEvent> listener)
public BaseAction withCaption(java.lang.String caption)
caption
- captionpublic BaseAction withDescription(java.lang.String description)
description
- descriptionpublic BaseAction withIcon(java.lang.String icon)
icon
- iconpublic BaseAction withShortcut(java.lang.String shortcut)
shortcut
- shortcutpublic BaseAction withHandler(java.util.function.Consumer<Action.ActionPerformedEvent> handler)
handler
- action performed handlerpublic BaseAction withPrimary(boolean primary)
primary
- primary