Package org.opencms.ui.util.table
Class CmsBeanTableBuilder<T>
- java.lang.Object
-
- org.opencms.ui.util.table.CmsBeanTableBuilder<T>
-
- Type Parameters:
T
- The class of the bean containing the metadata of the table
public class CmsBeanTableBuilder<T> extends java.lang.Object
Builds a table based on a given bean class.The columns of the table correspond to getters of the given bean class with the Column annotation.
-
-
Constructor Summary
Constructors Constructor Description CmsBeanTableBuilder(java.lang.Class<T> cls, java.lang.String view)
Creates a new table builder instance for the given bean class and view.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildTable(com.vaadin.v7.ui.Table table, java.util.List<T> beans)
Sets up a table and uses the given beans to fill its rows, but does not actually create the table instance; it uses the passed in table instance instead.com.vaadin.v7.ui.Table
buildTable(java.util.List<T> beans)
Builds a table and uses the given beans to fill its rows.com.vaadin.v7.ui.Table.CellStyleGenerator
getDefaultCellStyleGenerator()
Creates a default cell style generator which just returns the value of the styleName attribute in a Column annotation for cells in that column.com.vaadin.v7.data.Container.Filter
getDefaultFilter(java.lang.String filterString)
Creates a default filter which just searches the lower case version of the result of the toString() method applied to all columns with the annotation attribute filterable = true.CmsMacroResolver
getMacroResolver()
Gets the macro resolver which is used for column headers.static boolean
isProbablyMessageKey(java.lang.String str)
Checks if the given string is likely a message key.static <V> CmsBeanTableBuilder<V>
newInstance(java.lang.Class<V> cls)
Convenience method used to create a new instance of a table builder.static <V> CmsBeanTableBuilder<V>
newInstance(java.lang.Class<V> cls, java.lang.String view)
Convenience method used to create a new instance of a table builder.void
setMacroResolver(CmsMacroResolver resolver)
Sets the macro resolver.
-
-
-
Constructor Detail
-
CmsBeanTableBuilder
public CmsBeanTableBuilder(java.lang.Class<T> cls, java.lang.String view)
Creates a new table builder instance for the given bean class and view.Depending on the view configuration of the columns, columns may be hidden depending on the view.
- Parameters:
cls
- the bean classview
- the selected view
-
-
Method Detail
-
isProbablyMessageKey
public static boolean isProbablyMessageKey(java.lang.String str)
Checks if the given string is likely a message key.- Parameters:
str
- the input string- Returns:
- true if this is probably a message key
-
newInstance
public static <V> CmsBeanTableBuilder<V> newInstance(java.lang.Class<V> cls)
Convenience method used to create a new instance of a table builder.- Parameters:
cls
- the bean class- Returns:
- the new table builder
-
newInstance
public static <V> CmsBeanTableBuilder<V> newInstance(java.lang.Class<V> cls, java.lang.String view)
Convenience method used to create a new instance of a table builder.- Parameters:
cls
- the bean classview
- the selected view- Returns:
- the new table builder
-
buildTable
public com.vaadin.v7.ui.Table buildTable(java.util.List<T> beans)
Builds a table and uses the given beans to fill its rows.- Parameters:
beans
- the beans to display in the table- Returns:
- the finished table
-
buildTable
public void buildTable(com.vaadin.v7.ui.Table table, java.util.List<T> beans)
Sets up a table and uses the given beans to fill its rows, but does not actually create the table instance; it uses the passed in table instance instead.- Parameters:
table
- the table to set upbeans
- the beans to display in the table
-
getDefaultCellStyleGenerator
public com.vaadin.v7.ui.Table.CellStyleGenerator getDefaultCellStyleGenerator()
Creates a default cell style generator which just returns the value of the styleName attribute in a Column annotation for cells in that column.- Returns:
- the default cell style generator
-
getDefaultFilter
public com.vaadin.v7.data.Container.Filter getDefaultFilter(java.lang.String filterString)
Creates a default filter which just searches the lower case version of the result of the toString() method applied to all columns with the annotation attribute filterable = true.- Parameters:
filterString
- the string for which to filter- Returns:
- the default filter for the given filter string
-
getMacroResolver
public CmsMacroResolver getMacroResolver()
Gets the macro resolver which is used for column headers.- Returns:
- the macro resolver for column headers
-
setMacroResolver
public void setMacroResolver(CmsMacroResolver resolver)
Sets the macro resolver.- Parameters:
resolver
- the macro resolver
-
-