Java Code Examples for javax.swing.event.TableModelEvent#ALL_COLUMNS

The following examples show how to use javax.swing.event.TableModelEvent#ALL_COLUMNS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WrappingTableModel.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * This fine grain notification tells listeners the exact range of cells, rows, or columns that changed. The
 * received rows are translated to fit the external tablemodel size.
 *
 * @param e the event, that should be translated.
 */
public void tableChanged(final TableModelEvent e)
{
  // inefficient, but necessary ...
  final int columnIndex = TableModelEvent.ALL_COLUMNS;

  final int firstRow = e.getFirstRow();
  final int lastRow = e.getLastRow();

  final int firstRowIndex = (firstRow / 2);
  final int lastRowIndex = (lastRow / 2);

  final TableModelEvent event =
      new TableModelEvent(WrappingTableModel.this, firstRowIndex, lastRowIndex,
          columnIndex, e.getType());

  for (int i = 0; i < listeners.size(); i++)
  {
    final TableModelListener l = (TableModelListener) listeners.get(i);
    l.tableChanged(event);
  }

}
 
Example 2
Source File: AbstractSortedTableModel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Fires an event to let the listeners (like JTable) know that things have been changed. 
 * This method exists so that subclasses have a way to call the various <code>tableChanged()</code>
 * methods without triggering this class's overridden version.
 * @param dataChanged True signals that the actual data has changed; false signals that the
 *        data is the same, with exception that attributes of that data may be different.
 */
protected void notifyModelSorted(boolean dataChanged) {
	if (dataChanged) {
		super.fireTableChanged(new TableModelEvent(this));
	}
	else {
		super.fireTableChanged(new TableModelEvent(this, 0, getRowCount() - 1,
			TableModelEvent.ALL_COLUMNS, TableModelEvent.UPDATE));
	}

	for (SortListener listener : listeners) {
		listener.modelSorted(sortState);
	}
}
 
Example 3
Source File: CombinedLayerTableModel.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
void deleteRow(int rowIndex) {
    rows.remove(rowIndex);
    TableModelEvent event = new TableModelEvent(this, rowIndex, rowIndex, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);
    for (TableModelListener listener: listeners) {
        listener.tableChanged(event);
    }
}
 
Example 4
Source File: MonitorMessageTableModel.java    From USBtinViewer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Clear the message list
 */
public void clear() {
    
    if (messages.size() == 0) return;        
    int lastRow = messages.size() - 1;

    messages.clear();

    TableModelEvent e = new TableModelEvent(this, 0, lastRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);
    for (int i = 0, n = listeners.size(); i < n; i++) {
        listeners.get(i).tableChanged(e);
    }
}
 
Example 5
Source File: LogMessageTableModel.java    From USBtinViewer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Clear the message list
 */
public void clear() {
    
    if (messages.size() == 0) return;
    int lastRow = messages.size() - 1;

    messages.clear();

    TableModelEvent e = new TableModelEvent(this, 0, lastRow, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);
    for (int i = 0, n = listeners.size(); i < n; i++) {
        listeners.get(i).tableChanged(e);
    }
}
 
Example 6
Source File: TunnelFloorLayersTableModel.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
public void addLayer(Layer layer) {
    if (! layers.contains(layer)) {
        layers.add(layer);
        settings.put(layer, new TunnelLayer.LayerSettings());
        int row = layers.size() - 1;
        TableModelEvent event = new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
        for (TableModelListener listener: listeners) {
            listener.tableChanged(event);
        }
    }
}
 
