Class MasterDetailScreen<T>

All Implemented Interfaces:
FrameOwner, LookupScreen<T>, MultiSelectLookupScreen

@ParametersAreNonnullByDefault public abstract class MasterDetailScreen<T> extends StandardLookup<T>
Displays a list of entities on the left and details of the currently selected instance on the right.
  • Field Details

    • editing

      protected boolean editing
      Indicates that the screen is in editing mode.
    • creating

      protected boolean creating
      Indicates that a new instance of entity is being created.
    • justLocked

      protected boolean justLocked
      Indicates that edited entity is pessimistically locked.
    • crossFieldValidate

      protected boolean crossFieldValidate
      Indicates whether the cross-field validation is enabled.
  • Constructor Details

    • MasterDetailScreen

      public MasterDetailScreen()
  • Method Details

    • getLookupBox

      protected ComponentContainer getLookupBox()
      Returns the left container with browse components. Override if the container id differs from "lookupBox".
    • getTable

      protected ListComponent<T> getTable()
      Returns the browse Table or DataGrid. Override the method if the table id differs from "table".
    • getEditBox

      protected ComponentContainer getEditBox()
      Returns the right container with edit components. Override if the container id differs from "editBox".
    • getTabSheet

      @Nullable protected TabSheet getTabSheet()
      Returns the tab sheet with edit components. Can be null if the screen contains a field group only. Override if the tab sheet id differs from "tabSheet".
    • getForm

      protected Form getForm()
      Returns the field group. Override if the field group id differs from "fieldGroup".
    • getActionsPane

      protected ComponentContainer getActionsPane()
      Returns the container with edit actions (save, cancel). Override if the container id differs from "actionsPane".
    • getBrowseContainer

      protected CollectionContainer<T> getBrowseContainer()
      Returns the table's data container.
    • getEditContainer

      protected InstanceContainer<T> getEditContainer()
      Returns the edit form's data container.
    • getEditedEntity

      protected T getEditedEntity()
      Returns:
      currently edited entity instance loaded to editor form
    • getEditLoader

      protected InstanceLoader<T> getEditLoader()
      Returns the loader of the edit form's data container.
    • getEntityClass

      protected Class<T> getEntityClass()
      Returns the entity meta-class.
    • initMasterDetailScreen

      protected void initMasterDetailScreen(Screen.InitEvent event)
      Method invoked on the screen initialization.
    • initDataComponents

      protected void initDataComponents()
      Initializes data components.

      Default implementation unlinks browse loader from DataContext to prevent from the edited entity being referenced from both edit and browse data containers. Keep in mind that as a result, entities loaded in the browse table are not tracked.

    • initOkCancelActions

      protected void initOkCancelActions()
      Initializes OK/Cancel editor buttons.
    • initBrowseItemChangeListener

      protected void initBrowseItemChangeListener()
      Adds a listener that reloads the selected record and sets it to editCt.
    • initBrowseCreateAction

      protected void initBrowseCreateAction()
      Adds a CreateAction that removes selection in table, sets a newly created item to editDs and enables controls for record editing.
    • initBrowseEditAction

      protected void initBrowseEditAction()
      Adds an EditAction that enables controls for editing.
    • initShortcuts

      protected void initShortcuts()
      Adds ESCAPE shortcut that invokes cancel() method.
    • refreshOptionsForLookupFields

      protected void refreshOptionsForLookupFields()
      Loads options of LookupFields if any.
    • enableEditControls

      protected void enableEditControls(boolean creating)
      Enables controls for editing.
      Parameters:
      creating - indicates that a new instance is being created
    • disableEditControls

      protected void disableEditControls()
      Disables edit controls.
    • initEditComponents

      protected void initEditComponents(boolean enabled)
      Initializes edit controls, depending on if they should be enabled or disabled.
      Parameters:
      enabled - if true - enables edit controls and disables controls on the left side of the splitter if false - vice versa
    • lockIfNeeded

      protected boolean lockIfNeeded(Object entity)
      Pessimistic lock before start of editing, if it is configured for the entity.
    • releaseLock

      protected void releaseLock()
      Releases pessimistic lock if the entity was locked.
    • getLockName

      protected String getLockName()
      Returns the name of the pessimistic lock.
    • saveChanges

      protected void saveChanges()
      Method invoked when clicking on the Ok button after editing an existing or creating a new record.
    • commitEditorChanges

      protected OperationResult commitEditorChanges()
      Validates editor form and commits data context.
      Returns:
      operation result
    • discardChanges

      protected void discardChanges()
      Method invoked when clicking the Cancel button, discards changes and disables controls for editing.
    • isCrossFieldValidate

      protected boolean isCrossFieldValidate()
      Returns:
      true if the cross-field validation is enabled, false otherwise
    • setCrossFieldValidate

      protected void setCrossFieldValidate(boolean crossFieldValidate)
      Sets whether the cross-field validation is active. true by default.
      Parameters:
      crossFieldValidate - true to enable the cross-field validation, false otherwise
    • isUiListComponentsValidationEnabled

      protected boolean isUiListComponentsValidationEnabled()
    • validateEditorForm

      protected ValidationErrors validateEditorForm()
      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
    • validateUiListComponents

      protected ValidationErrors validateUiListComponents(ScreenValidation screenValidation)
    • validateAdditionalRules

      protected void validateAdditionalRules(ValidationErrors errors)
      Validates the cross-field rules if passed validation errors are empty.
      Parameters:
      errors - errors found during components validation
    • addInitEntityListener

      protected Subscription addInitEntityListener(Consumer<MasterDetailScreen.InitEntityEvent<T>> listener)
      Parameters:
      listener - listener
      Returns:
      subscription
    • addBeforeCommitChangesListener

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

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

      protected Subscription addValidationEventListener(Consumer<MasterDetailScreen.ValidationEvent> listener)
      Parameters:
      listener - listener
      Returns:
      subscription