Class AbstractMFXMasterController<T extends Modifiable>
java.lang.Object
cz.masci.commons.springfx.controller.AbstractMFXMasterController<T>
- Type Parameters:
T- Item type
@FxmlView("fxml/mfx-master-view.fxml")
public abstract class AbstractMFXMasterController<T extends Modifiable>
extends Object
Abstract controller for master-detail view.
Displays table view with items loaded by the item service.
Displays three buttons for actions:
Displays table view with items loaded by the item service.
Displays three buttons for actions:
- new item
- save all
- delete
Annotate subclass with FxmlController to let loader set the right controller class.
- Author:
- Daniel Masek
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected javafx.scene.layout.BorderPaneprotected javafx.scene.layout.VBoxprotected io.github.palexdev.materialfx.controls.MFXTableView<T> -
Constructor Summary
ConstructorsConstructorDescriptionAbstractMFXMasterController(net.rgielen.fxweaver.core.FxWeaver fxWeaver, CrudService<T> itemService, Class<? extends EditDialogControllerService<T>> editControllerClass) -
Method Summary
Modifier and TypeMethodDescriptionfinal voidaddColumns(io.github.palexdev.materialfx.controls.MFXTableColumn<T>... columns) Add table view columns.protected abstract voidinit()Delegate titles and columns initialization to subclass.final voidInitialize FX controller.voidonDelete(javafx.event.ActionEvent event) Open alert dialog and delete selected item.voidonNewItem(javafx.event.ActionEvent event) Open edit dialog and save new item defined in edit controller.voidonSaveAll(javafx.event.ActionEvent event) Save all items from the changed item list.<E extends AbstractDetailController<T>>
voidsetDetailController(Class<E> detailController) Set the detail controller.protected voidsetRowFactory(String styleClass) Sets the row factory
-
Field Details
-
borderPane
protected javafx.scene.layout.BorderPane borderPane -
tableView
-
items
protected javafx.scene.layout.VBox items
-
-
Constructor Details
-
AbstractMFXMasterController
public AbstractMFXMasterController(net.rgielen.fxweaver.core.FxWeaver fxWeaver, CrudService<T> itemService, Class<? extends EditDialogControllerService<T>> editControllerClass)
-
-
Method Details
-
onNewItem
public void onNewItem(javafx.event.ActionEvent event) Open edit dialog and save new item defined in edit controller.- Parameters:
event- Action event - is not used
-
onSaveAll
public void onSaveAll(javafx.event.ActionEvent event) Save all items from the changed item list. At the end removes them from the list.Open alert dialog.
- Parameters:
event- Action event
-
onDelete
public void onDelete(javafx.event.ActionEvent event) Open alert dialog and delete selected item.- Parameters:
event- Action event
-
initialize
public final void initialize()Initialize FX controller.Load items from item service and set in table view.
-
addColumns
@SafeVarargs public final void addColumns(io.github.palexdev.materialfx.controls.MFXTableColumn<T>... columns) Add table view columns.- Parameters:
columns- Columns to add
-
setDetailController
Set the detail controller.- Type Parameters:
E- Detail controller type- Parameters:
detailController- Controller to set
-
setRowFactory
Sets the row factory- Parameters:
styleClass- Name of the style class to used in row factory
-
init
protected abstract void init()Delegate titles and columns initialization to subclass.
-