uic.model
Interface TableViewInterface

All Known Implementing Classes:
TableRowSorter

public interface TableViewInterface

This interface should be added to every table model used in the MWTable from this package. This interface enforces the availablility of a method that allows the programmer to use the table more as a model-view-controller.


Method Summary
 TableModel getModel()
          Return the child model.
 int getOriginalIndex(int localIndex)
          Return the index of a row as reported by the model below this one.
 void setModel(TableModel model)
          TableModels are layered on top of each other, this method replaces the one below itself.
 

Method Detail

getModel

public TableModel getModel()
Return the child model.

In the default swing JTable and its models you can nest models and these models can be either view or data. The data model is always the last in the chain of models.

The problem with the Swing implementation is that the programmer needs a link to the datamodel since its impossible to get that from the JTable if at least one view model has been added. This method allows the recursive retrieval of models, and thus restoration of piece between the MVC and JTable groups :)

Returns:
the child model, or null if none.

setModel

public void setModel(TableModel model)
TableModels are layered on top of each other, this method replaces the one below itself. Every table has a series of tablemodels under itself. There can be any number (including none) of TableViews and there is always exactly one datamodel at the end of the chain. The table will ask the first model in its series for all the values, which then forwards the request to the second, which can then forward it again. All the way until the datamodel is reached which returns the value from its datastructures.

In order to allow the user to change this single linked list of table models it must be possible to set the childModel on each ViewModel.

Parameters:
model - the new child model this model will start using.

getOriginalIndex

public int getOriginalIndex(int localIndex)
Return the index of a row as reported by the model below this one. Models are layered one on top of each other; everyone only being able to talk to the one directly below it. Models that sort or filter can alter the rownumbers from the model below it and 'view' it differently in the requests from the model above it. This method allows the caller to find out the data- structure index by passing the view-index.

Take for example a filtering model that drops every other row; so only row 1, 3, 5 etc are displayed. This will result in visible-row 2 mapping to data-row 3, visible-row 3 to data-row 5 etc.
In this case an getOriginalIndex(3) will return 5;

Parameters:
localIndex - row number as seen in the tableModel interface.
Returns:
the index of the non-visible index in the datamodel.


Copyright © 2002,2003 Thomas Zander Available under the Free Apache licence