Class PdoCrud<T extends PersistentDomainObject<T>>
java.lang.Object
org.tentackle.fx.AbstractFxController
org.tentackle.fx.rdc.crud.PdoCrud<T>
- Type Parameters:
T- the PDO type
- All Implemented Interfaces:
FxController, PdoController<T>, PdoProvider<T>, ScopeConfigurator
@FxControllerService(binding=NO)
public class PdoCrud<T extends PersistentDomainObject<T>>
extends AbstractFxController
implements PdoController<T>
CRUD controller for PDOs.
Wraps a
Wraps a
PdoEditor with a toolbar to navigate through a list of PDOs, show the PDO's tree,
search, create (or copy, with the shift key held down), save, delete and print a PDO, edit its security
rules, and close the dialog.
An existing PDO is token-locked while it is being edited, if the entity provides a token lock.
Every persistence operation fires a PdoEvent to the handlers and filters registered
via addPdoEventHandler(EventType, EventHandler) and addPdoEventFilter(EventType, EventHandler).
- Author:
- harald
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPdoEventFilter(javafx.event.EventType<PdoEvent> eventType, javafx.event.EventHandler<PdoEvent> eventFilter) Adds a PDO event filter.voidaddPdoEventHandler(javafx.event.EventType<PdoEvent> eventType, javafx.event.EventHandler<PdoEvent> eventHandler) Adds a PDO event handler.voidcancel()Closes this CRUD.
Asks the user to save or discard pending changes before.protected booleanCloses the stage if modal.voidConfigures the controller as the final step in initialization.voiddelete()Deletes the current PDO.voidfind()Searches for a PDO in a modal search dialog and edits the selected one.Gets the HBox containing all buttons.Gets the PDO editor.getPdo()Gets the PDO.Gets the list of PDOs to walk through.booleanGets whether the user can change the editor's contents.booleanReturns whether the PDO is being edited effectively.booleanisModal()Returns whether the CRUD should be treated as modal.voidnewPdo()Discards the current PDO and edits a new one.
If the shift key is held down, the new PDO is a deep copy of the current one.voidnext()Navigates to the next PDO in the list.voidprevious()Navigates to the previous PDO in the list.voidprint()Prints the PDO.
Delegates toPdoEditor.print().voidreleasePdo(Consumer<Boolean> released) Releases the current PDO.
If the PDO has been modified, the user is asked to save, discard, or cancel.voidreleaseTokenLock(T pdo) Unlocks the given PDO.voidRemoves all PDO event handlers and filters.
The method is provided to avoid memory leaks.voidremovePdoEventFilter(javafx.event.EventType<PdoEvent> eventType, javafx.event.EventHandler<PdoEvent> eventFilter) Removes a PDO event filter.voidremovePdoEventHandler(javafx.event.EventType<PdoEvent> eventType, javafx.event.EventHandler<PdoEvent> eventHandler) Removes a PDO event handler.booleansave()Saves the current PDO.
The PDO is not saved if the form is invalid, if a PDO with the same unique domain key already exists, or if another user modified it meanwhile.voidsecurity()Shows the security dialog.voidsetEditable(boolean editable) Sets whether the user can change the editor's contents.voidsetEditing(boolean editing) Sets whether the PDO is being edited effectively.voidSets the PDO editor.voidsetModal(boolean modal) Sets whether the CRUD should be treated as modal.
Modality cannot be retrieved from the stage because there may be no stage yet.voidSets the PDO to edit.
Requests the token lock if the PDO is editable and the entity provides a token lock.voidsetPdoList(javafx.collections.ObservableList<T> pdoList) Sets a list of PDOs to walk through via the previous and next buttons.
List navigation hides the find, new and delete buttons.protected voidShows the validation errors.voidtree()Shows the tree of the current PDO in a modal stage.protected voidUpdates the visibility and disabled state of the buttons.protected voidEnables or disables the previous and next buttons.voidUpdates the window title if attached to its own stage.Methods inherited from class AbstractFxController
createBinder, getBinder, getContainer, getDefaultScopes, getFXMLFields, getFXMLMethods, getStage, getView, setView, validateInjectionsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface FxController
getBinder, getContainer, getFXMLFields, getFXMLMethods, getStage, getView, setView, validateInjectionsMethods inherited from interface PdoProvider
on, on
-
Constructor Details
-
PdoCrud
public PdoCrud()Creates a CRUD controller.
-
-
Method Details
-
setEditable
public void setEditable(boolean editable) Sets whether the user can change the editor's contents.- Parameters:
editable- true if editable
-
isEditable
public boolean isEditable()Gets whether the user can change the editor's contents.- Returns:
- true if editable
-
isEditing
public boolean isEditing()Returns whether the PDO is being edited effectively.- Returns:
- true if isEditable() and editing is allowed according to the security rules
-
setEditing
public void setEditing(boolean editing) Sets whether the PDO is being edited effectively.- Parameters:
editing- true if editing, else false
-
isModal
public boolean isModal()Returns whether the CRUD should be treated as modal.- Returns:
- true if modal
-
setModal
public void setModal(boolean modal) Sets whether the CRUD should be treated as modal.
Modality cannot be retrieved from the stage because there may be no stage yet. A modal CRUD hides the find, new and delete buttons, and closes after save or delete.- Parameters:
modal- true if modal
-
setPdoList
Sets a list of PDOs to walk through via the previous and next buttons.
List navigation hides the find, new and delete buttons.- Parameters:
pdoList- the PDOs, null to disable list navigation
-
getPdoList
-
setEditor
-
getEditor
-
setPdo
Sets the PDO to edit.
Requests the token lock if the PDO is editable and the entity provides a token lock. If the lock is held by another user, the editor switches to view-only and informs the user.- Specified by:
setPdoin interfacePdoController<T extends PersistentDomainObject<T>>- Parameters:
pdo- the PDO
-
getPdo
Gets the PDO.- Specified by:
getPdoin interfacePdoProvider<T extends PersistentDomainObject<T>>- Returns:
- the PDO
-
updateTitle
public void updateTitle()Updates the window title if attached to its own stage. -
configure
public void configure()Description copied from interface:FxControllerConfigures the controller as the final step in initialization.- Specified by:
configurein interfaceFxController- Overrides:
configurein classAbstractFxController
-
tree
public void tree()Shows the tree of the current PDO in a modal stage. -
previous
public void previous()Navigates to the previous PDO in the list. -
next
public void next()Navigates to the next PDO in the list. -
security
public void security()Shows the security dialog. -
newPdo
public void newPdo()Discards the current PDO and edits a new one.
If the shift key is held down, the new PDO is a deep copy of the current one. -
save
public boolean save()Saves the current PDO.
The PDO is not saved if the form is invalid, if a PDO with the same unique domain key already exists, or if another user modified it meanwhile. The user is informed in all those cases and the editor keeps the pending changes, which is why callers that go on to discard the editor's contents must check the result.- Returns:
- true if the PDO has been saved, false if it has not
-
delete
public void delete()Deletes the current PDO. -
cancel
public void cancel()Closes this CRUD.
Asks the user to save or discard pending changes before. -
find
public void find()Searches for a PDO in a modal search dialog and edits the selected one. -
releasePdo
-
releaseTokenLock
-
print
public void print()Prints the PDO.
Delegates toPdoEditor.print(). -
getButtonBox
-
removeAllPdoEventListeners
public void removeAllPdoEventListeners()Removes all PDO event handlers and filters.
The method is provided to avoid memory leaks. -
addPdoEventFilter
-
removePdoEventFilter
-
addPdoEventHandler
-
removePdoEventHandler
-
updateButtons
protected void updateButtons()Updates the visibility and disabled state of the buttons. -
updatePrevNextButtons
protected void updatePrevNextButtons()Enables or disables the previous and next buttons. -
closeIfModal
protected boolean closeIfModal()Closes the stage if modal.- Returns:
- true if closed
-
showValidationResults
Shows the validation errors.- Parameters:
ex- the validation exception
-