Example 7
Source File: CombinedLayerTableModel.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
void addRow(Row row) {
    rows.add(row);
    TableModelEvent event = new TableModelEvent(this, rows.size() - 1, rows.size() - 1, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
    for (TableModelListener listener: listeners) {
        listener.tableChanged(event);
    }
}
 
Example 8
Source File: LayerRangesTableModel.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
public void addRow(Filter filter, Layer layer) {
    filters.add(filter);
    layers.add(layer);
    int index = filters.size() - 1;
    TableModelEvent event = new TableModelEvent(this, index, index, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT);
    listeners.forEach(listener -> listener.tableChanged(event));
}
 
Example 9
Source File: TerrainRangesTableModel.java    From WorldPainter with GNU General Public License v3.0 5 votes vote down vote up
public void deleteRow(int row) {
    System.arraycopy(levels, row + 1, levels, row, rows - 1 - row);
    System.arraycopy(terrains, row + 1, terrains, row, rows - 1 - row);
    rows--;
    TableModelEvent event = new TableModelEvent(this, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE);
    for (TableModelListener listener: listeners) {
        listener.tableChanged(event);
    }
    notifyChangeListener();
}
 
Example 10
Source File: TableSorter.java    From jplag with GNU General Public License v3.0 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
    // If we're not sorting by anything, just pass the event along.             
    if (!isSorting()) {
        clearSortingState();
        fireTableChanged(e);
        return;
    }
        
    // If the table structure has changed, cancel the sorting; the             
    // sorting columns may have been either moved or deleted from             
    // the model. 
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        cancelSorting();
        fireTableChanged(e);
        return;
    }

    // We can map a cell event through to the view without widening             
    // when the following conditions apply: 
    // 
    // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and, 
    // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
    // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and, 
    // d) a reverse lookup will not trigger a sort (modelToView != null)
    //
    // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
    // 
    // The last check, for (modelToView != null) is to see if modelToView 
    // is already allocated. If we don't do this check; sorting can become 
    // a performance bottleneck for applications where cells  
    // change rapidly in different parts of the table. If cells 
    // change alternately in the sorting column and then outside of             
    // it this class can end up re-sorting on alternate cell updates - 
    // which can be a performance problem for large tables. The last 
    // clause avoids this problem. 
    int column = e.getColumn();
    if (e.getFirstRow() == e.getLastRow()
            && column != TableModelEvent.ALL_COLUMNS
            && getSortingStatus(column) == NOT_SORTED
            && modelToView != null) {
        int viewIndex = getModelToView()[e.getFirstRow()];
        fireTableChanged(new TableModelEvent(TableSorter.this, 
                                             viewIndex, viewIndex, 
                                             column, e.getType()));
        return;
    }

    // Something has happened to the data that may have invalidated the row order. 
    clearSortingState();
    fireTableDataChanged();
    return;
}
 
Example 11
Source File: AdminTool.java    From jplag with GNU General Public License v3.0 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
	if (e.getColumn() == TableModelEvent.ALL_COLUMNS)
		return;
	BackedUserData bud = getUserTableModel().getBackedUserData(e.getFirstRow());
	userDataChanged(bud);
}
 
Example 12
Source File: TableSorter.java    From cropplanning with GNU General Public License v3.0 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
    // If we're not sorting by anything, just pass the event along.             
    if (!isSorting()) {
        clearSortingState();
        fireTableChanged(e);
        return;
    }
        
    // If the table structure has changed, cancel the sorting; the             
    // sorting columns may have been either moved or deleted from             
    // the model. 
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        cancelSorting();
        fireTableChanged(e);
        return;
    }

    // We can map a cell event through to the view without widening             
    // when the following conditions apply: 
    // 
    // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and, 
    // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
    // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and, 
    // d) a reverse lookup will not trigger a sort (modelToView != null)
    //
    // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
    // 
    // The last check, for (modelToView != null) is to see if modelToView 
    // is already allocated. If we don't do this check; sorting can become 
    // a performance bottleneck for applications where cells  
    // change rapidly in different parts of the table. If cells 
    // change alternately in the sorting column and then outside of             
    // it this class can end up re-sorting on alternate cell updates - 
    // which can be a performance problem for large tables. The last 
    // clause avoids this problem. 
    int column = e.getColumn();
    if (e.getFirstRow() == e.getLastRow()
            && column != TableModelEvent.ALL_COLUMNS
            && getSortingStatus(column) == NOT_SORTED
            && modelToView != null) {
        int viewIndex = getModelToView()[e.getFirstRow()];
        fireTableChanged(new TableModelEvent(TableSorter.this, 
                                             viewIndex, viewIndex, 
                                             column, e.getType()));
        return;
    }

    // Something has happened to the data that may have invalidated the row order. 
    clearSortingState();
    fireTableDataChanged();
    return;
}
 
