org.olat.core.gui.components.table
Class TableController

java.lang.Object
  extended by org.olat.core.gui.control.DefaultController
      extended by org.olat.core.gui.components.table.TableController
All Implemented Interfaces:
Controller, ControllerEventListener, Disposable

public class TableController
extends DefaultController
implements ControllerEventListener

Responsability:

This controller wraps a table component and offers additional features like column selection. Two constructors are supported: regular table and table with a table filter. Use the TableGuiConfiguration object to configure the various rendering options.

Events fired:

Workflow:

Special translators:

Uses a translator provided in the constructor as fallback.

Hints:

Opens a modal dialog for choosing which columns to hide or show.

Author:
Felix Jost, Florian Gnägi

Field Summary
static Event EVENT_FILTER_SELECTED
          Event is fired when a specific filter is selected.
static Event EVENT_NOFILTER_SELECTED
          Event is fired when the 'apply no filter' is selected *
 
Constructor Summary
TableController(TableGuiConfiguration tableConfig, UserRequest ureq, WindowControl wControl, java.util.List filters, ShortName activeFilter, java.lang.String filterTitle, java.lang.String noFilterOption, Translator tableTrans, ControllerEventListener tableEventListener)
          Constructor for the table controller using the table filter.
TableController(TableGuiConfiguration tableConfig, UserRequest ureq, WindowControl wControl, Translator tableTrans, ControllerEventListener tableEventListener)
          Constructor for the table controller
TableController(TableGuiConfiguration tableConfig, UserRequest ureq, WindowControl wControl, Translator tableTrans, ControllerEventListener tableEventListener, boolean enableTableSearch)
           
 
Method Summary
 void addColumnDescriptor(boolean visible, ColumnDescriptor cd)
          Add a table column descriptor
 void addColumnDescriptor(ColumnDescriptor cd)
          Add a visible table column descriptor
 void addMultiSelectAction(java.lang.String actionKeyi18n, java.lang.String actionIdentifier)
          Add a multiselect action.
 void dispatchEvent(UserRequest ureq, Controller source, Event event)
           
 void event(UserRequest ureq, Component source, Event event)
          abstract event method for subclasses.
 ShortName getActiveFilter()
           
 ColumnDescriptor getColumnDescriptor(int row)
          Get the table column descriptor.
 java.util.List getSelectedSortedObjects(java.util.BitSet objectMarkers, DefaultTableDataModel defaultTableDataModel)
          Sorts the selected table row indexes according with the table Comparator, and then retrieves the rows from the input defaultTableDataModel.
 TableDataModel getTableDataModel()
          Get the current table data model from the table
 void modelChanged()
           
 void modelChanged(boolean resetSearchString)
          Notifies the controller about a changed table data model.
 void setActiveFilter(ShortName activeFilter)
           
 void setFilters(java.util.List filters, ShortName activeFilter)
          Sets the list of filters and the currently active filter
 void setMultiSelect(boolean isMultiSelect)
          Sets wether user is able to select multiple rows via checkboxes.
 void setMultiSelectReadonlyAt(int row, boolean readonly)
           
 void setMultiSelectSelectedAt(int row, boolean selected)
           
 void setSelectedRowId(int selectedRowId)
          Sets the selectedRowId to a specific row id.
 void setSortColumn(int sortColumn, boolean isSortAscending)
          Sets the sortColumn to a specific colun id.
 void setTableDataModel(TableDataModel tableDataModel)
          Sets the tableDataModel.
 
Methods inherited from class org.olat.core.gui.control.DefaultController
addControllerListener, addLoggingResourceable, dispatchEvent, dispose, getControllerCount, getInitialComponent, getUserActivityLogger, getWindowControlForDebug, isDisposed, toString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EVENT_NOFILTER_SELECTED

public static final Event EVENT_NOFILTER_SELECTED
Event is fired when the 'apply no filter' is selected *


EVENT_FILTER_SELECTED

public static final Event EVENT_FILTER_SELECTED
Event is fired when a specific filter is selected. Use getActiveFilter to retrieve the selected filter

Constructor Detail

TableController

public TableController(TableGuiConfiguration tableConfig,
                       UserRequest ureq,
                       WindowControl wControl,
                       java.util.List filters,
                       ShortName activeFilter,
                       java.lang.String filterTitle,
                       java.lang.String noFilterOption,
                       Translator tableTrans,
                       ControllerEventListener tableEventListener)
Constructor for the table controller using the table filter.

Parameters:
tableConfig - The table gui configuration determines the tables behaviour, may be null to use default table config.
ureq - The user request
wControl - The window control
filters - A list of filter objects (ShortName)
activeFilter - The initially activated filter object
filterTitle - The translated title of the filter
noFilterOption - The translated key for the no-filter filter or null if not used
tableTrans - The translator that is used to translate the table
tableEventListener - The listener for the table and table controller events

