Package io.jmix.ui.screen
Class MasterDetailScreen<T>
java.lang.Object
io.jmix.ui.screen.Screen
io.jmix.ui.screen.StandardLookup<T>
io.jmix.ui.screen.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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Event sent after commit of data context fromcommitEditorChanges()
call.static class
Event sent before commit of data context fromcommitEditorChanges()
call.static class
Event sent before the new entity instance is set to edited entity container.static class
Event 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
Nested classes/interfaces inherited from interface io.jmix.ui.screen.LookupScreen
LookupScreen.ValidationContext<T>
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
Indicates that a new instance of entity is being created.protected boolean
Indicates whether the cross-field validation is enabled.protected boolean
Indicates that the screen is in editing mode.protected boolean
Indicates that edited entity is pessimistically locked.Fields inherited from class io.jmix.ui.screen.StandardLookup
selectHandler, selectValidator
Fields inherited from interface io.jmix.ui.screen.FrameOwner
NO_OPTIONS, WINDOW_CLOSE_ACTION, WINDOW_COMMIT_AND_CLOSE_ACTION, WINDOW_DISCARD_AND_CLOSE_ACTION
Fields inherited from interface io.jmix.ui.screen.LookupScreen
LOOKUP_CANCEL_ACTION_ID, LOOKUP_ENTER_PRESSED_ACTION_ID, LOOKUP_ITEM_CLICK_ACTION_ID, LOOKUP_SELECT_ACTION_ID, LOOKUP_SELECT_CLOSE_ACTION
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Subscription
Adds a listener toMasterDetailScreen.AfterCommitChangesEvent
.protected Subscription
Adds a listener toMasterDetailScreen.BeforeCommitChangesEvent
.protected Subscription
Adds a listener toMasterDetailScreen.InitEntityEvent
.protected Subscription
Adds a listener toMasterDetailScreen.ValidationEvent
.protected OperationResult
Validates editor form and commits data context.protected void
Disables edit controls.protected void
Method invoked when clicking the Cancel button, discards changes and disables controls for editing.protected void
enableEditControls
(boolean creating) Enables controls for editing.protected ComponentContainer
Returns the container with edit actions (save, cancel).protected CollectionContainer<T>
Returns the table's data container.protected ComponentContainer
Returns the right container with edit components.protected InstanceContainer<T>
Returns the edit form's data container.protected T
protected InstanceLoader<T>
Returns the loader of the edit form's data container.Returns the entity meta-class.protected Form
getForm()
Returns the field group.protected String
Returns the name of the pessimistic lock.protected ComponentContainer
Returns the left container with browse components.protected ListComponent<T>
getTable()
protected TabSheet
Returns the tab sheet with edit components.protected void
Adds a CreateAction that removes selection in table, sets a newly created item to editDs and enables controls for record editing.protected void
Adds an EditAction that enables controls for editing.protected void
Adds a listener that reloads the selected record and sets it to editCt.protected void
Initializes data components.protected void
initEditComponents
(boolean enabled) Initializes edit controls, depending on if they should be enabled or disabled.protected void
Method invoked on the screen initialization.protected void
Initializes OK/Cancel editor buttons.protected void
Adds ESCAPE shortcut that invokes cancel() method.protected boolean
protected boolean
lockIfNeeded
(Object entity) Pessimistic lock before start of editing, if it is configured for the entity.protected void
Loads options of LookupFields if any.protected void
Releases pessimistic lock if the entity was locked.protected void
Method invoked when clicking on the Ok button after editing an existing or creating a new record.protected void
setCrossFieldValidate
(boolean crossFieldValidate) Sets whether the cross-field validation is active.protected void
Validates the cross-field rules if passed validation errors are empty.protected ValidationErrors
Validates screen data.protected ValidationErrors
Validates visible and enabled UI components.Methods inherited from class io.jmix.ui.screen.StandardLookup
addDefaultCancelAction, addDefaultSelectAction, cancel, getLookupActionsLayout, getLookupComponent, getSelectHandler, getSelectValidator, getWindowActionOptional, initActions, select, select, setLookupComponentMultiSelect, setSelectHandler, setSelectValidator, setupCommitShortcut, setupLookupComponent
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, setApplicationContext, setExtensions, setId, setScreenData, setUiEventListeners, setWindow, show
-
Field Details
-
editing
protected boolean editingIndicates that the screen is in editing mode. -
creating
protected boolean creatingIndicates that a new instance of entity is being created. -
justLocked
protected boolean justLockedIndicates that edited entity is pessimistically locked. -
crossFieldValidate
protected boolean crossFieldValidateIndicates whether the cross-field validation is enabled.
-
-
Constructor Details
-
MasterDetailScreen
public MasterDetailScreen()
-
-
Method Details
-
getLookupBox
Returns the left container with browse components. Override if the container id differs from "lookupBox". -
getTable
-
getEditBox
Returns the right container with edit components. Override if the container id differs from "editBox". -
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
Returns the field group. Override if the field group id differs from "fieldGroup". -
getActionsPane
Returns the container with edit actions (save, cancel). Override if the container id differs from "actionsPane". -
getBrowseContainer
Returns the table's data container. -
getEditContainer
Returns the edit form's data container. -
getEditedEntity
- Returns:
- currently edited entity instance loaded to editor form
-
getEditLoader
Returns the loader of the edit form's data container. -
getEntityClass
Returns the entity meta-class. -
initMasterDetailScreen
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
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
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
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
-
validateEditorForm
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
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) Adds a listener toMasterDetailScreen.InitEntityEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-
addBeforeCommitChangesListener
protected Subscription addBeforeCommitChangesListener(Consumer<MasterDetailScreen.BeforeCommitChangesEvent> listener) Adds a listener toMasterDetailScreen.BeforeCommitChangesEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-
addAfterCommitChangesListener
protected Subscription addAfterCommitChangesListener(Consumer<MasterDetailScreen.AfterCommitChangesEvent> listener) Adds a listener toMasterDetailScreen.AfterCommitChangesEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-
addValidationEventListener
protected Subscription addValidationEventListener(Consumer<MasterDetailScreen.ValidationEvent> listener) Adds a listener toMasterDetailScreen.ValidationEvent
.- Parameters:
listener
- listener- Returns:
- subscription
-