Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[geclipse-dev] Table sorting

Dear all,

regarding issue #208528 (http://bugs.eclipse.org/208528) reported by Harald 
about the tables in our views not supporting sorting when clicking on the 
different columns, i've added the two classes:
   eu.geclipse.ui.listeners.TableColumnListener
and
   eu.geclipse.ui.comparators.TableColumnComparator

This allows to add sorting to a *TableViewer with the few lines below.
Please add sorting to the tables in your views as requested by #208528.

---------------
import eu.geclipse.ui.internal.comparators.TableColumnComparator;
import eu.geclipse.ui.internal.listeners.TableColumnListener;
...
  public void createPartControl( ... ) {
      ...
      TableColumnListener columnListener
          = new TableColumnListener( theTableViewer );
      theFirstColumn.addSelectionListener( columnListener );
      theSecondColumn.addSelectionListener( columnListener );
    
      // Initially we sort the table by the first column, ascending
      theTable.setSortColumn( theFirstColumn );
      theTable.setSortDirection( SWT.UP );
      theTableViewer.setComparator( 
         new TableColumnComparator( this.voViewer, nameColumn ) );

--------------


If anybody knows about a smart way of telling the Table or TableViewer to 
refresh without requiring explicit knowledge of the TableViewer  i would 
be glad to know about it!
(currently using
  theTableViewer.refresh();
in the TableColumnListener  but that requires to pass the TableViewer as a 
param in the constructor... not nice... )

Cheers, Ariel


Back to the top