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
Nested ClassesModifier and TypeClassDescriptionstatic classEvent sent after commit of data context fromcommitChanges()call.static classEvent sent before commit of data context fromcommitChanges()call.static classEvent sent before the new entity instance is set to edited entity container.static classEvent 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
FieldsModifier and TypeFieldDescriptionprotected booleanprotected booleanprotected booleanFields inherited from interface io.jmix.ui.screen.EditorScreen
ENABLE_EDITING, WINDOW_CLOSE, WINDOW_COMMIT, WINDOW_COMMIT_AND_CLOSEFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SubscriptionAdds a listener toStandardEditor.AfterCommitChangesEvent.protected SubscriptionAdds a listener toStandardEditor.BeforeCommitChangesEvent.protected ActionaddDefaultCloseAction(Messages messages, Icons icons) protected ActionaddDefaultCommitAction(Messages messages, Icons icons) protected ActionaddDefaultCommitAndCloseAction(Messages messages, Icons icons) protected ActionaddDefaultEnableEditingAction(Messages messages, Icons icons) protected SubscriptionaddInitEntityListener(Consumer<StandardEditor.InitEntityEvent<T>> listener) Adds a listener toStandardEditor.InitEntityEvent.protected SubscriptionAdds a listener toStandardEditor.ValidationEvent.Tries to validate and commit data.Ignores the unsaved changes and closes the screen withFrameOwner.WINDOW_DISCARD_AND_CLOSE_ACTIONaction.protected OperationResultValidates screen and commits data context.protected voidprotected booleanprotected voidenableEditing(Action.ActionPerformedEvent actionPerformedEvent) protected InstanceContainer<T>protected InstanceLoaderprotected Stringbooleanprotected voidinitActions(Screen.InitEvent event) protected booleanprotected booleanprotected booleanisEntityModifiedRecursive(Object entity, DataContext dataContext, HashSet<Object> visited) booleanisLocked()protected booleanbooleanbooleanbooleanprotected booleanprotected voidprotected voidprotected voidprotected voidprotected voidsetCrossFieldValidate(boolean crossFieldValidate) voidsetEntityToEdit(T item) Sets entity instance to editor.protected voidsetModifiedAfterOpen(boolean entityModified) voidsetReadOnly(boolean readOnly) Changes the read-only mode.voidsetShowSaveNotification(boolean showSaveNotification) Sets whether a notification will be shown in case of successful commit.protected voidprotected voidprotected voidprotected voidprotected voidprotected ValidationErrorsValidates screen data.protected ValidationErrorsValidates 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, isScreenAction, 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:
getEditedEntityin interfaceEditorScreen<T>- Returns:
- currently edited entity instance
-
setEntityToEdit
Description copied from interface:EditorScreenSets entity instance to editor.- Specified by:
setEntityToEditin interfaceEditorScreen<T>- Parameters:
item- entity
-
hasUnsavedChanges
public boolean hasUnsavedChanges()- Specified by:
hasUnsavedChangesin interfaceChangeTracker- Returns:
- true if screen has unsaved changes
-
commitChanges
Validates screen and commits data context.- Returns:
- operation result
-
isLocked
public boolean isLocked()- Specified by:
isLockedin 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
public 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:
isReadOnlyin interfaceReadOnlyAwareScreen- Returns:
- whether a screen controller in read-only mode.
-
setReadOnly
public void setReadOnly(boolean readOnly) Description copied from interface:ReadOnlyAwareScreenChanges the read-only mode.- Specified by:
setReadOnlyin interfaceReadOnlyAwareScreen- Parameters:
readOnly-trueto enable the read-only mode,falseotherwise
-
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_CLOSEaction. 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_ACTIONaction.- 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-trueif a notification needs to be shown,falseotherwise
-
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
-