public class AbstractEditor<T extends Entity> extends AbstractWindow implements Window.Editor<T>
Screen.AfterCloseEvent, Screen.AfterDetachEvent, Screen.AfterInitEvent, Screen.AfterShowEvent, Screen.BeforeCloseEvent, Screen.BeforeShowEvent, Screen.InitEventWindow.BeforeCloseEvent, Window.BeforeCloseWithCloseButtonEvent, Window.BeforeCloseWithShortcutEvent, Window.CloseListener, Window.CloseOrigin, Window.CloseWithCommitListener, Window.Committable, Window.ContentSwitchMode, Window.Editor<T extends Entity>, Window.HasFoldersPane, Window.HasUserIndicator, Window.HasWorkArea, Window.Lookup<T extends Entity>, Window.TopLevelWindow, Window.WrapperFrame.MessageMode, Frame.MessageType, Frame.NotificationTypeExpandingLayout.ExpandDirectionComponent.Alignment, Component.BelongToFrame, Component.Disposable, Component.Editable, Component.Focusable, Component.HasCaption, Component.HasDescription, Component.HasIcon, Component.HasXmlDescriptor, Component.OptionsStyleProvider| Modifier and Type | Field and Description |
|---|---|
protected boolean |
commitActionPerformed |
protected boolean |
crossFieldValidate |
protected boolean |
justLocked |
protected boolean |
readOnly |
protected boolean |
showSaveNotification |
frame, messages, UNKNOWN_CLOSE_ACTION_IDNAMEBROWSE_WINDOW_SUFFIX, CLOSE_ACTION_ID, COMMIT_ACTION_ID, CREATE_WINDOW_SUFFIX, EDITOR_WINDOW_SUFFIX, LOOKUP_WINDOW_SUFFIX, SELECT_ACTION_IDAUTO_SIZE, AUTO_SIZE_PX, FULL_SIZE, UNITS_PERCENTAGE, UNITS_PIXELSWINDOW_CLOSE, WINDOW_COMMIT, WINDOW_COMMIT_AND_CLOSENO_OPTIONS, WINDOW_CLOSE_ACTION, WINDOW_COMMIT_AND_CLOSE_ACTION, WINDOW_DISCARD_AND_CLOSE_ACTION| Constructor and Description |
|---|
AbstractEditor() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
afterWindowApplyPostInit()
Called after "postInit" in "Apply" action processing.
|
OperationResult |
closeWithCommit()
Tries to validate and commit data.
|
boolean |
commit()
Called by the framework to validate and commit changes.
|
boolean |
commit(boolean validate)
Commit changes with optional validation.
|
void |
commitAndClose()
Validate, commit and close the window if commit was successful.
|
protected boolean |
commitInternal(boolean close) |
protected Datasource |
getDatasourceInternal() |
T |
getEditedEntity() |
T |
getItem() |
protected MetaClass |
getMetaClassForLocking(Datasource ds) |
Datasource |
getParentDs() |
protected void |
handlePreviouslyDeletedCompositionItems(Entity entity,
DatasourceImplementation parentDs)
This method is required for multi-level composition, when a user deletes records from nested editors, saves them
and then reopens.
|
boolean |
hasUnsavedChanges() |
protected void |
initCommitActions(Screen.InitEvent event) |
protected void |
initNewItem(T item)
Hook to be implemented in subclasses.
|
boolean |
isCrossFieldValidate() |
boolean |
isLocked() |
boolean |
isModified() |
boolean |
isShowSaveNotification() |
protected boolean |
postCommit(boolean committed,
boolean close)
Hook to be implemented in subclasses.
|
protected void |
postInit()
Hook to be implemented in subclasses.
|
protected boolean |
preCommit()
Hook to be implemented in subclasses.
|
void |
releaseLock() |
void |
setCrossFieldValidate(boolean crossFieldValidate)
Enable/disable cross field validation on
Window.validateAll() call. |
void |
setEntityToEdit(T entity)
Sets entity instance to editor.
|
void |
setItem(Entity item)
Called by the framework to set an edited entity after creation of all components and datasources, and after
AbstractWindow.init(java.util.Map). |
protected void |
setItemInternal(Entity item) |
void |
setParentDs(Datasource parentDs)
This method is called by the framework to set parent datasource to commit into this datasource instead
of directly to the database.
|
void |
setShowSaveNotification(boolean showSaveNotification) |
void |
validateAdditionalRules(ValidationErrors errors) |
add, add, addAction, addAction, addBeforeWindowCloseListener, addFacet, addStyleName, addTimer, afterShow, applySettings, beforeClose, closeWithDiscard, deleteSettings, expand, expand, formatMessage, getAction, getActions, getActionsPermissions, getAlignment, getCaption, getCompanion, getComponent, getComponent, getComponent, getComponents, getComposition, getContentSwitchMode, getContext, getDescription, getDialogOptions, getDsContext, getExpandDirection, getExpandRatio, getFacet, getFacets, getFocusComponent, getFrame, getFrameOwner, getHeight, getHeightSizeUnit, getIcon, getMargin, getMaxHeight, getMaxWidth, getMessage, getMessagesPack, getMinHeight, getMinWidth, getOwnComponent, getOwnComponents, getOwnComponentsStream, getParent, getScreenHashCode, getSettings, getSpacing, getStyleName, getTimer, getWidth, getWidthSizeUnit, getWindowManager, getWrappedFrame, getWrappedWindow, getXmlDescriptor, handleValidationErrors, indexOf, init, init, isAttributeAccessControlEnabled, isCloseable, isEnabled, isEnabledRecursive, isExpanded, isResponsive, isSameScreen, isValid, isVisible, isVisibleRecursive, postValidate, preClose, ready, remove, removeAction, removeAction, removeAll, removeAllActions, removeBeforeWindowCloseListener, removeFacet, removeStyleName, resetExpanded, saveSettings, setAlignment, setCaption, setCloseable, setCompanion, setContentSwitchMode, setDescription, setDsContext, setEnabled, setExpandRatio, setFocusComponent, setFrame, setHeight, setIcon, setIconFromSet, setId, setMargin, setMaxHeight, setMaxWidth, setMessagesPack, setMinHeight, setMinWidth, setParent, setResponsive, setSpacing, setStyleName, setVisible, setWidth, setWindow, setXmlDescriptor, showValidationErrors, unwrap, unwrapComposition, validate, validate, validateAlladdAfterCloseListener, addAfterDetachListener, addAfterInitListener, addAfterShowListener, addBeforeCloseListener, addBeforeShowListener, addInitListener, addUrlParamsChangeListener, applyDataLoadingSettings, close, closeWithDefaultAction, fireEvent, getBeanLocator, getEventHub, getExtensions, getId, getScreenData, getUiEventListeners, getWindow, isMultipleOpen, isSaveScreenHistoryOnClose, isSaveSettingsOnClose, setBeanLocator, setExtensions, setScreenData, setUiEventListeners, showclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddBeforeCloseWithCloseButtonListener, addBeforeCloseWithShortcutListener, addBeforeWindowCloseListener, addCloseListener, addCloseWithCommitListener, addListener, addTimer, applySettings, close, close, closeAndRun, deleteSettings, getContext, getDialogOptions, getFocusComponent, getFrameOwner, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getSettings, getTimer, getWindowManager, isCloseable, removeBeforeCloseWithCloseButtonListener, removeBeforeCloseWithShortcutListener, removeBeforeWindowCloseListener, removeCloseListener, removeCloseWithCommitListener, removeListener, saveSettings, setCloseable, setFocusComponent, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, validate, validateAlladdFacet, getFacet, getFacetNN, getFacets, isValid, removeFacet, validateexpand, expand, getExpandDirection, isExpanded, resetExpandedadd, getComponent, getComponentNN, indexOfadd, add, focusFirstComponent, getComponent, getComponentNN, getComponents, getOwnComponent, getOwnComponents, getOwnComponentsStream, remove, remove, removeAlladdStyleName, getAlignment, getHeight, getHeightSizeUnit, getHeightUnits, getId, getParent, getStyleName, getWidth, getWidthSizeUnit, getWidthUnits, isEnabled, isEnabledItself, isEnabledRecursive, isResponsive, isVisible, isVisibleItself, isVisibleRecursive, removeStyleName, requestFocus, setAlignment, setEnabled, setHeight, setHeightAuto, setHeightFull, setId, setParent, setResponsive, setSizeAuto, setSizeFull, setStyleName, setVisible, setWidth, setWidthAuto, setWidthFull, unwrap, unwrapCompositiongetFrame, setFramegetSpacing, setSpacinggetMargin, setMargin, setMargin, setMarginaddAction, addAction, getAction, getActionNN, getActions, getSubPart, removeAction, removeAction, removeAllActionsgetIcon, setIcon, setIconFromSetgetCaption, setCaptiongetDescription, setDescriptionopenEditor, openEditor, openEditor, openEditor, openEditor, openEditor, openEditor, openFrame, openFrame, openLookup, openLookup, openLookup, openLookup, openWindow, openWindow, showMessageDialog, showNotification, showNotification, showNotification, showOptionDialog, showOptionDialog, showWebPagegetExpandRatio, setExpandRatiogetCompanion, getContext, getDsContext, getMessagesPack, getXmlDescriptor, isValid, setDsContext, setMessagesPack, setXmlDescriptor, validate, validate, validateAllgetComponent, getCompositiongetWrappedFrameprotected boolean showSaveNotification
protected boolean readOnly
protected boolean justLocked
protected boolean crossFieldValidate
protected boolean commitActionPerformed
protected void initCommitActions(Screen.InitEvent event)
public T getItem()
getItem in interface Window.Editor<T extends Entity>@Nullable public Datasource getParentDs()
getParentDs in interface Window.Editor<T extends Entity>public void setItem(Entity item)
AbstractWindow.init(java.util.Map).
Don't override this method in subclasses, use hooks initNewItem(com.haulmont.cuba.core.entity.Entity)
and postInit() instead.
setItem in interface Window.Editor<T extends Entity>item - entity instanceprotected Datasource getDatasourceInternal()
protected void setItemInternal(Entity item)
public void releaseLock()
protected void handlePreviouslyDeletedCompositionItems(Entity entity, DatasourceImplementation parentDs)
public void setParentDs(Datasource parentDs)
Window.EditorsetParentDs in interface Window.Editor<T extends Entity>protected MetaClass getMetaClassForLocking(Datasource ds)
public boolean isModified()
isModified in interface Window.Committablepublic boolean commit()
Don't override this method in subclasses, use hooks AbstractWindow.postValidate(ValidationErrors), preCommit()
and postCommit(boolean, boolean) instead.
commit in interface Window.Editor<T extends Entity>public boolean commit(boolean validate)
Don't override this method in subclasses, use hooks AbstractWindow.postValidate(ValidationErrors), preCommit()
and postCommit(boolean, boolean) instead.
commit in interface Window.Editor<T extends Entity>validate - false to avoid validationprotected boolean commitInternal(boolean close)
public void validateAdditionalRules(ValidationErrors errors)
validateAdditionalRules in class AbstractWindowpublic OperationResult closeWithCommit()
EditorScreen.WINDOW_COMMIT_AND_CLOSE action. May show validation errors or open an additional dialog before closing
the screen.public void commitAndClose()
Window.COMMIT_ACTION_ID to associated CloseListeners
Don't override this method in subclasses, use hooks AbstractWindow.postValidate(ValidationErrors), preCommit()
and postCommit(boolean, boolean) instead.
commitAndClose in interface Window.Committablepublic void setEntityToEdit(T entity)
EditorScreensetEntityToEdit in interface EditorScreen<T extends Entity>entity - entitypublic T getEditedEntity()
getEditedEntity in interface EditorScreen<T extends Entity>public boolean hasUnsavedChanges()
hasUnsavedChanges in interface ChangeTrackerhasUnsavedChanges in class AbstractWindowpublic boolean isLocked()
isLocked in interface EditorScreen<T extends Entity>public boolean isCrossFieldValidate()
isCrossFieldValidate in interface Window.Editor<T extends Entity>Window.validateAll()
call using BeanValidation.BeanValidationpublic void setCrossFieldValidate(boolean crossFieldValidate)
Window.EditorWindow.validateAll() call. UiCrossFieldChecks group only
(without Default group) when there are no other validation errors in UI components.
Cross field validation is triggered before AbstractWindow.postValidate(com.haulmont.cuba.gui.components.ValidationErrors) hook.
setCrossFieldValidate in interface Window.Editor<T extends Entity>crossFieldValidate - cross field validate flagBeanValidationprotected void initNewItem(T item)
setItem(com.haulmont.cuba.core.entity.Entity) when
the editor is opened for a new entity instance. Allows to additionally initialize the new entity instance
before setting it into the datasource.item - entity instanceprotected void postInit()
setItem(com.haulmont.cuba.core.entity.Entity).
At the moment of calling the main datasource is initialized and getItem() returns reloaded entity instance.
postCommit(boolean, boolean) if the window is not closed after
commit. Then getItem() contains instance, returned from DataService.commit().
This is useful for initialization of components that have to show fresh information from the current instance.
protected void postInit() {
if (!PersistenceHelper.isNew(getItem())) {
diffFrame.loadVersions(getItem());
entityLogDs.refresh();
}
}
protected boolean preCommit()
protected boolean postCommit(boolean committed,
boolean close)
postInit() if the window is not closing.committed - whether any data were actually changed and committedclose - whether the window is going to be closedprotected void afterWindowApplyPostInit()
public boolean isShowSaveNotification()
public void setShowSaveNotification(boolean showSaveNotification)