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.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.Status, Action.UiPermissionAware
PROP_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 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 actionPerformed 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, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setIconFromSet, setPrimary, setShortcut, setShortcutCombination
equals, 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 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
public void refreshState()
Action
refreshState
in interface Action
refreshState
in class AbstractAction
public ListComponent getTarget()
getTarget
in interface Action.HasTarget
public void setTarget(ListComponent target)
setTarget
in interface Action.HasTarget
public boolean isEnabledByUiPermissions()
isEnabledByUiPermissions
in interface Action.UiPermissionAware
public void setEnabledByUiPermissions(boolean enabledByUiPermissions)
setEnabledByUiPermissions
in interface Action.UiPermissionAware
public boolean isVisibleByUiPermissions()
isVisibleByUiPermissions
in interface Action.UiPermissionAware
public void setVisibleByUiPermissions(boolean visibleByUiPermissions)
setVisibleByUiPermissions
in interface Action.UiPermissionAware
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 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