net.sourceforge.java.util.gui.jface.viewers
Class TableViewerSorterHandler

java.lang.Object
  extended byorg.eclipse.swt.events.SelectionAdapter
      extended bynet.sourceforge.java.util.gui.jface.viewers.TableViewerSorterHandler
All Implemented Interfaces:
EventListener, SelectionListener, SWTEventListener

public class TableViewerSorterHandler
extends SelectionAdapter

Enables sorting facility for Table instances using an arbitrary TableViewerSorter for sorting.

Author:
Sebastian Machhausen

Field Summary
private  TableViewerSorter sorter
           The TableViewerSorter to use for sorting
private  Table table
           The Table that the TableViewerSorter is bound to
 
Constructor Summary
TableViewerSorterHandler(Table table, TableViewerSorter sorter)
           Creates a new TableViewerSorterHandler instance and binds it to the specified Table using the given TableViewerSorter to sort the model elements.
 
Method Summary
 void dispose()
           Disposes this TableViewerSorterHandler.
private  void registerColumns()
           Registers all TableColumns to sort on header single mouse click.
 void sort(int columnIndex)
           Sorts the underlying model by the specified column.
 void sort(int columnIndex, boolean ascending)
           Sorts the underlying model by the specified columnIndex.
private  void unregisterColumns()
           Unregisters all TableColumns from this TableViewerSorterHandler.
 void widgetSelected(SelectionEvent event)
           Handles the SelectionEvent being triggered when the sorting column and/or order of the Table changes.
 
Methods inherited from class org.eclipse.swt.events.SelectionAdapter
widgetDefaultSelected
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

private Table table

The Table that the TableViewerSorter is bound to


sorter

private TableViewerSorter sorter

The TableViewerSorter to use for sorting

Constructor Detail

TableViewerSorterHandler

public TableViewerSorterHandler(Table table,
                                TableViewerSorter sorter)

Creates a new TableViewerSorterHandler instance and binds it to the specified Table using the given TableViewerSorter to sort the model elements.

Parameters:
table - the Table to bind this TableViewerSorterHandler to
sorter - the TableViewerSorter to use to sort the model elements
Method Detail

dispose

public void dispose()

Disposes this TableViewerSorterHandler.


widgetSelected

public void widgetSelected(SelectionEvent event)

Handles the SelectionEvent being triggered when the sorting column and/or order of the Table changes. The sorting of the underlying model is done using the selected column to sort by. The sort direction is reversed, i.e. from ascending to descending and reverse.

Parameters:
event - Event the SelectionEvent triggered

sort

public void sort(int columnIndex)

Sorts the underlying model by the specified column. The sort direction is reversed.

Parameters:
columnIndex - int the index of the column to sort

sort

public void sort(int columnIndex,
                 boolean ascending)

Sorts the underlying model by the specified columnIndex.

Parameters:
columnIndex - int the index of the column to sort
ascending - true for ascending, false for descending sort order

registerColumns

private void registerColumns()

Registers all TableColumns to sort on header single mouse click. Each single mouse click on the same TableColumns reverses the sort order.


unregisterColumns

private void unregisterColumns()

Unregisters all TableColumns from this TableViewerSorterHandler.