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 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 Details

    • PdoSearch

      public PdoSearch()
      Creates a search controller.
  • Method Details

    • getNoDataMessage

      public String 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

      public void setNoDataMessage(String noDataMessage)
      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

      public Consumer<T> getDoubleClickHandler()
      Gets the double click handler.
      Returns:
      the handler, null if default handler
    • setDoubleClickHandler

      public void setDoubleClickHandler(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).
      Parameters:
      doubleClickHandler - the handler, null to clear
    • getButtonBox

      public FxHBox getButtonBox()
      Gets the HBox containing all buttons.
      Returns:
      the button container
    • setFinder

      public void setFinder(PdoFinder<T> finder)
      Sets the PDO finder.
      The finder can be set only once.
      Parameters:
      finder - the finder
    • getFinder

      public PdoFinder<T> getFinder()
      Gets the PDO finder.
      Returns:
      the finder
    • setPdo

      public void setPdo(T pdo)
      Sets the PDO as a template for the search.
      Creates the result table and tree, and runs the search immediately if PdoFinder.isSearchRunningImmediately().
      Specified by:
      setPdo in interface PdoController<T extends PersistentDomainObject<T>>
      Parameters:
      pdo - the PDO
    • getPdo

      public T getPdo()
      Gets the PDO.
      Specified by:
      getPdo in interface PdoProvider<T extends PersistentDomainObject<T>>
      Returns:
      the PDO
    • setFinderVisible

      public void setFinderVisible(boolean visible)
      Sets the visibility of the finder.
      The method must be invoked after setPdo(T), because setPdo sets the visibility according to PdoFinder.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

      public void setTotals(javafx.collections.ObservableList<T> totals)
      Sets the totals.
      Shows the results from PdoFinder.createTotals(ObservableList) or hides the totals if none.
      Parameters:
      totals - the totals (usually one item), null or empty if none
      See Also:
    • getTotalsItems

      public javafx.collections.ObservableList<T> 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 if PdoFinder.isSearchRunningInBackground().
    • presetScrolling

      protected void presetScrolling()
      Presets the scrolling according to the finder's configuration.
      Scrolls to the end of the table or tree view, if PdoFinder.isScrollingToEnd() == true, otherwise to the beginning.
    • filterViewablePdos

      protected javafx.collections.ObservableList<T> filterViewablePdos(List<T> pdos)
      Filters the viewable PDOs from the list and converts them to an ObservableList.
      Parameters:
      pdos - list of PDOs, null is treated as empty
      Returns:
      the PDOs with view permission
    • setItems

      public void setItems(List<T> pdos)
      Shows the search results.
      PDOs the user is not allowed to view are skipped. If the shift key is held down, the PDOs are added to the current results.
      Parameters:
      pdos - the found PDOs, null or empty to clear
    • getItems

      public javafx.collections.ObservableList<T> 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

      public javafx.collections.ObservableList<T> 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

      public FxTreeView<T> 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

      public FxTableView<T> 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: FxController
      Configures the controller as the final step in initialization.
      Specified by:
      configure in interface FxController
      Overrides:
      configure in class AbstractFxController
    • 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