Copyright © 2005 Scientific Applications. All Rights Reserved.

com.sciapp.table
Class TableReorder

java.lang.Object
  extended by com.sciapp.table.TableReorder
All Implemented Interfaces:
ReorderListener, EventListener
Direct Known Subclasses:
DefaultTreeTableReorder, TreeTableReorder, TreeTableReorder

public class TableReorder
extends Object
implements ReorderListener

TableReorder acts on a JTable in order to ensure that the same rows are selected after the ReorderEvent is generated.


Field Summary
protected  int[] changedIndices
          an int array showing how the rows have changed place
protected  boolean scrollToSelection
          boolean flag indicating whether the table should scroll to the last selection after the cell selection has been restored.
protected  int[] selectedColumns
          the selected columns of the table
protected  int[] selectedRows
          the selected rows of the table
protected  JTable table
          the table
 
Constructor Summary
TableReorder()
          Constructs a TableReorder object with a null JTable.
TableReorder(JTable table)
          Constructs a TableReorder object acting on table.
 
Method Summary
 int getNewEditRow()
          Determines the displaced row index of the table's editing row, after a model update.
 boolean getScrollToSelection()
          Determines whether the table should scroll to the last selection after the cell selection has been restored.
 void reselectTableRows()
          Uses the values stored when the rowsReordered method was called in order to update the table selection.
 void reselectTableRows(int[] selRows, int[] mapIndex)
          Updates the table selection.
 void rowsReordered(ReorderEvent e)
          Called whenever the rows of a JTable have been restructured.
 void setScrollToSelection(boolean scrollToSelection)
          Determines whether the table should scroll to the last selection after the cell selection has been restored.
 void setTable(JTable newTable)
          Sets the table to newTable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

table

protected JTable table
the table


selectedRows

protected int[] selectedRows
the selected rows of the table


changedIndices

protected int[] changedIndices
an int array showing how the rows have changed place


selectedColumns

protected int[] selectedColumns
the selected columns of the table


scrollToSelection

protected boolean scrollToSelection
boolean flag indicating whether the table should scroll to the last selection after the cell selection has been restored.

Constructor Detail

TableReorder

public TableReorder()
Constructs a TableReorder object with a null JTable.


TableReorder

public TableReorder(JTable table)
Constructs a TableReorder object acting on table.

Method Detail

getNewEditRow

public int getNewEditRow()
Determines the displaced row index of the table's editing row, after a model update. If the table is not being edited, or if the editing row is removed from the view after a model update, this method returns -1.

Returns:
the new row index of the table's editing row

getScrollToSelection

public boolean getScrollToSelection()
Determines whether the table should scroll to the last selection after the cell selection has been restored.

Returns:
true if the table should scroll to the last selection, false otherwise.

reselectTableRows

public void reselectTableRows()
Uses the values stored when the rowsReordered method was called in order to update the table selection.


reselectTableRows

public void reselectTableRows(int[] selRows,
                              int[] mapIndex)
Updates the table selection.

Parameters:
selRows - the table's selected rows before an update to the table data was made
mapIndex - an int array showing how the rows have changed place

rowsReordered

public void rowsReordered(ReorderEvent e)
Called whenever the rows of a JTable have been restructured.

Specified by:
rowsReordered in interface ReorderListener
Parameters:
e - the ReorderEvent object

setScrollToSelection

public void setScrollToSelection(boolean scrollToSelection)
Determines whether the table should scroll to the last selection after the cell selection has been restored.

Parameters:
scrollToSelection - true if the table should scroll to the last selection, false otherwise.

setTable

public void setTable(JTable newTable)
Sets the table to newTable

Parameters:
newTable - the JTable to set

Copyright © 2005 Scientific Applications. All Rights Reserved.