Example 13
Source File: TableSorter.java    From beast-mcmc with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
    // If we're not sorting by anything, just pass the event along.
    if (!isSorting()) {
        clearSortingState();
        fireTableChanged(e);
        return;
    }

    // If the table structure has changed, cancel the sorting; the
    // sorting columns may have been either moved or deleted from
    // the model.
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        cancelSorting();
        fireTableChanged(e);
        return;
    }

    // We can map a cell event through to the view without widening
    // when the following conditions apply:
    //
    // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
    // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
    // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
    // d) a reverse lookup will not trigger a sort (modelToView != null)
    //
    // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
    //
    // The last check, for (modelToView != null) is to see if modelToView
    // is already allocated. If we don't do this check; sorting can become
    // a performance bottleneck for applications where cells
    // change rapidly in different parts of the table. If cells
    // change alternately in the sorting column and then outside of
    // it this class can end up re-sorting on alternate cell updates -
    // which can be a performance problem for large tables. The last
    // clause avoids this problem.
    int column = e.getColumn();
    if (e.getFirstRow() == e.getLastRow()
            && column != TableModelEvent.ALL_COLUMNS
            && getSortingStatus(column) == NOT_SORTED
            && modelToView != null) {
        int viewIndex = getModelToView()[e.getFirstRow()];
        fireTableChanged(new TableModelEvent(TableSorter.this,
                                             viewIndex, viewIndex,
                                             column, e.getType()));
        return;
    }

    // Something has happened to the data that may have invalidated the row order.
    clearSortingState();
    fireTableDataChanged();
    return;
}
 
Example 14
Source File: TableSorter.java    From java-swing-tips with MIT License 4 votes vote down vote up
@Override public void tableChanged(TableModelEvent e) {
  // If we're not sorting by anything, just pass the event along.
  if (!isSorting()) {
    clearSortingState();
    fireTableChanged(e);
    return;
  }

  // If the table structure has changed, cancel the sorting; the
  // sorting columns may have been either moved or deleted from
  // the model.
  if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
    cancelSorting();
    fireTableChanged(e);
    return;
  }

  // We can map a cell event through to the view without widening
  // when the following conditions apply:
  //
  // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
  // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
  // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
  // d) a reverse lookup will not trigger a sort (modelToView != null)
  //
  // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
  //
  // The last check, for (modelToView != null) is to see if modelToView
  // is already allocated. If we don't do this check; sorting can become
  // a performance bottleneck for applications where cells
  // change rapidly in different parts of the table. If cells
  // change alternately in the sorting column and then outside of
  // it this class can end up re-sorting on alternate cell updates -
  // which can be a performance problem for large tables. The last
  // clause avoids this problem.
  int column = e.getColumn();
  int fr = e.getFirstRow();
  int lr = e.getLastRow();
  if (fr == lr && column != TableModelEvent.ALL_COLUMNS && getSortingStatus(column) == NOT_SORTED) {
    int viewIndex = getModelToView().get(fr);
    fireTableChanged(new TableModelEvent(TableSorter.this, viewIndex, viewIndex, column, e.getType()));
    return;
  }

  // Something has happened to the data that may have invalidated the row order.
  clearSortingState();
  fireTableDataChanged();
  // return;
}
 
Example 15
Source File: TableSorter.java    From tda with GNU Lesser General Public License v2.1 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
    // If we're not sorting by anything, just pass the event along.             
    if (!isSorting()) {
        clearSortingState();
        fireTableChanged(e);
        return;
    }
        
    // If the table structure has changed, cancel the sorting; the             
    // sorting columns may have been either moved or deleted from             
    // the model. 
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        cancelSorting();
        fireTableChanged(e);
        return;
    }

    // We can map a cell event through to the view without widening             
    // when the following conditions apply: 
    // 
    // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and, 
    // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
    // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and, 
    // d) a reverse lookup will not trigger a sort (modelToView != null)
    //
    // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
    // 
    // The last check, for (modelToView != null) is to see if modelToView 
    // is already allocated. If we don't do this check; sorting can become 
    // a performance bottleneck for applications where cells  
    // change rapidly in different parts of the table. If cells 
    // change alternately in the sorting column and then outside of             
    // it this class can end up re-sorting on alternate cell updates - 
    // which can be a performance problem for large tables. The last 
    // clause avoids this problem. 
    int column = e.getColumn();
    if (e.getFirstRow() == e.getLastRow()
            && column != TableModelEvent.ALL_COLUMNS
            && getSortingStatus(column) == NOT_SORTED
            && modelToView != null) {
        int viewIndex = getModelToView()[e.getFirstRow()];
        fireTableChanged(new TableModelEvent(TableSorter.this, 
                                             viewIndex, viewIndex, 
                                             column, e.getType()));
        return;
    }

    // Something has happened to the data that may have invalidated the row order. 
    clearSortingState();
    fireTableDataChanged();
    return;
}
 
