- java.lang.Object
-
- org.tentackle.fx.rdc.Rdc
-
public class Rdc extends java.lang.ObjectCollected factory methods for FX-RDC-related stuff.
Enhances code readability.- Author:
- harald
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidbg(java.lang.Runnable runner)Runs some code in another thread.static <V> voidbg(java.util.function.Supplier<V> runner, java.util.function.Consumer<V> updateUI)Same asbg(Supplier, Consumer, Consumer)but with a predefined exception consumer.
The exception is shown as an error dialog.static <V> voidbg(java.util.function.Supplier<V> runner, java.util.function.Consumer<V> updateUI, java.util.function.Consumer<java.lang.RuntimeException> failedUI)Runs some code in another thread and optionally updates the UI.
The method is provided to hide the concrete implementation and make it replaceable.
Use this method whenever some lengthy operation (database I/O, for example) would otherwise block the event queue.static voidcloseStageHierarchy(javafx.scene.Node node)Closes the stage hierarchy of given node, except the main stage.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
GuiProvider<T>createGuiProvider(T pdo)Creates a service object that provides methods related to the rdc gui.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
PdoCrud<T>createPdoCrud(T pdo, boolean editable, boolean modal)Creates a CRUD controller for a pdo.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
PdoSearch<T>createPdoSearch(T pdo)Creates a search controller for a pdo.static <S,T extends org.tentackle.pdo.PersistentDomainObject<T>>
PdoTableCell<S,T>createTableCell(org.tentackle.fx.table.TableColumnConfiguration<S,T> columnConfig)Creates a table cell for a pdo type.static <S> TablePopup<S>createTablePopup(org.tentackle.fx.component.FxTableView<S> table, java.lang.String preferencesSuffix, java.lang.String title)Creates a table popup for a table view.static <S> TablePopup<S>createTablePopup(org.tentackle.fx.component.FxTreeTableView<S> treeTable, java.lang.String preferencesSuffix, java.lang.String title)Creates a table popup for a tree table view.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
javafx.scene.control.TreeCell<T>createTreeCell(javafx.scene.control.TreeView<T> treeView)Creates a tree cell for a pdo type.
Usage:static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
javafx.scene.control.TreeItem<T>createTreeItem(T pdo)Creates a tree item for a pdo.static <S,T extends org.tentackle.pdo.PersistentDomainObject<T>>
PdoTreeTableCell<S,T>createTreeTableCell(org.tentackle.fx.table.TableColumnConfiguration<S,T> columnConfig)Creates a tree table cell for a pdo type.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voiddisplayCrudStage(T pdo, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner, java.util.function.Consumer<T> updatedPdo)CRUD of a PDO in a separate window.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voiddisplayCrudStage(T pdo, boolean editable, javafx.stage.Window owner)CRUD of a PDO in a non-modal separate window.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voiddisplayCrudStage(T pdo, javafx.collections.ObservableList<T> pdoList, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner, java.util.function.Consumer<T> updatedPdo, java.util.function.Consumer<PdoCrud<T>> configurator)CRUD of a PDO in a separate window.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voiddisplaySearchStage(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner, boolean createPdoAllowed, java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems)Searches for PDOs in a separate window.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voiddisplaySearchStage(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner, boolean createPdoAllowed, java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems, java.util.function.Consumer<PdoSearch<T>> configurator)Searches for PDOs in a separate window.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voiddisplaySearchStage(T pdo, javafx.stage.Window owner, boolean createPdoAllowed)Searches for PDOs in a non-modal separate window.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
PdoCrud<T>getCrud(T pdo, javafx.collections.ObservableList<T> pdoList, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner)Gets a CRUD for a PDO.
If the PDO is already being edited the corresponding stage will be brought to front and null is returned.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
PdoSearch<T>getSearch(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner)Gets a search controller for a PDO.static voidshowSaveDiscardCancelDialog(java.util.function.Consumer<java.lang.Boolean> doIt)Shows a question dialog whether to save, discard or cancel editing of a PDO.static <T extends org.tentackle.pdo.PersistentDomainObject<T>>
voidshowTree(T pdo)Shows the tree of a PDO in a modal scene.
-
-
-
Method Detail
-
createPdoCrud
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoCrud<T> createPdoCrud(T pdo, boolean editable, boolean modal)
Creates a CRUD controller for a pdo.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdoeditable- true if user may edit the pdo, false if to view onlymodal- true if modal mode- Returns:
- the crud controller
-
createPdoSearch
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoSearch<T> createPdoSearch(T pdo)
Creates a search controller for a pdo.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdo- Returns:
- the search controller
-
createGuiProvider
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> GuiProvider<T> createGuiProvider(T pdo)
Creates a service object that provides methods related to the rdc gui.Throws a
PdoRuntimeExceptionif provider could not be created.- Type Parameters:
T- the PDO's class- Parameters:
pdo- the PDO- Returns:
- the GUI provider, never null
-
createTablePopup
public static <S> TablePopup<S> createTablePopup(org.tentackle.fx.component.FxTableView<S> table, java.lang.String preferencesSuffix, java.lang.String title)
Creates a table popup for a table view.- Type Parameters:
S- the row type- Parameters:
table- the tablepreferencesSuffix- the optional preferences suffix to load/save table preferencestitle- the optional title of the printed table- Returns:
- the popup
-
createTablePopup
public static <S> TablePopup<S> createTablePopup(org.tentackle.fx.component.FxTreeTableView<S> treeTable, java.lang.String preferencesSuffix, java.lang.String title)
Creates a table popup for a tree table view.- Type Parameters:
S- the row type- Parameters:
treeTable- the treetablepreferencesSuffix- the optional preferences suffix to load/save table preferencestitle- the optional title of the printed table- Returns:
- the popup
-
createTreeItem
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> javafx.scene.control.TreeItem<T> createTreeItem(T pdo)
Creates a tree item for a pdo.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdo- Returns:
- the tree item
-
createTreeCell
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> javafx.scene.control.TreeCell<T> createTreeCell(javafx.scene.control.TreeView<T> treeView)
Creates a tree cell for a pdo type.
Usage:treeView.setCellFactory(Rdc::createTreeCell);
- Type Parameters:
T- the pdo type- Parameters:
treeView- the treeview- Returns:
- the tree cell
-
createTableCell
public static <S,T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoTableCell<S,T> createTableCell(org.tentackle.fx.table.TableColumnConfiguration<S,T> columnConfig)
Creates a table cell for a pdo type. Usage:tableColumn.setCellFactory(Rdc::createTableCell);
- Type Parameters:
S- the table row's typeT- the table cell's pdo type- Parameters:
columnConfig- the table column configuration- Returns:
- the tree table cell
-
createTreeTableCell
public static <S,T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoTreeTableCell<S,T> createTreeTableCell(org.tentackle.fx.table.TableColumnConfiguration<S,T> columnConfig)
Creates a tree table cell for a pdo type. Usage:treeTableColumn.setCellFactory(Rdc::createTreeTableCell);
- Type Parameters:
S- the table row's typeT- the table cell's pdo type- Parameters:
columnConfig- the table column configuration- Returns:
- the tree table cell
-
displayCrudStage
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displayCrudStage(T pdo, boolean editable, javafx.stage.Window owner)CRUD of a PDO in a non-modal separate window.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdoeditable- true if user may edit the pdo, false if to view onlyowner- the owner, null if none
-
displayCrudStage
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displayCrudStage(T pdo, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner, java.util.function.Consumer<T> updatedPdo)CRUD of a PDO in a separate window.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdoeditable- true if user may edit the pdo, false if to view onlymodality- the modalityowner- the owner, null if noneupdatedPdo- the consumer for the possibly changed pdo if modal
-
displayCrudStage
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displayCrudStage(T pdo, javafx.collections.ObservableList<T> pdoList, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner, java.util.function.Consumer<T> updatedPdo, java.util.function.Consumer<PdoCrud<T>> configurator)CRUD of a PDO in a separate window.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdopdoList- the optional list of PDOs to navigate in the listeditable- true if user may edit the pdo, false if to view onlymodality- the modalityowner- the owner, null if noneupdatedPdo- the consumer for the possibly changed pdo if modalconfigurator- optional crud configurator
-
getCrud
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoCrud<T> getCrud(T pdo, javafx.collections.ObservableList<T> pdoList, boolean editable, javafx.stage.Modality modality, javafx.stage.Window owner)
Gets a CRUD for a PDO.
If the PDO is already being edited the corresponding stage will be brought to front and null is returned.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdopdoList- the optional list of PDOs to navigate in the listeditable- true if user may edit the pdo, false if to view onlymodality- the modalityowner- the owner, null if none- Returns:
- the CRUD, null if there is already a CRUD editing this PDO.
-
displaySearchStage
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displaySearchStage(T pdo, javafx.stage.Window owner, boolean createPdoAllowed)Searches for PDOs in a non-modal separate window.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdo as a templateowner- the owner, null if nonecreatePdoAllowed- true if allow to create a new PDO from within the search dialog
-
displaySearchStage
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displaySearchStage(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner, boolean createPdoAllowed, java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems)Searches for PDOs in a separate window.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdo as a templatemodality- the modalityowner- the owner, null if nonecreatePdoAllowed- true if allow to create a new PDO from within the search dialogselectedItems- the consumer for the selected PDOs if modal, null if not modal
-
displaySearchStage
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void displaySearchStage(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner, boolean createPdoAllowed, java.util.function.Consumer<javafx.collections.ObservableList<T>> selectedItems, java.util.function.Consumer<PdoSearch<T>> configurator)Searches for PDOs in a separate window.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdo as a templatemodality- the modalityowner- the owner, null if nonecreatePdoAllowed- true if allow to create a new PDO from within the search dialogselectedItems- the consumer for the selected PDOs if modal, null if not modalconfigurator- the optional configurator for the PdoSearch
-
getSearch
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> PdoSearch<T> getSearch(T pdo, javafx.stage.Modality modality, javafx.stage.Window owner)
Gets a search controller for a PDO.- Type Parameters:
T- the pdo type- Parameters:
pdo- the pdomodality- the modalityowner- the owner, null if none- Returns:
- the search controller, never null
-
showTree
public static <T extends org.tentackle.pdo.PersistentDomainObject<T>> void showTree(T pdo)
Shows the tree of a PDO in a modal scene.- Type Parameters:
T- the PDO type- Parameters:
pdo- the PDO
-
showSaveDiscardCancelDialog
public static void showSaveDiscardCancelDialog(java.util.function.Consumer<java.lang.Boolean> doIt)
Shows a question dialog whether to save, discard or cancel editing of a PDO.- Parameters:
doIt- consumer invoked with true to save, false to discard changes, null to cancel and do nothing
-
closeStageHierarchy
public static void closeStageHierarchy(javafx.scene.Node node)
Closes the stage hierarchy of given node, except the main stage.- Parameters:
node- the node
-
bg
public static <V> void bg(java.util.function.Supplier<V> runner, java.util.function.Consumer<V> updateUI, java.util.function.Consumer<java.lang.RuntimeException> failedUI)Runs some code in another thread and optionally updates the UI.
The method is provided to hide the concrete implementation and make it replaceable.
Use this method whenever some lengthy operation (database I/O, for example) would otherwise block the event queue.Example:
Rdc.bg(() -> { on(MyPdo.class).findWhateverItTakes()... ... return "Done"; }, s -> Fx.info(s));- Type Parameters:
V- the type returned by the runner- Parameters:
runner- the code running in another thread in parallel to the FX threadupdateUI- optional UI updater invoked from within the FX event queuefailedUI- optional UI updater invoked if execution failed- See Also:
RdcUtilities.runInBackground(Supplier, Consumer, Consumer)
-
bg
public static <V> void bg(java.util.function.Supplier<V> runner, java.util.function.Consumer<V> updateUI)Same asbg(Supplier, Consumer, Consumer)but with a predefined exception consumer.
The exception is shown as an error dialog.- Type Parameters:
V- the type returned by the runner- Parameters:
runner- the code running in another thread in parallel to the FX threadupdateUI- optional UI updater invoked from within the FX event queue
-
bg
public static void bg(java.lang.Runnable runner)
Runs some code in another thread.- Parameters:
runner- the code running in another thread in parallel to the FX thread- See Also:
bg(Supplier, Consumer)
-
-