TableController

public TableController(TableGuiConfiguration tableConfig,
                       UserRequest ureq,
                       WindowControl wControl,
                       Translator tableTrans,
                       ControllerEventListener tableEventListener)
Constructor for the table controller

Parameters:
tableConfig - The table gui configuration determines the tables behaviour, may be null to use default table config.
ureq - The user request
wControl - The window control
tableTrans - The translator that is used to translate the table
tableEventListener - The listener for the table and table controller events

TableController

public TableController(TableGuiConfiguration tableConfig,
                       UserRequest ureq,
                       WindowControl wControl,
                       Translator tableTrans,
                       ControllerEventListener tableEventListener,
                       boolean enableTableSearch)
Method Detail

event

public void event(UserRequest ureq,
                  Component source,
                  Event event)
Description copied from class: DefaultController
abstract event method for subclasses. the event received from the component we are listening to are always rerouted to this method here, except when the component has been disposed, in which case the events are simply ignored.

See Also:
DefaultController.event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)

dispatchEvent

public void dispatchEvent(UserRequest ureq,
                          Controller source,
                          Event event)
Specified by:
dispatchEvent in interface ControllerEventListener
Overrides:
dispatchEvent in class DefaultController
See Also:
ControllerEventListener.dispatchEvent(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)

getActiveFilter

public ShortName getActiveFilter()
Returns:
The currently active filter object or null if no filter is applied

setActiveFilter

public void setActiveFilter(ShortName activeFilter)
Parameters:
activeFilter - The currently applied filter or null if no filter is applied

setFilters

public void setFilters(java.util.List filters,
                       ShortName activeFilter)
Sets the list of filters and the currently active filter

Parameters:
filters - List of TableFilter
activeFilter - active TableFilter

modelChanged

public void modelChanged()

modelChanged

public void modelChanged(boolean resetSearchString)
Notifies the controller about a changed table data model. This will check if the table data model has any values and show a message instead of the table when the model has no rows.


setTableDataModel

public void setTableDataModel(TableDataModel tableDataModel)
Sets the tableDataModel. IMPORTANT: Once a tableDataModel is set, it is assumed to remain constant in its data & row & colcount. Otherwise a modelChanged has to be called

Parameters:
tableDataModel - The tableDataModel to set

addColumnDescriptor

public void addColumnDescriptor(boolean visible,
                                ColumnDescriptor cd)
Add a table column descriptor

Parameters:
visible - true: is visible; false: is not visible
cd - column descriptor

addColumnDescriptor

public void addColumnDescriptor(ColumnDescriptor cd)
Add a visible table column descriptor

Parameters:
cd - column descriptor

getColumnDescriptor

public ColumnDescriptor getColumnDescriptor(int row)
Get the table column descriptor.

Parameters:
row -
Returns:
ColumnDescriptor

getTableDataModel

public TableDataModel getTableDataModel()
Get the current table data model from the table

Returns:
TableDataModel

getSelectedSortedObjects

public java.util.List getSelectedSortedObjects(java.util.BitSet objectMarkers,
                                               DefaultTableDataModel defaultTableDataModel)
Sorts the selected table row indexes according with the table Comparator, and then retrieves the rows from the input defaultTableDataModel. It is assumed that the defaultTableDataModel IS THE MODEL for the table.

Parameters:
objectMarkers -
Returns:
the List with the sorted selected objects in this table.

setSelectedRowId

public void setSelectedRowId(int selectedRowId)
Sets the selectedRowId to a specific row id. Make sure that this is valid, the table does not check for out of bound exception.

Parameters:
selectedRowId - The selectedRowId to set

setSortColumn

public void setSortColumn(int sortColumn,
                          boolean isSortAscending)
Sets the sortColumn to a specific colun id. Check if the column can be accessed and if it is sortable.

Parameters:
sortColumn - The sortColumn to set
isSortAscending - true: sorting is ascending

setMultiSelect

public void setMultiSelect(boolean isMultiSelect)
Sets wether user is able to select multiple rows via checkboxes.

Parameters:
isMultiSelect -

setMultiSelectSelectedAt

public void setMultiSelectSelectedAt(int row,
                                     boolean selected)

setMultiSelectReadonlyAt

public void setMultiSelectReadonlyAt(int row,
                                     boolean readonly)

addMultiSelectAction

public void addMultiSelectAction(java.lang.String actionKeyi18n,
                                 java.lang.String actionIdentifier)
Add a multiselect action.

Parameters:
actionKeyi18n -
actionIdentifier -