public class BaseAction extends AbstractAction implements Action.HasTarget, Action.UiPermissionAware
The BaseAction is visible if the following conditions are met:
The action is enabled if the following conditions are met:
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("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.Status, Action.UiPermissionAwarePROP_CAPTION, PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_VISIBLE| Constructor and Description |
|---|
BaseAction(java.lang.String id) |
| Modifier and Type | Method and Description |
|---|---|
void |
actionPerform(Component component)
Invoked by owning component when an action occurs.
|
void |
addEnabledRule(BaseAction.EnabledRule enabledRule)
Add new enabled rule for the action.
|
ListComponent |
getTarget() |
boolean |
isEnabledByUiPermissions() |
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) |
void |
setTarget(ListComponent target) |
void |
setVisible(boolean visible) |
void |
setVisibleByUiPermissions(boolean visibleByUiPermissions) |
BaseAction |
withCaption(java.lang.String caption)
Set caption usin 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 actionPerformed handler using fluent API method.
|
BaseAction |
withIcon(java.lang.String icon)
Set icon using fluent API method.
|
BaseAction |
withShortcut(java.lang.String shortcut)
Set shortcut using fluent API method.
|
addOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setIconFromSet, setPrimary, setShortcut, setShortcutCombinationequals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setIconFromSet, setShortcut, setShortcutCombinationpublic void setVisible(boolean visible)
setVisible in interface ActionsetVisible in class AbstractActionpublic void setEnabled(boolean enabled)
setEnabled in interface ActionsetEnabled in class AbstractActionpublic void refreshState()
ActionrefreshState in interface ActionrefreshState in class AbstractActionpublic ListComponent getTarget()
getTarget in interface Action.HasTargetpublic void setTarget(ListComponent target)
setTarget in interface Action.HasTargetpublic boolean isEnabledByUiPermissions()
isEnabledByUiPermissions in interface Action.UiPermissionAwarepublic void setEnabledByUiPermissions(boolean enabledByUiPermissions)
setEnabledByUiPermissions in interface Action.UiPermissionAwarepublic boolean isVisibleByUiPermissions()
isVisibleByUiPermissions in interface Action.UiPermissionAwarepublic void setVisibleByUiPermissions(boolean visibleByUiPermissions)
setVisibleByUiPermissions in interface Action.UiPermissionAwarepublic 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)
ActionactionPerform in interface Actioncomponent - invoking componentpublic 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 handler