Example 16
Source File: TableSorter.java    From evosql with Apache License 2.0 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {

            // If we're not sorting by anything, just pass the event along.
            if (!isSorting()) {
                clearSortingState();
                fireTableChanged(e);

                return;
            }

            // If the table structure has changed, cancel the sorting; the
            // sorting columns may have been either moved or deleted from
            // the model.
            if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                cancelSorting();
                fireTableChanged(e);

                return;
            }

            // We can map a cell event through to the view without widening
            // when the following conditions apply:
            //
            // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
            // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
            // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
            // d) a reverse lookup will not trigger a sort (modelToView != null)
            //
            // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
            //
            // The last check, for (modelToView != null) is to see if modelToView
            // is already allocated. If we don't do this check; sorting can become
            // a performance bottleneck for applications where cells
            // change rapidly in different parts of the table. If cells
            // change alternately in the sorting column and then outside of
            // it this class can end up re-sorting on alternate cell updates -
            // which can be a performance problem for large tables. The last
            // clause avoids this problem.
            int column = e.getColumn();

            if (e.getFirstRow() == e.getLastRow()
                    && column != TableModelEvent.ALL_COLUMNS
                    && getSortingStatus(column) == NOT_SORTED
                    && modelToView != null) {
                int viewIndex = getModelToView()[e.getFirstRow()];

                fireTableChanged(new TableModelEvent(TableSorter.this,
                                                     viewIndex, viewIndex,
                                                     column, e.getType()));

                return;
            }

            // Something has happened to the data that may have invalidated the row order.
            clearSortingState();
            fireTableDataChanged();

            return;
        }
 
Example 17
Source File: TableSorter.java    From java-swing-tips with MIT License 4 votes vote down vote up
@Override public void tableChanged(TableModelEvent e) {
  // If we're not sorting by anything, just pass the event along.
  if (!isSorting()) {
    clearSortingState();
    fireTableChanged(e);
    return;
  }

  // If the table structure has changed, cancel the sorting; the
  // sorting columns may have been either moved or deleted from
  // the model.
  if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
    cancelSorting();
    fireTableChanged(e);
    return;
  }

  // We can map a cell event through to the view without widening
  // when the following conditions apply:
  //
  // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
  // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
  // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
  // d) a reverse lookup will not trigger a sort (modelToView != null)
  //
  // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
  //
  // The last check, for (modelToView != null) is to see if modelToView
  // is already allocated. If we don't do this check; sorting can become
  // a performance bottleneck for applications where cells
  // change rapidly in different parts of the table. If cells
  // change alternately in the sorting column and then outside of
  // it this class can end up re-sorting on alternate cell updates -
  // which can be a performance problem for large tables. The last
  // clause avoids this problem.
  int column = e.getColumn();
  int fr = e.getFirstRow();
  int lr = e.getLastRow();
  if (fr == lr && column != TableModelEvent.ALL_COLUMNS && getSortingStatus(column) == NOT_SORTED) {
    int viewIndex = getModelToView().get(fr);
    fireTableChanged(new TableModelEvent(TableSorter.this, viewIndex, viewIndex, column, e.getType()));
    return;
  }

  // Something has happened to the data that may have invalidated the row order.
  clearSortingState();
  fireTableDataChanged();
  // return;
}
 
Example 18
Source File: TableSorter.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
    // If we're not sorting by anything, just pass the event along.             
    if (!isSorting()) {
        clearSortingState();
        fireTableChanged(e);
        return;
    }
    // If the table structure has changed, cancel the sorting; the             
    // sorting columns may have been either moved or deleted from             
    // the model. 
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        cancelSorting();
        fireTableChanged(e);
        return;
    }
    // We can map a cell event through to the view without widening             
    // when the following conditions apply: 
    // 
    // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and, 
    // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
    // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and, 
    // d) a reverse lookup will not trigger a sort (modelToView != null)
    //
    // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
    // 
    // The last check, for (modelToView != null) is to see if modelToView 
    // is already allocated. If we don't do this check; sorting can become 
    // a performance bottleneck for applications where cells  
    // change rapidly in different parts of the table. If cells 
    // change alternately in the sorting column and then outside of             
    // it this class can end up re-sorting on alternate cell updates - 
    // which can be a performance problem for large tables. The last 
    // clause avoids this problem. 
    int column = e.getColumn();
    if (e.getFirstRow() == e.getLastRow() && column != TableModelEvent.ALL_COLUMNS && getSortingStatus(column) == NOT_SORTED && modelToView != null) {
        int viewIndex = getModelToView()[e.getFirstRow()];
        fireTableChanged(new TableModelEvent(TableSorter.this,
                viewIndex, viewIndex,
                column, e.getType()));
        return;
    }
    // Something has happened to the data that may have invalidated the row order. 
    clearSortingState();
    fireTableDataChanged();
    return;
}
 
