Package io.jmix.ui.screen
Class StandardEditor<T>
java.lang.Object
io.jmix.ui.screen.Screen
io.jmix.ui.screen.StandardEditor<T>
- Type Parameters:
T
- type of entity
- All Implemented Interfaces:
ChangeTracker
,EditorScreen<T>
,FrameOwner
,ReadOnlyAwareScreen
- Direct Known Subclasses:
AdditionalBusinessDayEdit
,BusinessCalendarEdit
,CandidateGroupsEdit
,CandidateUsersEdit
,CategoryAttrsEdit
,CategoryEdit
,ContentStorageEdit
,DashboardGroupEdit
,DecisionDetailsScreen
,DmnDecisionTableEdit
,EmailAttachmentEdit
,EmailTemplateAttachmentEdit
,EntityAttributeEdit
,EntityAttributeResourcePolicyModelEdit
,EntityInspectorEditor
,EntityResourcePolicyModelEdit
,ErrorDefinitionEdit
,EventListenerEdit
,ExecutionListenerEdit
,ExtensionPropertyEdit
,FieldEdit
,FilterConditionEdit
,FormFieldEdit
,FormOutcomeEdit
,FormParamEdit
,GraphQLResourcePolicyModelEdit
,HolidayEdit
,ImapMailBoxEdit
,ImapMessageEdit
,InAppNotificationEdit
,InAppNotificationView
,InOutBindingModelEdit
,InputDefinitionEdit
,JobDataEdit
,JobModelEdit
,JpqlParameterEdit
,JsonEmailTemplateEdit
,MBeanAttributeEditor
,MBeanInspectScreen
,MenuResourcePolicyModelEdit
,MessageDefinitionEdit
,OutputDefinitionEdit
,ParameterEdit
,ParameterEditor
,PersistentDashboardEdit
,PivotTableAggregationEdit
,PivotTablePropertyEdit
,ProcessDefinitionEdit
,ProcessInstanceEdit
,ProcessVariableEdit
,QueryParameterEditor
,RegionEditor
,ReportEditor
,ReportEmailTemplateEdit
,ReportGroupEditor
,ResourcePolicyModelEdit
,ResourceRoleModelEdit
,RowLevelPolicyModelEdit
,RowLevelRoleModelEdit
,ScheduledBusinessDayEdit
,ScreenResourcePolicyModelEdit
,SignalDefinitionEdit
,SpecificResourcePolicyModelEdit
,TaskListenerEdit
,TemplateBlockEdit
,TemplateBlockGroupEdit
,TemplateEditor
,TemplateGroupEdit
,TenantEdit
,TriggerModelEdit
,UserGroupEdit
,UserSubstitutionEdit
,ValueFormatEditor
,VariableInstanceDataEdit
,WebdavDocumentCollectionEdit
,WebdavShowDocumentVersionEdit
,WidgetEdit
,WidgetTemplateEdit
,WidgetTemplateGroupEdit
public abstract class StandardEditor<T>
extends Screen
implements EditorScreen<T>, ReadOnlyAwareScreen
Base class for editor screens.
Supports pessimistic locking, cross field validation and checks for unsaved changes on close.
Supports pessimistic locking, cross field validation and checks for unsaved changes on close.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Event sent after commit of data context fromcommitChanges()
call.static class
Event sent before commit of data context fromcommitChanges()
call.static class
Event sent before the new entity instance is set to edited entity container.static class
Event sent when screen is validated fromvalidateAdditionalRules(ValidationErrors)
call.Nested classes/interfaces inherited from class io.jmix.ui.screen.Screen
Screen.AfterCloseEvent, Screen.AfterDetachEvent, Screen.AfterInitEvent, Screen.AfterShowEvent, Screen.BeforeCloseEvent, Screen.BeforeShowEvent, Screen.InitEvent
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected boolean
protected boolean
Fields inherited from interface io.jmix.ui.screen.EditorScreen
ENABLE_EDITING, WINDOW_CLOSE, WINDOW_COMMIT, WINDOW_COMMIT_AND_CLOSE
Fields inherited from interface io.jmix.ui.screen.FrameOwner
NO_OPTIONS, WINDOW_CLOSE_ACTION, WINDOW_COMMIT_AND_CLOSE_ACTION, WINDOW_DISCARD_AND_CLOSE_ACTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Subscription
Adds a listener toStandardEditor.AfterCommitChangesEvent
.protected Subscription
Adds a listener toStandardEditor.BeforeCommitChangesEvent
.protected Action
addDefaultCloseAction
(Messages messages, Icons icons) protected Action
addDefaultCommitAction
(Messages messages, Icons icons) protected Action
addDefaultCommitAndCloseAction
(Messages messages, Icons icons) protected Action
addDefaultEnableEditingAction
(Messages messages, Icons icons) protected Subscription
addInitEntityListener
(Consumer<StandardEditor.InitEntityEvent<T>> listener) Adds a listener toStandardEditor.InitEntityEvent
.protected Subscription
Adds a listener toStandardEditor.ValidationEvent
.protected void
Tries to validate and commit data.Ignores the unsaved changes and closes the screen withFrameOwner.WINDOW_DISCARD_AND_CLOSE_ACTION
action.protected void
protected void
protected OperationResult
Validates screen and commits data context.protected void
protected boolean
protected void
enableEditing
(Action.ActionPerformedEvent actionPerformedEvent) protected InstanceContainer<T>
protected InstanceLoader
protected String
boolean
protected void
initActions
(Screen.InitEvent event) protected boolean
protected boolean
protected boolean
isEntityModifiedRecursive
(Object entity, DataContext dataContext, HashSet<Object> visited) boolean
isLocked()
protected boolean
boolean
protected boolean
boolean
protected boolean
protected void
protected void
protected void
protected void
protected void
setCrossFieldValidate
(boolean crossFieldValidate) void
setEntityToEdit
(T item) Sets entity instance to editor.protected void
setModifiedAfterOpen
(boolean entityModified) void
setReadOnly
(boolean readOnly) Changes the read-only mode.void
setShowSaveNotification
(boolean showSaveNotification) Sets whether a notification will be shown in case of successful commit.protected void
protected void
protected void
protected void
protected void
protected ValidationErrors
Validates screen data.protected ValidationErrors
Validates visible and enabled UI components.Methods inherited from class io.jmix.ui.screen.Screen
addAfterCloseListener, addAfterDetachListener, addAfterInitListener, addAfterShowListener, addBeforeCloseListener, addBeforeShowListener, addInitListener, addUrlParamsChangeListener, close, close, closeWithDefaultAction, fireEvent, getApplicationContext, getEventHub, getExtensions, getId, getScreenData, getUiEventListeners, getWindow, isMultipleOpen, isSameScreen, setApplicationContext, setExtensions, setId, setScreenData, setUiEventListeners, setWindow, show
-
Field Details
-
showSaveNotification
protected boolean showSaveNotification -
commitActionPerformed
protected boolean commitActionPerformed -
showEnableEditingBtn
protected boolean showEnableEditingBtn
-
-
Constructor Details
-
StandardEditor
protected StandardEditor()
-
-
Method Details
-
initActions
-
getWindowActionOptional
-
addDefaultCommitAndCloseAction
-
addDefaultCommitAction
-
addDefaultCloseAction
-
addDefaultEnableEditingAction
-
enableEditing
-
setupModifiedTracking
protected void setupModifiedTracking() -
onChangeEvent
-
onPostCommitEvent
-
preventUnsavedChanges
-
setupEntityToEdit
protected void setupEntityToEdit() -
setupLock
protected void setupLock() -
releaseLock
protected void releaseLock() -
doNotReloadEditedEntity
protected boolean doNotReloadEditedEntity() -
isEntityModifiedInParentContext
protected boolean isEntityModifiedInParentContext() -
isEntityModifiedRecursive
protected boolean isEntityModifiedRecursive(Object entity, DataContext dataContext, HashSet<Object> visited) -
getEditedEntityLoader
-
getEditedEntityContainer
-
getEditedEntity
- Specified by:
getEditedEntity
in interfaceEditorScreen<T>
- Returns:
- currently edited entity instance
-
setEntityToEdit
Description copied from interface:EditorScreen
Sets entity instance to editor.- Specified by:
setEntityToEdit
in interfaceEditorScreen<T>
- Parameters:
item
- entity
-
hasUnsavedChanges
public boolean hasUnsavedChanges()- Specified by:
hasUnsavedChanges
in interfaceChangeTracker
- Returns:
- true if screen has unsaved changes
-
commitChanges
Validates screen and commits data context.- Returns:
- operation result
-
isLocked
public boolean isLocked()- Specified by:
isLocked
in interfaceEditorScreen<T>
- Returns:
- true if the edited item has been pessimistically locked when the screen is opened
-
setModifiedAfterOpen
protected void setModifiedAfterOpen(boolean entityModified) -
isModifiedAfterOpen
protected boolean isModifiedAfterOpen()- Returns:
- true if data is modified after screen opening
-
isReadOnlyDueToLock
protected boolean isReadOnlyDueToLock()- Returns:
- true if the editor switched to read-only mode because the entity is locked by another user
-
isReadOnly
public boolean isReadOnly()- Specified by:
isReadOnly
in interfaceReadOnlyAwareScreen
- Returns:
- whether a screen controller in read-only mode.
-
setReadOnly
public void setReadOnly(boolean readOnly) Description copied from interface:ReadOnlyAwareScreen
Changes the read-only mode.- Specified by:
setReadOnly
in interfaceReadOnlyAwareScreen
- Parameters:
readOnly
-true
to enable the read-only mode,false
otherwise
-
disableCommitActions
protected void disableCommitActions() -
isCrossFieldValidate
protected boolean isCrossFieldValidate()- Returns:
- true if cross-field validation is enabled
-
setCrossFieldValidate
protected void setCrossFieldValidate(boolean crossFieldValidate) -
isUiListComponentsValidationEnabled
protected boolean isUiListComponentsValidationEnabled() -
validateScreen
Validates screen data. Default implementation validates visible and enabled UI components.
Can be overridden in subclasses.- Returns:
- validation errors
-
validateUiComponents
Validates visible and enabled UI components.
Can be overridden in subclasses.- Returns:
- validation errors
-
validateAdditionalRules
-
commitAndClose
-
commit
-
showSaveNotification
protected void showSaveNotification() -
getSaveNotificationCaption
-
cancel
-
closeWithCommit
Tries to validate and commit data. If data committed successfully then closes the screen withEditorScreen.WINDOW_COMMIT_AND_CLOSE
action. May show validation errors or open an additional dialog before closing the screen.- Returns:
- result of close request
-
closeWithDiscard
Ignores the unsaved changes and closes the screen withFrameOwner.WINDOW_DISCARD_AND_CLOSE_ACTION
action.- Returns:
- result of close request
-
isShowSaveNotification
public boolean isShowSaveNotification()- Returns:
- whether a notification will be shown in case of successful commit
-
setShowSaveNotification
public void setShowSaveNotification(boolean showSaveNotification) Sets whether a notification will be shown in case of successful commit.- Parameters:
showSaveNotification
-true
if a notification needs to be shown,false
otherwise
-
addInitEntityListener
Adds a listener toStandardEditor.InitEntityEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-
addBeforeCommitChangesListener
protected Subscription addBeforeCommitChangesListener(Consumer<StandardEditor.BeforeCommitChangesEvent> listener) Adds a listener toStandardEditor.BeforeCommitChangesEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-
addAfterCommitChangesListener
protected Subscription addAfterCommitChangesListener(Consumer<StandardEditor.AfterCommitChangesEvent> listener) Adds a listener toStandardEditor.AfterCommitChangesEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-
addValidationEventListener
protected Subscription addValidationEventListener(Consumer<StandardEditor.ValidationEvent> listener) Adds a listener toStandardEditor.ValidationEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-