Package io.jmix.flowui.screen
Class StandardEditor<T>
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.Composite<T>
io.jmix.flowui.screen.Screen<ScreenLayout>
io.jmix.flowui.screen.StandardScreen
io.jmix.flowui.screen.StandardEditor<T>
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasElement,com.vaadin.flow.router.AfterNavigationObserver,com.vaadin.flow.router.BeforeEnterObserver,com.vaadin.flow.router.BeforeLeaveObserver,com.vaadin.flow.router.internal.AfterNavigationHandler,com.vaadin.flow.router.internal.BeforeEnterHandler,com.vaadin.flow.router.internal.BeforeLeaveHandler,ChangeTracker,EditorScreen<T>,ReadOnlyAwareScreen,Serializable
public class StandardEditor<T>
extends StandardScreen
implements EditorScreen<T>, ReadOnlyAwareScreen
- See Also:
-
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()call.Nested classes/interfaces inherited from class io.jmix.flowui.screen.Screen
Screen.AfterCloseEvent, Screen.AfterShowEvent, Screen.BeforeCloseEvent, Screen.BeforeShowEvent, Screen.InitEvent -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.vaadin.flow.shared.RegistrationaddAfterCommitChangesListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.AfterCommitChangesEvent> listener) protected com.vaadin.flow.shared.RegistrationaddBeforeCommitChangesListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.BeforeCommitChangesEvent> listener) protected com.vaadin.flow.shared.RegistrationaddInitEntityListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.InitEntityEvent<T>> listener) voidbeforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) commit()protected OperationResultprotected booleanprotected voidfindEntityId(com.vaadin.flow.router.BeforeEnterEvent event) protected InstanceContainer<T>protected InstanceLoader<T>protected Stringbooleanprotected voidinitExistingEntity(String serializedEntityId) protected voidinitNewEntity(Class<T> entityClass) protected booleanbooleanprotected booleanprotected booleanisEntityModifiedRecursive(Object entity, DataContext dataContext, HashSet<Object> visited) protected booleanisLocked()protected booleanbooleanprotected booleanbooleanbooleanprotected voidonChangeEvent(DataContext.ChangeEvent changeEvent) protected voidonPostCommitEvent(DataContext.PostCommitEvent postCommitEvent) protected voidprotected voidvoidsetCrossFieldValidationEnabled(boolean crossFieldValidationEnabled) Sets whether cross-field validation should be performed before commit changes.voidsetEntityToEdit(T entity) 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.voidsetShowValidationErrors(boolean showValidationErrors) Sets whether to indicate about errors after components validation.protected voidprotected voidsetupEntityToEdit(String serializedEntityId) protected voidsetupEntityToEdit(T entityToEdit) protected voidprotected voidprotected ValidationErrorsprotected ValidationErrorsprotected ValidationErrorsMethods inherited from class io.jmix.flowui.screen.StandardScreen
initContentMethods inherited from class io.jmix.flowui.screen.Screen
addAfterCloseListener, addAfterShowListener, addBeforeCloseListener, addBeforeShowListener, addInitListener, afterNavigation, beforeLeave, close, close, closeWithDefaultAction, getApplicationContext, getId, getScreenActions, getScreenData, getScreenFacets, removeApplicationListeners, setApplicationContext, setId, setScreenActions, setScreenData, setScreenFacets, unregisterBackNavigation, updatePageTitleMethods inherited from class com.vaadin.flow.component.Composite
getChildren, getContent, getElementMethods inherited from class com.vaadin.flow.component.Component
addListener, fireEvent, from, get, getEventBus, getLocale, getParent, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, scrollIntoView, set, setElement, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
-
Field Details
-
NEW_ENTITY_ID
- See Also:
-
showSaveNotification
protected boolean showSaveNotification -
commitActionPerformed
protected boolean commitActionPerformed
-
-
Constructor Details
-
StandardEditor
public StandardEditor()
-
-
Method Details
-
setupModifiedTracking
protected void setupModifiedTracking() -
onChangeEvent
-
onPostCommitEvent
-
getSaveNotificationText
-
beforeEnter
public void beforeEnter(com.vaadin.flow.router.BeforeEnterEvent event) - Specified by:
beforeEnterin interfacecom.vaadin.flow.router.internal.BeforeEnterHandler- Overrides:
beforeEnterin classScreen<ScreenLayout>
-
findEntityId
protected void findEntityId(com.vaadin.flow.router.BeforeEnterEvent event) -
commitChanges
-
validateScreen
-
validateUiComponents
-
validateAdditionalRules
-
isCommitActionPerformed
protected boolean isCommitActionPerformed() -
commit
- Specified by:
commitin interfaceEditorScreen<T>
-
closeWithCommit
- Specified by:
closeWithCommitin interfaceEditorScreen<T>
-
closeWithDiscard
- Specified by:
closeWithDiscardin interfaceEditorScreen<T>
-
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
-
isShowValidationErrors
public boolean isShowValidationErrors()- Returns:
- whether to indicate about errors after components validation
-
setShowValidationErrors
public void setShowValidationErrors(boolean showValidationErrors) Sets whether to indicate about errors after components validation. The default value istrue.- Parameters:
showValidationErrors-trueif notification needs to be shown,falseotherwise
-
isCrossFieldValidationEnabled
public boolean isCrossFieldValidationEnabled()- Returns:
trueif cross-field validation is enabled
-
setCrossFieldValidationEnabled
public void setCrossFieldValidationEnabled(boolean crossFieldValidationEnabled) Sets whether cross-field validation should be performed before commit changes. It usesUiCrossFieldChecksconstraint group to validate bean instance. The default value istrue.- Parameters:
crossFieldValidationEnabled-trueif cross-field should be enabled,falseotherwise
-
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
-
preventUnsavedChanges
-
hasUnsavedChanges
public boolean hasUnsavedChanges()- Specified by:
hasUnsavedChangesin interfaceChangeTracker- Returns:
trueif screen has unsaved changes
-
getEditedEntityContainer
-
getEditedEntityLoader
-
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:
entity- entity
-
setupEntityToEdit
protected void setupEntityToEdit() -
setupEntityToEdit
-
initNewEntity
-
initExistingEntity
-
setupEntityToEdit
-
doNotReloadEditedEntity
protected boolean doNotReloadEditedEntity() -
isEntityModifiedInParentContext
protected boolean isEntityModifiedInParentContext() -
isEntityModifiedRecursive
protected boolean isEntityModifiedRecursive(Object entity, DataContext dataContext, HashSet<Object> visited) -
setupLock
protected void setupLock() -
releaseLock
protected void releaseLock() -
getPessimisticLockStatus
- Specified by:
getPessimisticLockStatusin interfaceEditorScreen<T>- Returns:
- lock status of currently edited entity instance. Possible variants:
PessimisticLockStatus.NOT_SUPPORTED- if the entity does not support pessimistic lock.PessimisticLockStatus.LOCKED- if the entity instance is successfully locked.PessimisticLockStatus.FAILED- if the entity instance has been locked when the screen is opened.
- See Also:
-
isReadOnlyDueToLock
protected boolean isReadOnlyDueToLock()- Returns:
trueif the editor switched to read-only mode because the entity is locked by another user
-
isLocked
protected boolean isLocked()- Returns:
trueif the entity instance has been pessimistically locked when the screen is opened
-
setModifiedAfterOpen
protected void setModifiedAfterOpen(boolean entityModified) -
isModifiedAfterOpen
protected boolean isModifiedAfterOpen()- Returns:
trueif data is modified after screen opening
-
addInitEntityListener
protected com.vaadin.flow.shared.Registration addInitEntityListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.InitEntityEvent<T>> listener) -
addBeforeCommitChangesListener
protected com.vaadin.flow.shared.Registration addBeforeCommitChangesListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.BeforeCommitChangesEvent> listener) -
addAfterCommitChangesListener
protected com.vaadin.flow.shared.Registration addAfterCommitChangesListener(com.vaadin.flow.component.ComponentEventListener<StandardEditor.AfterCommitChangesEvent> listener)
-