- java.lang.Object
-
- org.tentackle.fx.table.DefaultTableConfiguration<S>
-
- Type Parameters:
S- type of the objects contained within the table's items list
- All Implemented Interfaces:
TableConfiguration<S>
public class DefaultTableConfiguration<S> extends java.lang.Object implements TableConfiguration<S>
Default implementation of a table configuration.- Author:
- harald
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.tentackle.fx.table.TableConfiguration
TableConfiguration.BINDING, TableConfiguration.EDITMODE
-
-
Constructor Summary
Constructors Constructor Description DefaultTableConfiguration(java.lang.Class<S> objectClass, java.lang.String name)Creates a configuration.DefaultTableConfiguration(S template, java.lang.String name)Creates a configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TableColumnConfiguration<S,?>addColumn(java.lang.String name, java.lang.String displayedName)Adds a column via binding path.voidaddColumnConfiguration(TableColumnConfiguration<S,?> columnConfiguration)Adds a column configuration.voidconfigure(FxTableView<S> table)Configures the table.FxTableBinder<S>getBinder()Gets the table binder.
Don't mix up the table's binder with the FxController's binder! The table binder is responsible to bind the cells to the model, whereas the controller binder binds the data list to the table.
As a consequence, binding properties such as the DomainContext, if necessary for cell editors, must be applied to the table binder!TableConfiguration.BINDINGgetBindingType()Gets the type of binding.<T> TableCellType<T>getCellType(java.lang.Class<T> type)Gets the cell type according to the item type.TableColumnConfiguration<S,?>getColumnConfiguration(java.lang.String name)Gets a column configuration by its name.TableColumnConfiguration<S,?>getColumnConfiguration(javafx.scene.control.TableColumn<S,?> column)Gets a column configuration by its table column.java.util.Collection<TableColumnConfiguration<S,?>>getColumnConfigurations()Gets the configurations of the columns.TableConfiguration.EDITMODEgetEditMode()Returns the edit mode.java.lang.StringgetName()Gets the name of the table.
The name is also used as a key to the table preferences.java.lang.Class<S>getObjectClass()Gets the row object class.SgetTemplate()Gets the template.booleanisSortingIncluded()Returns whether the preferences include the column sorting.booleanisViewSizeIncluded()Returns whether the preferences include the view size.voidloadPreferences(FxTableView<S> table, java.lang.String suffix, boolean system)Loads the column sizes, visability, view size and sorting from the preferences.TableColumnConfiguration<S,?>removeColumn(java.lang.String name)Removes a column via binding path.voidsavePreferences(FxTableView<S> table, java.lang.String suffix, boolean system)Saves the column sizes, visability, view size and sorting to the preferences.voidsetBindingType(TableConfiguration.BINDING bindingType)Sets the type of binding.voidsetEditMode(TableConfiguration.EDITMODE editMode)Sets the edit mode.voidsetSortingIncluded(boolean sortingIncluded)Sets whether the preferences include the column sorting.voidsetViewSizeIncluded(boolean viewSizeIncluded)Sets whether the preferences include the view size.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultTableConfiguration
public DefaultTableConfiguration(S template, java.lang.String name)
Creates a configuration.- Parameters:
template- a template objectname- the table's name, null if basename from effective class of template
-
DefaultTableConfiguration
public DefaultTableConfiguration(java.lang.Class<S> objectClass, java.lang.String name)
Creates a configuration.- Parameters:
objectClass- the object classname- the table's name, null if basename from effective class of template
-
-
Method Detail
-
getTemplate
public S getTemplate()
Gets the template.- Returns:
- the template, null if only class given
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
addColumn
public TableColumnConfiguration<S,?> addColumn(java.lang.String name, java.lang.String displayedName)
Description copied from interface:TableConfigurationAdds a column via binding path.- Specified by:
addColumnin interfaceTableConfiguration<S>- Parameters:
name- the column's binding pathdisplayedName- the displayed column name- Returns:
- the created column configuration
-
removeColumn
public TableColumnConfiguration<S,?> removeColumn(java.lang.String name)
Description copied from interface:TableConfigurationRemoves a column via binding path.- Specified by:
removeColumnin interfaceTableConfiguration<S>- Parameters:
name- the column's binding path- Returns:
- the old column configuration, null if no such column
-
addColumnConfiguration
public void addColumnConfiguration(TableColumnConfiguration<S,?> columnConfiguration)
Description copied from interface:TableConfigurationAdds a column configuration.- Specified by:
addColumnConfigurationin interfaceTableConfiguration<S>- Parameters:
columnConfiguration- the config
-
getColumnConfigurations
public java.util.Collection<TableColumnConfiguration<S,?>> getColumnConfigurations()
Description copied from interface:TableConfigurationGets the configurations of the columns.- Specified by:
getColumnConfigurationsin interfaceTableConfiguration<S>- Returns:
- the column configurations
-
getColumnConfiguration
public TableColumnConfiguration<S,?> getColumnConfiguration(java.lang.String name)
Description copied from interface:TableConfigurationGets a column configuration by its name.- Specified by:
getColumnConfigurationin interfaceTableConfiguration<S>- Parameters:
name- the name- Returns:
- the config, null if no such name and displayed name
-
getColumnConfiguration
public TableColumnConfiguration<S,?> getColumnConfiguration(javafx.scene.control.TableColumn<S,?> column)
Description copied from interface:TableConfigurationGets a column configuration by its table column.- Specified by:
getColumnConfigurationin interfaceTableConfiguration<S>- Parameters:
column- the table column- Returns:
- the config, null if no such column
-
getName
public java.lang.String getName()
Description copied from interface:TableConfigurationGets the name of the table.
The name is also used as a key to the table preferences.- Specified by:
getNamein interfaceTableConfiguration<S>- Returns:
- the name, never null
-
isSortingIncluded
public boolean isSortingIncluded()
Description copied from interface:TableConfigurationReturns whether the preferences include the column sorting.- Specified by:
isSortingIncludedin interfaceTableConfiguration<S>- Returns:
- true if sorting is restored from the preferences (default is false)
-
setSortingIncluded
public void setSortingIncluded(boolean sortingIncluded)
Description copied from interface:TableConfigurationSets whether the preferences include the column sorting.- Specified by:
setSortingIncludedin interfaceTableConfiguration<S>- Parameters:
sortingIncluded- true if sorting is restored from the preferences (default is false)
-
isViewSizeIncluded
public boolean isViewSizeIncluded()
Description copied from interface:TableConfigurationReturns whether the preferences include the view size.- Specified by:
isViewSizeIncludedin interfaceTableConfiguration<S>- Returns:
- true if the preferred size is restored from the preferences (default is true)
-
setViewSizeIncluded
public void setViewSizeIncluded(boolean viewSizeIncluded)
Description copied from interface:TableConfigurationSets whether the preferences include the view size.- Specified by:
setViewSizeIncludedin interfaceTableConfiguration<S>- Parameters:
viewSizeIncluded- true if the preferred size is restored from the preferences (default is true)
-
savePreferences
public void savePreferences(FxTableView<S> table, java.lang.String suffix, boolean system)
Description copied from interface:TableConfigurationSaves the column sizes, visability, view size and sorting to the preferences.- Specified by:
savePreferencesin interfaceTableConfiguration<S>- Parameters:
table- the tablesuffix- the configuration suffix, null if nonesystem- true if save to system prefs, else user prefs
-
loadPreferences
public void loadPreferences(FxTableView<S> table, java.lang.String suffix, boolean system)
Description copied from interface:TableConfigurationLoads the column sizes, visability, view size and sorting from the preferences.- Specified by:
loadPreferencesin interfaceTableConfiguration<S>- Parameters:
table- the tablesuffix- the configuration suffix, null if nonesystem- true if load from system prefs only, else user prefs first
-
getEditMode
public TableConfiguration.EDITMODE getEditMode()
Description copied from interface:TableConfigurationReturns the edit mode.- Specified by:
getEditModein interfaceTableConfiguration<S>- Returns:
- the edit mode, never null, default is NO
-
setEditMode
public void setEditMode(TableConfiguration.EDITMODE editMode)
Description copied from interface:TableConfigurationSets the edit mode.- Specified by:
setEditModein interfaceTableConfiguration<S>- Parameters:
editMode- the edit mode, null is equivalent to NO
-
configure
public void configure(FxTableView<S> table)
Description copied from interface:TableConfigurationConfigures the table.- Specified by:
configurein interfaceTableConfiguration<S>- Parameters:
table- the table view
-
getObjectClass
public java.lang.Class<S> getObjectClass()
Description copied from interface:TableConfigurationGets the row object class.- Specified by:
getObjectClassin interfaceTableConfiguration<S>- Returns:
- the row object class
-
getBindingType
public TableConfiguration.BINDING getBindingType()
Description copied from interface:TableConfigurationGets the type of binding.- Specified by:
getBindingTypein interfaceTableConfiguration<S>- Returns:
- the binding type
-
setBindingType
public void setBindingType(TableConfiguration.BINDING bindingType)
Description copied from interface:TableConfigurationSets the type of binding.- Specified by:
setBindingTypein interfaceTableConfiguration<S>- Parameters:
bindingType- the binding type
-
getBinder
public FxTableBinder<S> getBinder()
Description copied from interface:TableConfigurationGets the table binder.
Don't mix up the table's binder with the FxController's binder! The table binder is responsible to bind the cells to the model, whereas the controller binder binds the data list to the table.
As a consequence, binding properties such as the DomainContext, if necessary for cell editors, must be applied to the table binder!- Specified by:
getBinderin interfaceTableConfiguration<S>- Returns:
- the binder
-
getCellType
public <T> TableCellType<T> getCellType(java.lang.Class<T> type)
Description copied from interface:TableConfigurationGets the cell type according to the item type.- Specified by:
getCellTypein interfaceTableConfiguration<S>- Type Parameters:
T- the item type- Parameters:
type- the item class- Returns:
- the cell type, never null
-
-