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
Nested ClassesModifier and TypeClassDescriptionstatic classEvent sent after commit of data context fromcommitEditorChanges()call.static classEvent sent before commit of data context fromcommitEditorChanges()call.static classEvent sent before the new entity instance is set to edited entity container.static classEvent 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.InitEventNested classes/interfaces inherited from interface io.jmix.ui.screen.LookupScreen
LookupScreen.ValidationContext<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanIndicates that a new instance of entity is being created.protected booleanIndicates whether the cross-field validation is enabled.protected booleanIndicates that the screen is in editing mode.protected booleanIndicates that edited entity is pessimistically locked.Fields inherited from class io.jmix.ui.screen.StandardLookup
selectHandler, selectValidatorFields inherited from interface io.jmix.ui.screen.FrameOwner
NO_OPTIONS, WINDOW_CLOSE_ACTION, WINDOW_COMMIT_AND_CLOSE_ACTION, WINDOW_DISCARD_AND_CLOSE_ACTIONFields 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SubscriptionAdds a listener toMasterDetailScreen.AfterCommitChangesEvent.protected SubscriptionAdds a listener toMasterDetailScreen.BeforeCommitChangesEvent.protected SubscriptionAdds a listener toMasterDetailScreen.InitEntityEvent.protected SubscriptionAdds a listener toMasterDetailScreen.ValidationEvent.protected OperationResultValidates editor form and commits data context.protected voidDisables edit controls.Method invoked when clicking the Cancel button, discards changes and disables controls for editing.protected voidenableEditControls(boolean creating) Enables controls for editing.protected ComponentContainerReturns the container with edit actions (save, cancel).protected CollectionContainer<T>Returns the table's data container.protected ComponentContainerReturns the right container with edit components.protected InstanceContainer<T>Returns the edit form's data container.protected Tprotected InstanceLoader<T>Returns the loader of the edit form's data container.Returns the entity meta-class.protected FormgetForm()Returns the field group.protected StringReturns the name of the pessimistic lock.protected ComponentContainerReturns the left container with browse components.protected ListComponent<T>getTable()protected TabSheetReturns the tab sheet with edit components.protected voidAdds a CreateAction that removes selection in table, sets a newly created item to editDs and enables controls for record editing.protected voidAdds an EditAction that enables controls for editing.protected voidAdds a listener that reloads the selected record and sets it to editCt.protected voidInitializes data components.protected voidinitEditComponents(boolean enabled) Initializes edit controls, depending on if they should be enabled or disabled.protected voidMethod invoked on the screen initialization.protected voidInitializes OK/Cancel editor buttons.protected voidAdds ESCAPE shortcut that invokes cancel() method.protected booleanprotected booleanisManagedAction(Action action) protected booleanprotected booleanlockIfNeeded(Object entity) Pessimistic lock before start of editing, if it is configured for the entity.protected voidLoads options of LookupFields if any.protected voidReleases pessimistic lock if the entity was locked.Method invoked when clicking on the Ok button after editing an existing or creating a new record.protected voidsetCrossFieldValidate(boolean crossFieldValidate) Sets whether the cross-field validation is active.protected voidValidates the cross-field rules if passed validation errors are empty.protected ValidationErrorsValidates screen data.protected ValidationErrorsValidates visible and enabled UI components.protected ValidationErrorsvalidateUiListComponents(ScreenValidation screenValidation) Methods inherited from class io.jmix.ui.screen.StandardLookup
addDefaultCancelAction, addDefaultSelectAction, cancel, getLookupActionsLayout, getLookupComponent, getSelectHandler, getSelectValidator, getWindowActionOptional, initActions, select, select, setLookupComponentMultiSelect, setSelectHandler, setSelectValidator, setupCommitShortcut, setupLookupComponentMethods 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, isScreenAction, 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
-
isManagedAction
-
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
Method invoked when clicking on the Ok button after editing an existing or creating a new record.- Returns:
- Result of the operation
-
commitEditorChanges
Validates editor form and commits data context.- Returns:
- operation result
-
discardChanges
Method invoked when clicking the Cancel button, discards changes and disables controls for editing.- Returns:
- Result of the operation
-
isCrossFieldValidate
protected boolean isCrossFieldValidate()- Returns:
trueif the cross-field validation is enabled,falseotherwise
-
setCrossFieldValidate
protected void setCrossFieldValidate(boolean crossFieldValidate) Sets whether the cross-field validation is active.trueby default.- Parameters:
crossFieldValidate-trueto enable the cross-field validation,falseotherwise
-
isUiListComponentsValidationEnabled
protected boolean isUiListComponentsValidationEnabled() -
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
-
validateUiListComponents
-
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
-