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

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

public class TableTreeViewerSorterHandler
extends SelectionAdapter

Enables sorting facility for tabular Tree instances using an arbitrary TableTreeViewerSorter for sorting.

Author:
Sebastian Machhausen

Field Summary
private  TableTreeViewerSorter sorter
           The TableTreeViewerSorter to use for sorting
private  Tree tree
           The Tree that the TableTreeViewerSorter is bound to
 
Constructor Summary
TableTreeViewerSorterHandler(Tree tree, TableTreeViewerSorter sorter)
           Creates a new TableTreeViewerSorterHandler instance and binds it to the specified Tree using the given TableTreeViewerSorter to sort the model elements.
 
Method Summary
 void dispose()
           Disposes this TableTreeViewerSorterHandler.
private  void registerColumns()
           Registers all TreeColumns 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 TreeColumns from this TableTreeViewerSorterHandler.
 void widgetSelected(SelectionEvent event)
           Handles the SelectionEvent being triggered when the sorting column and/or order of the Tree 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

tree

private Tree tree

The Tree that the TableTreeViewerSorter is bound to


sorter

private TableTreeViewerSorter sorter

The TableTreeViewerSorter to use for sorting

Constructor Detail

TableTreeViewerSorterHandler

public TableTreeViewerSorterHandler(Tree tree,
                                    TableTreeViewerSorter sorter)

Creates a new TableTreeViewerSorterHandler instance and binds it to the specified Tree using the given TableTreeViewerSorter to sort the model elements.

Parameters:
tree - the Tree to bind this TableTreeViewerSorterHandler to
sorter - the TableTreeViewerSorter to use to sort the model elements
Method Detail

dispose

public void dispose()

Disposes this TableTreeViewerSorterHandler.


widgetSelected

public void widgetSelected(SelectionEvent event)

Handles the SelectionEvent being triggered when the sorting column and/or order of the Tree 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 TreeColumns to sort on header single mouse click. Each single mouse click on the same TreeColumns reverses the sort order.


unregisterColumns

private void unregisterColumns()

Unregisters all TreeColumns from this TableTreeViewerSorterHandler.