Class TableUtilities

java.lang.Object
org.tentackle.fx.rdc.table.TableUtilities

@Service(TableUtilities.class) public class TableUtilities extends Object
Table-related utility methods.
Author:
harald
  • Constructor Details

    • TableUtilities

      public TableUtilities()
  • Method Details

    • getInstance

      public static TableUtilities getInstance()
      The singleton.
      Returns:
      the singleton
    • createTableConfiguration

      public <T extends PersistentDomainObject<T>> TableConfiguration<T> createTableConfiguration(Class<T> pdoClass, ResourceBundle bundle)
      Creates a default table configuration for a given PDO class.
      Each attribute getter (annotated with Persistent) gets its own column, except the default attributes from PersistentObject and object ids for object relations.
      Type Parameters:
      T - the PDO type
      Parameters:
      pdoClass - the PDO class
      bundle - optional bundle to determine the displayed column names, null if name is attribute name
      Returns:
      the table configuration
    • selectSpreadsheetFile

      public File selectSpreadsheetFile(String tableName, javafx.stage.Stage owner)
      Selects the spreadsheet file.
      Parameters:
      tableName - the configured table name
      owner - the window owner for the selection dialog, null if none
      Returns:
      the selected file, null if aborted
    • selectXmlFile

      public File selectXmlFile(String tableName, javafx.stage.Stage owner)
      Selects the XML file.
      Parameters:
      tableName - the configured table name
      owner - the window owner for the selection dialog, null if none
      Returns:
      the selected file, null if aborted
    • toSpreadsheet

      public <S> void toSpreadsheet(FxTableView<S> table, File file, boolean onlySelected)
      Converts the table to a spreadsheet file.
      Type Parameters:
      S - the row type
      Parameters:
      table - the table view
      file - the output file
      onlySelected - true if export only selected rows
    • toSpreadsheet

      public <S> void toSpreadsheet(FxTreeTableView<S> treeTable, File file, boolean onlySelected)
      Converts the treetable to a spreadsheet file.
      Type Parameters:
      S - the row type
      Parameters:
      treeTable - the table view
      file - the output file
      onlySelected - true if export only selected rows
    • toSpreadsheet

      protected <S> void toSpreadsheet(Collection<TableColumnConfiguration<S,?>> columnConfigurations, File file, List<S> items)
      Converts the column configurations to a spreadsheet file.
      Type Parameters:
      S - the row type
      Parameters:
      columnConfigurations - the column configurerations
      file - the output file
      items - the items to export
    • isColumnVisible

      public boolean isColumnVisible(TableColumnConfiguration<?,?> columnConfiguration)
      Returns whether a column is visible.
      Parameters:
      columnConfiguration - the column configuration
      Returns:
      true if visible
    • toXml

      public <S> void toXml(FxTableView<S> table, File file, boolean onlySelected)
      Exports a table to an XML file.
      Type Parameters:
      S - the row type
      Parameters:
      table - the table view
      file - the output file
      onlySelected - true if export only selected rows
    • toXml

      public <S> void toXml(FxTreeTableView<S> treeTable, File file, boolean onlySelected)
      Exports a treetable to an XML file.
      Type Parameters:
      S - the row type
      Parameters:
      treeTable - the treetable view
      file - the output file
      onlySelected - true if export only selected rows
    • print

      public void print(FxTableView<?> table, String title)
      Prints a table view.
      Tables need a special handling for multiple pages.
      Parameters:
      table - the table to print
      title - the optional title, null if take from table's configuration
    • print

      public void print(FxTreeTableView<?> treeTable, String title)
      Prints a tree table view.
      Tables need a special handling for multiple pages.
      Parameters:
      treeTable - the treetable to print
      title - the optional title, null if take from treetable's configuration