Class PdoSearch<T extends PersistentDomainObject<T>>
java.lang.Object
org.tentackle.fx.AbstractFxController
org.tentackle.fx.rdc.search.PdoSearch<T>
- Type Parameters:
T- the PDO type
- All Implemented Interfaces:
FxController, PdoController<T>, PdoProvider<T>, ScopeConfigurator
@FxControllerService(binding=NO)
public class PdoSearch<T extends PersistentDomainObject<T>>
extends AbstractFxController
implements PdoController<T>
Search controller for PDOs.
Wraps a
Wraps a
PdoFinder with a result table, which can be switched to a tree of the found PDOs.
Holding the shift key down while searching adds the new results to the existing ones.
If the entity provides a normtext, a filter field narrows the displayed result.
In a modal dialog, the user selects one or more PDOs, which are returned via getSelectedItems().
In a non-modal dialog, a double-click on a row opens the PDO in a CRUD dialog, which allows
walking through the result list.
- Author:
- harald
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidBinds the ok button so that it is enabled only if a PDO is selected.voidcancel()Clears the selection and closes the search.voidClears the selection.voidclose()Closes the search.voidConfigures the controller as the final step in initialization.voidCreates a new PDO in a modal CRUD dialog.
The unique domain key, if any, is taken from the search template.protected javafx.scene.NodeCreates the placeholder node for the empty search result in the table view.voidFilters the result.
Keeps only the PDOs whose normtext contains the normalized text of the filter field.protected javafx.collections.ObservableList<T> filterViewablePdos(List<T> pdos) Filters the viewable PDOs from the list and converts them to anObservableList.voidfind()Runs the search and displays the results.
The search runs in the background ifPdoFinder.isSearchRunningInBackground().Gets the HBox containing all buttons.Gets the double click handler.Gets the PDO finder.javafx.collections.ObservableList<T> getItems()Gets the items shown in the table or tree.Gets the message displayed in the table view when no data was found.getPdo()Gets the PDO.javafx.collections.ObservableList<T> Returns the selected PDOs.Gets access to the table view.
If the tree is shown, it will be switched to the table view.javafx.collections.ObservableList<T> Gets the totals if shown.Gets access to the tree view.
If the table is shown, it will be switched to the tree view.booleanReturns whether creating a new PDO is allowed.protected booleanReturns whether a CRUD is currently shown for this search.booleanReturns whether the finder is visible.booleanReturns whether in single selection mode.booleanReturns whether the tree is shown instead of the table.protected voidPresets the scrolling according to the finder's configuration.
Scrolls to the end of the table or tree view, ifPdoFinder.isScrollingToEnd()== true, otherwise to the beginning.voidsetCreatePdoAllowed(boolean allowed) Sets whether creating a new PDO is allowed.
Shows or hides the new button.voidsetDoubleClickHandler(Consumer<T> doubleClickHandler) Sets the double click handler.
If the search dialog is non-modal and the user double-clicks on a row of the table view, this handler will be invoked instead of the default (showing the PDO editor, if provided).voidSets the PDO finder.
The finder can be set only once.voidsetFinderVisible(boolean visible) Sets the visibility of the finder.
The method must be invoked aftersetPdo(T), becausesetPdosets the visibility according toPdoFinder.isVisible().voidShows the search results.
PDOs the user is not allowed to view are skipped.voidsetNoDataMessage(String noDataMessage) Sets the message displayed in the table view when no data was found.voidSets the PDO as a template for the search.
Creates the result table and tree, and runs the search immediately ifPdoFinder.isSearchRunningImmediately().voidsetSingleSelectMode(boolean singleSelectMode) Sets the single selection mode.
This mode is usually used in a modal dialog to select exactly one PDO.voidSets the totals.
Shows the results fromPdoFinder.createTotals(ObservableList)or hides the totals if none.voidSwitches to the table view.voidshowTree()Switches to the tree view.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
-
PdoSearch
public PdoSearch()Creates a search controller.
-
-
Method Details
-
getNoDataMessage
Gets the message displayed in the table view when no data was found.- Returns:
- the placeholder message, null if the default message, empty if no message at all
-
setNoDataMessage
Sets the message displayed in the table view when no data was found.- Parameters:
noDataMessage- the placeholder message, null if the default message, empty if no message at all
-
getDoubleClickHandler
-
setDoubleClickHandler
Sets the double click handler.
If the search dialog is non-modal and the user double-clicks on a row of the table view, this handler will be invoked instead of the default (showing the PDO editor, if provided).- Parameters:
doubleClickHandler- the handler, null to clear
-
getButtonBox
-
setFinder
-
getFinder
-
setPdo
Sets the PDO as a template for the search.
Creates the result table and tree, and runs the search immediately ifPdoFinder.isSearchRunningImmediately().- 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
-
setFinderVisible
public void setFinderVisible(boolean visible) Sets the visibility of the finder.
The method must be invoked aftersetPdo(T), becausesetPdosets the visibility according toPdoFinder.isVisible().- Parameters:
visible- true if visible
-
isFinderVisible
public boolean isFinderVisible()Returns whether the finder is visible.- Returns:
- true if visible
-
setSingleSelectMode
public void setSingleSelectMode(boolean singleSelectMode) Sets the single selection mode.
This mode is usually used in a modal dialog to select exactly one PDO.- Parameters:
singleSelectMode- true if select a single PDO
-
isSingleSelectMode
public boolean isSingleSelectMode()Returns whether in single selection mode.- Returns:
- true if select a single PDO
-
setCreatePdoAllowed
public void setCreatePdoAllowed(boolean allowed) Sets whether creating a new PDO is allowed.
Shows or hides the new button.- Parameters:
allowed- true if allowed
-
isCreatePdoAllowed
public boolean isCreatePdoAllowed()Returns whether creating a new PDO is allowed.- Returns:
- true if allowed
-
setTotals
Sets the totals.
Shows the results fromPdoFinder.createTotals(ObservableList)or hides the totals if none.- Parameters:
totals- the totals (usually one item), null or empty if none- See Also:
-
getTotalsItems
Gets the totals if shown.- Returns:
- the totals, null if no totals
-
updateTitle
public void updateTitle()Updates the window title if attached to its own stage. -
find
public void find()Runs the search and displays the results.
The search runs in the background ifPdoFinder.isSearchRunningInBackground(). -
presetScrolling
protected void presetScrolling()Presets the scrolling according to the finder's configuration.
Scrolls to the end of the table or tree view, ifPdoFinder.isScrollingToEnd()== true, otherwise to the beginning. -
filterViewablePdos
-
setItems
-
getItems
Gets the items shown in the table or tree.- Returns:
- the items
-
filterResult
public void filterResult()Filters the result.
Keeps only the PDOs whose normtext contains the normalized text of the filter field. A leading!or-inverts the filter. -
getSelectedItems
Returns the selected PDOs.- Returns:
- the selected PDOs or the newly created PDO, empty list if nothing selected
-
clearSelection
public void clearSelection()Clears the selection. -
isTreeShown
public boolean isTreeShown()Returns whether the tree is shown instead of the table.- Returns:
- true, if the tree is shown, else the table is shown
-
showTree
public void showTree()Switches to the tree view. -
getTreeView
Gets access to the tree view.
If the table is shown, it will be switched to the tree view.- Returns:
- the tree view
-
showTable
public void showTable()Switches to the table view. -
getTableView
Gets access to the table view.
If the tree is shown, it will be switched to the table view.- Returns:
- the table view
-
cancel
public void cancel()Clears the selection and closes the search. -
close
public void close()Closes the search. -
createPdo
public void createPdo()Creates a new PDO in a modal CRUD dialog.
The unique domain key, if any, is taken from the search template. If the PDO was saved, the search is closed and the new PDO is returned as the selected item. -
configure
public void configure()Description copied from interface:FxControllerConfigures the controller as the final step in initialization.- Specified by:
configurein interfaceFxController- Overrides:
configurein classAbstractFxController
-
bindOkButton
protected void bindOkButton()Binds the ok button so that it is enabled only if a PDO is selected. -
isCrudShown
protected boolean isCrudShown()Returns whether a CRUD is currently shown for this search.- Returns:
- true if shown
-
createPlaceHolder
protected javafx.scene.Node createPlaceHolder()Creates the placeholder node for the empty search result in the table view.- Returns:
- the node, null to use the table view's default placeholder
-