E
- type of entity@StudioAction(category="List Actions", description="Edits an entity instance using its editor screen") @ActionType(value="edit") public class EditAction<E extends Entity> extends SecuredListAction implements Action.AdjustWhenScreenReadOnly, Action.ExecutableAction
Should be defined for a list component (Table
, DataGrid
, etc.) in a screen XML descriptor.
The action instance can be parameterized using the nested properties
XML element or programmatically in the
screen controller.
BaseAction.EnabledRule
Action.ActionPerformedEvent, Action.AdjustWhenScreenReadOnly, Action.BeforeActionPerformedHandler, Action.DisabledWhenScreenReadOnly, Action.ExecutableAction, Action.HasBeforeActionPerformedHandler, Action.HasOpenType, Action.HasPrimaryState, Action.HasSecurityConstraint, Action.HasTarget, Action.SecuredAction, Action.Status
Modifier and Type | Field and Description |
---|---|
protected java.util.function.Consumer<E> |
afterCommitHandler |
protected boolean |
captionInitialized |
static java.lang.String |
ID |
protected Messages |
messages |
protected ScreenBuilders |
screenBuilders |
protected ActionScreenInitializer |
screenInitializer |
protected java.util.function.Function<E,E> |
transformation |
constraintCode, constraintOperationType, security
target
caption, description, enabled, eventHub, icon, id, owners, primary, shortcut, visible
PROP_CAPTION, PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_VISIBLE
Constructor and Description |
---|
EditAction() |
EditAction(java.lang.String id) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerform(Component component)
Invoked by owning component to execute the action.
|
void |
execute()
Executes the action.
|
OpenMode |
getOpenMode()
Returns the editor screen open mode if it was set by
setOpenMode(OpenMode) or in the screen XML. |
java.lang.Class |
getScreenClass()
Returns the editor screen class if it was set by
setScreenClass(Class) or in the screen XML. |
java.lang.String |
getScreenId()
Returns the editor screen id if it was set by
setScreenId(String) or in the screen XML. |
boolean |
isDisabledWhenScreenReadOnly() |
protected boolean |
isPermitted()
Callback method which is invoked by the action to determine its enabled state.
|
void |
refreshState()
Refresh internal state of the action to initialize enabled, visible, caption, icon, etc.
|
void |
setAfterCloseHandler(java.util.function.Consumer<Screen.AfterCloseEvent> afterCloseHandler)
Sets the handler to be invoked when the editor screen closes.
|
void |
setAfterCommitHandler(java.util.function.Consumer<E> afterCommitHandler)
Sets the handler to be invoked when the editor screen commits the entity.
|
void |
setCaption(java.lang.String caption) |
protected void |
setConfiguration(Configuration configuration) |
protected void |
setIcons(Icons icons) |
protected void |
setMessages(Messages messages) |
void |
setOpenMode(OpenMode openMode)
Sets the editor screen open mode.
|
void |
setScreenClass(java.lang.Class screenClass)
Sets the editor screen id.
|
void |
setScreenConfigurer(java.util.function.Consumer<Screen> screenConfigurer)
Sets the editor screen configurer.
|
void |
setScreenId(java.lang.String screenId)
Sets the editor screen id.
|
void |
setScreenOptionsSupplier(java.util.function.Supplier<ScreenOptions> screenOptionsSupplier)
Sets the editor screen options supplier.
|
void |
setTransformation(java.util.function.Function<E,E> transformation)
Sets the function to transform the committed in the editor screen entity before setting it to the target data container.
|
getConstraintCode, getConstraintOperationType, isApplicable, setConstraintCode, setConstraintOperationType, setSecurity
getTarget, setTarget, withCaption, withDescription, withHandler, withIcon, withPrimary, withShortcut
addActionPerformedListener, addEnabledRule, isEnabledByRule, isEnabledByUiPermissions, isVisibleByUiPermissions, removeEnabledRule, setEnabled, setEnabledByUiPermissions, setEnabledInternal, setVisible, setVisibleByUiPermissions, setVisibleInternal
addOwner, addPropertyChangeListener, firePropertyChange, getCaption, getDefaultCaption, getDescription, getEventHub, getIcon, getId, getOwner, getOwners, getShortcutCombination, hasSubscriptions, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, 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, setDescription, setEnabled, setIcon, setIconFromSet, setShortcut, setShortcutCombination, setVisible
public static final java.lang.String ID
@Inject protected ScreenBuilders screenBuilders
protected ActionScreenInitializer screenInitializer
protected java.util.function.Function<E extends Entity,E extends Entity> transformation
protected boolean captionInitialized
protected Messages messages
@Nullable public OpenMode getOpenMode()
setOpenMode(OpenMode)
or in the screen XML.
Otherwise returns null.@StudioPropertiesItem public void setOpenMode(OpenMode openMode)
@Nullable public java.lang.String getScreenId()
setScreenId(String)
or in the screen XML.
Otherwise returns null.@StudioPropertiesItem public void setScreenId(java.lang.String screenId)
@Nullable public java.lang.Class getScreenClass()
setScreenClass(Class)
or in the screen XML.
Otherwise returns null.@StudioPropertiesItem public void setScreenClass(java.lang.Class screenClass)
public void setScreenOptionsSupplier(java.util.function.Supplier<ScreenOptions> screenOptionsSupplier)
ScreenOptions
to the
opened screen.
The preferred way to set the supplier is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.edit", subject = "screenOptionsSupplier") protected ScreenOptions petsTableEditScreenOptionsSupplier() { return new MapScreenOptions(ParamsMap.of("someParameter", 10)); }
public void setScreenConfigurer(java.util.function.Consumer<Screen> screenConfigurer)
The preferred way to set the configurer is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.edit", subject = "screenConfigurer") protected void petsTableEditScreenConfigurer(Screen editorScreen) { ((PetEdit) editorScreen).setSomeParameter(someValue); }
public void setAfterCloseHandler(java.util.function.Consumer<Screen.AfterCloseEvent> afterCloseHandler)
The preferred way to set the handler is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.edit", subject = "afterCloseHandler") protected void petsTableEditAfterCloseHandler(AfterCloseEvent event) { if (event.closedWith(StandardOutcome.COMMIT)) { System.out.println("Committed"); } }
public void setAfterCommitHandler(java.util.function.Consumer<E> afterCommitHandler)
The preferred way to set the handler is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.edit", subject = "afterCommitHandler") protected void petsTableEditAfterCommitHandler(Pet entity) { System.out.println("Committed " + entity); }
public void setTransformation(java.util.function.Function<E,E> transformation)
The preferred way to set the function is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.edit", subject = "transformation") protected Pet petsTableEditTransformation(Pet entity) { return doTransform(entity); }
@Inject protected void setIcons(Icons icons)
@Inject protected void setMessages(Messages messages)
@Inject protected void setConfiguration(Configuration configuration)
public void setCaption(java.lang.String caption)
setCaption
in interface Action
setCaption
in class AbstractAction
protected boolean isPermitted()
BaseAction
isPermitted
in class SecuredListAction
public void refreshState()
Action
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.
refreshState
in interface Action
refreshState
in class BaseAction
public boolean isDisabledWhenScreenReadOnly()
isDisabledWhenScreenReadOnly
in interface Action.AdjustWhenScreenReadOnly
public void actionPerform(Component component)
Action
actionPerform
in interface Action
actionPerform
in class BaseAction
component
- invoking componentpublic void execute()
execute
in interface Action.ExecutableAction