Methods Summary |
---|
public void | addTableModelListener(javax.swing.event.TableModelListener l)
listenerList.add (TableModelListener.class, l);
|
protected void | fireAllChanged()
TableModelEvent e = new TableModelEvent (this);
fireTableModelEvent (e);
|
public void | fireTableModelEvent(javax.swing.event.TableModelEvent e)
Object[] listeners = listenerList.getListenerList();
for (int i = listeners.length-2; i>=0; i-=2) {
if (listeners[i] == TableModelListener.class) {
((TableModelListener) listeners[i+1]).tableChanged(e);
}
}
|
public java.lang.Class | getColumnClass(int columnIndex)
if (delegatedModel.getRowCount() > 0)
return delegatedModel.getValueAt(0, columnIndex).getClass();
else
return Object.class;
|
public int | getColumnCount()
return delegatedModel.getColumnCount();
|
public java.lang.String | getColumnName(int index)
return delegatedModel.getColumnName (index);
|
private int | getDelegatedRow(int row)
return sortedIndicies [row];
|
public int | getRowCount()
return delegatedModel.getRowCount();
|
public int | getSortColumn()
return sortColumn;
|
public java.lang.Object | getValueAt(int rowIndex, int columnIndex)
return delegatedModel.getValueAt (getDelegatedRow(rowIndex),
columnIndex);
|
public boolean | isCellEditable(int rowIndex, int columnIndex)
return delegatedModel.isCellEditable (rowIndex, columnIndex);
|
public void | removeTableModelListener(javax.swing.event.TableModelListener l)
listenerList.remove (TableModelListener.class, l);
|
protected void | resort()called to rebuild the delegate-to-sortable mapping
// does sortedIndicies need to grow or shrink?
if (sortedIndicies.length != delegatedModel.getRowCount()) {
sortedIndicies = new int [delegatedModel.getRowCount()];
}
// build up a list of SortingDelegates
ArrayList sortMe = new ArrayList();
for (int i=0; i<delegatedModel.getRowCount(); i++) {
SortingDelegate sd =
new SortingDelegate (delegatedModel.getValueAt(i, getSortColumn()),
i);
sortMe.add (sd);
}
// now sort him with the SortingDelegateComparator
SortingDelegateComparator sdc =
new SortingDelegateComparator (comparator);
Collections.sort (sortMe, sdc);
// fill sortedIndicies array
// index -> value represents mapping from original
// row to sorted row
for (int i=0; i<sortMe.size(); i++) {
sortedIndicies[i] =
((SortingDelegate) sortMe.get(i)).row;
}
// fire change event
fireAllChanged();
|
public void | setComparatorForColumn(java.util.Comparator c, int i)
// range check
if (i > comparators.length) {
Comparator[] newComparators = new Comparator[i+1];
System.arraycopy (comparators, 0,
newComparators, 0,
comparators.length);
comparators = newComparators;
}
// add the comparator
comparators[i] = c;
|
public void | setSortColumn(int i)
sortColumn = i;
// reset current comparator, possibly to null, which
// will make us use "natural ordering" for those values
comparator = null;
if ((comparators != null) &&
(comparators.length > 0))
// is there one in the list of comparators?
comparator = comparators[sortColumn];
// now do the sort
resort();
|
public void | setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
delegatedModel.setValueAt (aValue, rowIndex, columnIndex);
|
public void | tableChanged(javax.swing.event.TableModelEvent e)
switch (e.getType()) {
case TableModelEvent.DELETE: {
resort();
fireAllChanged();
break;
}
case TableModelEvent.INSERT: {
resort();
fireAllChanged();
break;
}
case TableModelEvent.UPDATE: {
resort();
fireAllChanged();
break;
}
}
|