Example 19
Source File: EventBroadcaster.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Translates tree expansion event into an appropriate TableModelEvent
 * indicating the number of rows added/removed at the appropriate index */
private TableModelEvent translateEvent (TreeExpansionEvent e, boolean expand) {
    //PENDING:  This code should be profiled - the descendent paths search
    //is not cheap, and it might be less expensive (at least if the table
    //does not have expensive painting logic) to simply fire a generic
    //"something changed" table model event and be done with it.
    
    TreePath path = e.getPath();
    
    //Add one because it is a child of the row.
    int firstRow = getLayout().getRowForPath(path) + 1;
    if (firstRow == -1) {
        //This does not mean nothing happened, it may just be that we are
        //a large model tree, and the FixedHeightLayoutCache says the
        //change happened in a row that is not showing.
        
        //TODO:  Just to make the table scrollbar adjust itself appropriately,
        //we may want to look up the number of children in the model and
        //fire an event that says that that many rows were added.  Waiting
        //to see if anybody actually will use this (i.e. fires changes in
        //offscreen nodes as a normal part of usage
        return null;
    }
    
    //Get all the expanded descendants of the path that was expanded/collapsed
    TreePath[] paths = getTreePathSupport().getExpandedDescendants(path);
    
    //Start with the number of children of whatever was expanded/collapsed
    int count = getTreeModel().getChildCount(path.getLastPathComponent());
    
    if (count == 0) {
        return null;
    }
    
    //Iterate any of the expanded children, adding in their child counts
    for (int i=0; i < paths.length; i++) {
        count += getTreeModel().getChildCount(paths[i].getLastPathComponent());
    }
    
    //Now we can calculate the last row affected for real
    int lastRow = firstRow + count -1;
    
    //Construct a table model event reflecting this data
    TableModelEvent result = new TableModelEvent (getModel(), firstRow, lastRow, 
        TableModelEvent.ALL_COLUMNS, expand ? TableModelEvent.INSERT : 
        TableModelEvent.DELETE);
        
    return result;
}
 
Example 20
Source File: TableSorter.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public void tableChanged(TableModelEvent e) {
    // If we're not sorting by anything, just pass the event along.
    if (!isSorting()) {
        clearSortingState();
        fireTableChanged(e);
        return;
    }

    // If the table structure has changed, cancel the sorting; the
    // sorting columns may have been either moved or deleted from
    // the model.
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        cancelSorting();
        fireTableChanged(e);
        return;
    }

    // We can map a cell event through to the view without widening
    // when the following conditions apply:
    //
    // a) all the changes are on one row (e.getFirstRow() ==
    // e.getLastRow()) and,
    // b) all the changes are in one column (column !=
    // TableModelEvent.ALL_COLUMNS) and,
    // c) we are not sorting on that column (getSortingStatus(column) ==
    // NOT_SORTED) and,
    // d) a reverse lookup will not trigger a sort (modelToView != null)
    //
    // Note: INSERT and DELETE events fail this test as they have column
    // == ALL_COLUMNS.
    //
    // The last check, for (modelToView != null) is to see if
    // modelToView
    // is already allocated. If we don't do this check; sorting can
    // become
    // a performance bottleneck for applications where cells
    // change rapidly in different parts of the table. If cells
    // change alternately in the sorting column and then outside of
    // it this class can end up re-sorting on alternate cell updates -
    // which can be a performance problem for large tables. The last
    // clause avoids this problem.
    int column = e.getColumn();
    if (e.getFirstRow() == e.getLastRow() && column != TableModelEvent.ALL_COLUMNS && getSortingStatus(column) == NOT_SORTED
            && modelToView != null) {
        int viewIndex = getModelToView()[e.getFirstRow()];
        fireTableChanged(new TableModelEvent(TableSorter.this, viewIndex, viewIndex, column, e.getType()));
        return;
    }

    // Something has happened to the data that may have invalidated the
    // row order.
    clearSortingState();
    fireTableDataChanged();
    return;
}