- java.lang.Object
-
- org.tentackle.fx.rdc.table.TableUtilities
-
@Service(TableUtilities.class) public class TableUtilities extends Object
Table-related utility methods.- Author:
- harald
-
-
Constructor Summary
Constructors Constructor Description TableUtilities()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <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 withPersistent) gets its own column, except the default attributes fromPersistentObjectand object ids for object relations.static TableUtilitiesgetInstance()The singleton.booleanisColumnVisible(TableColumnConfiguration<?,?> columnConfiguration)Returns whether a column is visible.voidprint(FxTableView<?> table, String title)Prints a table view.
Tables need a special handling for multiple pages.voidprint(FxTreeTableView<?> treeTable, String title)Prints a tree table view.
Tables need a special handling for multiple pages.FileselectSpreadsheetFile(String tableName, javafx.stage.Stage owner)Selects the spreadsheet file.FileselectXmlFile(String tableName, javafx.stage.Stage owner)Selects the XML file.protected <S> voidtoSpreadsheet(Collection<TableColumnConfiguration<S,?>> columnConfigurations, File file, List<S> items)Converts the column configurations to a spreadsheet file.<S> voidtoSpreadsheet(FxTableView<S> table, File file, boolean onlySelected)Converts the table to a spreadsheet file.<S> voidtoSpreadsheet(FxTreeTableView<S> treeTable, File file, boolean onlySelected)Converts the treetable to a spreadsheet file.<S> voidtoXml(FxTableView<S> table, File file, boolean onlySelected)Exports a table to an XML file.<S> voidtoXml(FxTreeTableView<S> treeTable, File file, boolean onlySelected)Exports a treetable to an XML file.
-
-
-
Method Detail
-
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 withPersistent) gets its own column, except the default attributes fromPersistentObjectand object ids for object relations.- Type Parameters:
T- the PDO type- Parameters:
pdoClass- the PDO classbundle- 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 nameowner- 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 nameowner- 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 viewfile- the output fileonlySelected- 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 viewfile- the output fileonlySelected- 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 configurerationsfile- the output fileitems- 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 viewfile- the output fileonlySelected- 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 viewfile- the output fileonlySelected- 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 printtitle- 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 printtitle- the optional title, null if take from treetable's configuration
-
-