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.
  • Field Details

    • showSaveNotification

      protected boolean showSaveNotification
    • commitActionPerformed

      protected boolean commitActionPerformed
    • showEnableEditingBtn

      protected boolean showEnableEditingBtn
  • Constructor Details

    • StandardEditor

      protected StandardEditor()
  • Method Details

    • initActions

      protected void initActions(Screen.InitEvent event)
    • getWindowActionOptional

      protected Optional<Action> getWindowActionOptional(String id)
    • addDefaultCommitAndCloseAction

      protected Action addDefaultCommitAndCloseAction(Messages messages, Icons icons)
    • addDefaultCommitAction

      protected Action addDefaultCommitAction(Messages messages, Icons icons)
    • addDefaultCloseAction

      protected Action addDefaultCloseAction(Messages messages, Icons icons)
    • addDefaultEnableEditingAction

      protected Action addDefaultEnableEditingAction(Messages messages, Icons icons)
    • enableEditing

      protected void enableEditing(Action.ActionPerformedEvent actionPerformedEvent)
    • setupModifiedTracking

      protected void setupModifiedTracking()
    • onChangeEvent

      protected void onChangeEvent(DataContext.ChangeEvent event)
    • onPostCommitEvent

      protected void onPostCommitEvent(DataContext.PostCommitEvent event)
    • preventUnsavedChanges

      protected void preventUnsavedChanges(Screen.BeforeCloseEvent event)
    • 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

      protected InstanceLoader getEditedEntityLoader()
    • getEditedEntityContainer

      protected InstanceContainer<T> getEditedEntityContainer()
    • getEditedEntity

      public T getEditedEntity()
      Specified by:
      getEditedEntity in interface EditorScreen<T>
      Returns:
      currently edited entity instance
    • setEntityToEdit

      public void setEntityToEdit(T item)
      Description copied from interface: EditorScreen
      Sets entity instance to editor.
      Specified by:
      setEntityToEdit in interface EditorScreen<T>
      Parameters:
      item - entity
    • hasUnsavedChanges

      public boolean hasUnsavedChanges()
      Specified by:
      hasUnsavedChanges in interface ChangeTracker
      Returns:
      true if screen has unsaved changes
    • commitChanges

      protected OperationResult commitChanges()
      Validates screen and commits data context.
      Returns:
      operation result
    • isLocked

      public boolean isLocked()
      Specified by:
      isLocked in interface EditorScreen<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 interface ReadOnlyAwareScreen
      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 interface ReadOnlyAwareScreen
      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

      protected ValidationErrors validateScreen()
      Validates screen data. Default implementation validates visible and enabled UI components.
      Can be overridden in subclasses.
      Returns:
      validation errors
    • validateUiComponents

      protected ValidationErrors validateUiComponents()
      Validates visible and enabled UI components.
      Can be overridden in subclasses.
      Returns:
      validation errors
    • validateAdditionalRules

      protected void validateAdditionalRules(ValidationErrors errors)
    • commitAndClose

      protected void commitAndClose(Action.ActionPerformedEvent event)
    • commit

      protected void commit(Action.ActionPerformedEvent event)
    • showSaveNotification

      protected void showSaveNotification()
    • getSaveNotificationCaption

      protected String getSaveNotificationCaption()
    • cancel

      protected void cancel(Action.ActionPerformedEvent event)
    • closeWithCommit

      public OperationResult closeWithCommit()
      Tries to validate and commit data. If data committed successfully then closes the screen with EditorScreen.WINDOW_COMMIT_AND_CLOSE action. May show validation errors or open an additional dialog before closing the screen.
      Returns:
      result of close request
    • closeWithDiscard

      public OperationResult closeWithDiscard()
      Ignores the unsaved changes and closes the screen with FrameOwner.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

      protected Subscription addInitEntityListener(Consumer<StandardEditor.InitEntityEvent<T>> listener)
      Adds a listener to StandardEditor.InitEntityEvent.
      Parameters:
      listener - listener
      Returns:
      subscription
    • addBeforeCommitChangesListener

      protected Subscription addBeforeCommitChangesListener(Consumer<StandardEditor.BeforeCommitChangesEvent> listener)
      Parameters:
      listener - listener
      Returns:
      subscription
    • addAfterCommitChangesListener

      protected Subscription addAfterCommitChangesListener(Consumer<StandardEditor.AfterCommitChangesEvent> listener)
      Parameters:
      listener - listener
      Returns:
      subscription
    • addValidationEventListener

      protected Subscription addValidationEventListener(Consumer<StandardEditor.ValidationEvent> listener)
      Adds a listener to StandardEditor.ValidationEvent.
      Parameters:
      listener - listener
      Returns:
      subscription