T
- type of entitypublic abstract class StandardEditor<T> extends Screen implements EditorScreen<T>, ReadOnlyAwareScreen
Modifier and Type | Class and Description |
---|---|
static class |
StandardEditor.AfterCommitChangesEvent
Event sent after commit of data context from
commitChanges() call. |
static class |
StandardEditor.BeforeCommitChangesEvent
Event sent before commit of data context from
commitChanges() call. |
static class |
StandardEditor.InitEntityEvent<E>
Event sent before the new entity instance is set to edited entity container.
|
static class |
StandardEditor.ValidationEvent
Event sent when screen is validated from
validateAdditionalRules(ValidationErrors) call. |
Screen.AfterCloseEvent, Screen.AfterDetachEvent, Screen.AfterInitEvent, Screen.AfterShowEvent, Screen.BeforeCloseEvent, Screen.BeforeShowEvent, Screen.InitEvent
Modifier and Type | Field and Description |
---|---|
protected boolean |
commitActionPerformed |
protected boolean |
showEnableEditingBtn |
protected boolean |
showSaveNotification |
ENABLE_EDITING, WINDOW_CLOSE, WINDOW_COMMIT, WINDOW_COMMIT_AND_CLOSE
NO_OPTIONS, WINDOW_CLOSE_ACTION, WINDOW_COMMIT_AND_CLOSE_ACTION, WINDOW_DISCARD_AND_CLOSE_ACTION
Modifier | Constructor and Description |
---|---|
protected |
StandardEditor() |
Modifier and Type | Method and Description |
---|---|
protected io.jmix.core.common.event.Subscription |
addAfterCommitChangesListener(java.util.function.Consumer<StandardEditor.AfterCommitChangesEvent> listener)
Adds a listener to
StandardEditor.AfterCommitChangesEvent . |
protected io.jmix.core.common.event.Subscription |
addBeforeCommitChangesListener(java.util.function.Consumer<StandardEditor.BeforeCommitChangesEvent> listener)
Adds a listener to
StandardEditor.BeforeCommitChangesEvent . |
protected Action |
addDefaultCloseAction(io.jmix.core.Messages messages,
Icons icons) |
protected Action |
addDefaultCommitAction(io.jmix.core.Messages messages,
Icons icons) |
protected Action |
addDefaultCommitAndCloseAction(io.jmix.core.Messages messages,
Icons icons) |
protected Action |
addDefaultEnableEditingAction(io.jmix.core.Messages messages,
Icons icons) |
protected io.jmix.core.common.event.Subscription |
addInitEntityListener(java.util.function.Consumer<StandardEditor.InitEntityEvent<T>> listener)
Adds a listener to
StandardEditor.InitEntityEvent . |
protected io.jmix.core.common.event.Subscription |
addValidationEventListener(java.util.function.Consumer<StandardEditor.ValidationEvent> listener)
Adds a listener to
StandardEditor.ValidationEvent . |
protected void |
cancel(Action.ActionPerformedEvent event) |
OperationResult |
closeWithCommit()
Tries to validate and commit data.
|
OperationResult |
closeWithDiscard()
Ignores the unsaved changes and closes the screen with
FrameOwner.WINDOW_DISCARD_AND_CLOSE_ACTION action. |
protected void |
commit(Action.ActionPerformedEvent event) |
protected void |
commitAndClose(Action.ActionPerformedEvent event) |
protected OperationResult |
commitChanges()
Validates screen and commits data context.
|
protected void |
disableCommitActions() |
protected boolean |
doNotReloadEditedEntity() |
protected void |
editedEntityCommitted(DataContext.PostCommitEvent event) |
protected void |
editedEntityModified(DataContext.ChangeEvent event) |
protected void |
enableEditing(Action.ActionPerformedEvent actionPerformedEvent) |
T |
getEditedEntity() |
protected InstanceContainer<T> |
getEditedEntityContainer() |
protected InstanceLoader |
getEditedEntityLoader() |
protected java.lang.String |
getSaveNotificationCaption() |
protected java.util.Optional<Action> |
getWindowActionOptional(java.lang.String id) |
boolean |
hasUnsavedChanges() |
protected void |
initActions(Screen.InitEvent event) |
protected boolean |
isCrossFieldValidate() |
protected boolean |
isEntityModified() |
protected boolean |
isEntityModifiedInParentContext() |
protected boolean |
isEntityModifiedRecursive(java.lang.Object entity,
DataContext dataContext,
java.util.HashSet<java.lang.Object> visited) |
boolean |
isLocked() |
boolean |
isReadOnly() |
protected boolean |
isReadOnlyDueToLock() |
boolean |
isShowSaveNotification() |
protected void |
preventUnsavedChanges(Screen.BeforeCloseEvent event) |
protected void |
releaseLock() |
protected void |
setCrossFieldValidate(boolean crossFieldValidate) |
protected void |
setEntityModified(boolean entityModified) |
void |
setEntityToEdit(T item)
Sets entity instance to editor.
|
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 |
setupEntityToEdit() |
protected void |
setupLock() |
protected void |
setupModifiedTracking() |
protected void |
showSaveNotification() |
protected void |
validateAdditionalRules(ValidationErrors errors) |
protected ValidationErrors |
validateScreen()
Validates screen data.
|
protected ValidationErrors |
validateUiComponents()
Validates visible and enabled UI components.
|
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
protected boolean showSaveNotification
protected boolean commitActionPerformed
protected boolean showEnableEditingBtn
protected void initActions(Screen.InitEvent event)
protected java.util.Optional<Action> getWindowActionOptional(java.lang.String id)
protected Action addDefaultCommitAndCloseAction(io.jmix.core.Messages messages, Icons icons)
protected Action addDefaultCommitAction(io.jmix.core.Messages messages, Icons icons)
protected Action addDefaultCloseAction(io.jmix.core.Messages messages, Icons icons)
protected Action addDefaultEnableEditingAction(io.jmix.core.Messages messages, Icons icons)
protected void enableEditing(Action.ActionPerformedEvent actionPerformedEvent)
protected void setupModifiedTracking()
protected void editedEntityModified(DataContext.ChangeEvent event)
protected void editedEntityCommitted(DataContext.PostCommitEvent event)
protected void preventUnsavedChanges(Screen.BeforeCloseEvent event)
protected void setupEntityToEdit()
protected void setupLock()
protected void releaseLock()
protected boolean doNotReloadEditedEntity()
protected boolean isEntityModifiedInParentContext()
protected boolean isEntityModifiedRecursive(java.lang.Object entity, DataContext dataContext, java.util.HashSet<java.lang.Object> visited)
protected InstanceLoader getEditedEntityLoader()
protected InstanceContainer<T> getEditedEntityContainer()
public T getEditedEntity()
getEditedEntity
in interface EditorScreen<T>
public void setEntityToEdit(T item)
EditorScreen
setEntityToEdit
in interface EditorScreen<T>
item
- entitypublic boolean hasUnsavedChanges()
hasUnsavedChanges
in interface ChangeTracker
protected OperationResult commitChanges()
public boolean isLocked()
isLocked
in interface EditorScreen<T>
protected void setEntityModified(boolean entityModified)
protected boolean isEntityModified()
protected boolean isReadOnlyDueToLock()
public boolean isReadOnly()
isReadOnly
in interface ReadOnlyAwareScreen
public void setReadOnly(boolean readOnly)
ReadOnlyAwareScreen
setReadOnly
in interface ReadOnlyAwareScreen
readOnly
- true
to enable the read-only mode, false
otherwiseprotected void disableCommitActions()
protected boolean isCrossFieldValidate()
protected void setCrossFieldValidate(boolean crossFieldValidate)
protected ValidationErrors validateScreen()
protected ValidationErrors validateUiComponents()
protected void validateAdditionalRules(ValidationErrors errors)
protected void commitAndClose(Action.ActionPerformedEvent event)
protected void commit(Action.ActionPerformedEvent event)
protected void showSaveNotification()
protected java.lang.String getSaveNotificationCaption()
protected void cancel(Action.ActionPerformedEvent event)
public OperationResult closeWithCommit()
EditorScreen.WINDOW_COMMIT_AND_CLOSE
action. May show validation errors or open an additional dialog before closing
the screen.public OperationResult closeWithDiscard()
FrameOwner.WINDOW_DISCARD_AND_CLOSE_ACTION
action.public boolean isShowSaveNotification()
public void setShowSaveNotification(boolean showSaveNotification)
showSaveNotification
- true
if a notification needs to be shown, false
otherwiseprotected io.jmix.core.common.event.Subscription addInitEntityListener(java.util.function.Consumer<StandardEditor.InitEntityEvent<T>> listener)
StandardEditor.InitEntityEvent
.listener
- listenerprotected io.jmix.core.common.event.Subscription addBeforeCommitChangesListener(java.util.function.Consumer<StandardEditor.BeforeCommitChangesEvent> listener)
StandardEditor.BeforeCommitChangesEvent
.listener
- listenerprotected io.jmix.core.common.event.Subscription addAfterCommitChangesListener(java.util.function.Consumer<StandardEditor.AfterCommitChangesEvent> listener)
StandardEditor.AfterCommitChangesEvent
.listener
- listenerprotected io.jmix.core.common.event.Subscription addValidationEventListener(java.util.function.Consumer<StandardEditor.ValidationEvent> listener)
StandardEditor.ValidationEvent
.listener
- listener