javax.swing.event.TableModelEvent#HEADER_ROW源码实例Demo

下面列出了javax.swing.event.TableModelEvent#HEADER_ROW 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: EventBroadcaster.java
private static String tableModelEventToString (TableModelEvent e) {
    StringBuilder sb = new StringBuilder();
    sb.append ("TableModelEvent ");
    switch (e.getType()) {
        case TableModelEvent.INSERT : sb.append ("insert ");
             break;
        case TableModelEvent.DELETE : sb.append ("delete ");
             break;
        case TableModelEvent.UPDATE : sb.append ("update ");
             break;
        default : sb.append("Unknown type ").append(e.getType());
    }
    sb.append ("from ");
    switch (e.getFirstRow()) {
        case TableModelEvent.HEADER_ROW : sb.append ("header row ");
            break;
        default : sb.append (e.getFirstRow());
                  sb.append (' ');
    }
    sb.append ("to ");
    sb.append (e.getLastRow());
    sb.append (" column ");
    switch (e.getColumn()) {
        case TableModelEvent.ALL_COLUMNS :
            sb.append ("ALL_COLUMNS");
            break;
        default : sb.append (e.getColumn());
    }
    return sb.toString();
}
 
源代码2 项目: nmonvisualizer   文件: ScrollingTableFix.java
@Override
public void tableChanged(TableModelEvent e) {
    if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        if (scrollPane.getViewport().getWidth() < table.getPreferredSize().getWidth()) {
            table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        }
        else {
            table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
        }
    }
}
 
源代码3 项目: gate-core   文件: XJTable.java
/**
 * Overridden for efficiency reasons (provides a better calculation of the 
 * dirty region). See 
 * <a href="http://www.objectdefinitions.com/odblog/2009/jtable-setrowheight-causes-slow-repainting/">this page</a>
 * for a more complete discussion. 
 */
@Override
public void tableChanged(TableModelEvent e) {
  //if just an update, and not a data or structure changed event or an insert or delete, use the fixed row update handling
  //otherwise call super.tableChanged to let the standard JTable update handling manage it
  if ( e != null &&
      e.getType() == TableModelEvent.UPDATE &&
      e.getFirstRow() != TableModelEvent.HEADER_ROW &&
      e.getLastRow() != Integer.MAX_VALUE) {
      handleRowUpdate(e);
  } else {
      super.tableChanged(e);
  }
}
 
源代码4 项目: pentaho-reporting   文件: JoiningTableModel.java
/**
 * This fine grain notification tells listeners the exact range of cells, rows, or columns that changed.
 */
public void tableChanged( final TableModelEvent e ) {
  if ( e.getType() == TableModelEvent.UPDATE && e.getFirstRow() == TableModelEvent.HEADER_ROW ) {
    updateStructure();
  } else if ( e.getType() == TableModelEvent.INSERT || e.getType() == TableModelEvent.DELETE ) {
    updateRowCount();
  } else {
    updateData();
  }
}
 
public void updateRowHeights(TableModelEvent e) {
    final int first;
    final int last;
    if (e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        first = 0;
        last = this.getTable().getRowCount();
    } else {
        first = e.getFirstRow();
        last = e.getLastRow() + 1;
    }

    SwingUtilities.invokeLater(() -> {
        updateRowHeights(first, last);
    });
}
 
源代码6 项目: WorldPainter   文件: MixedMaterialTableModel.java
public void setMode(Mode mode) {
    if (mode != this.mode) {
        this.mode = mode;
        TableModelEvent event = new TableModelEvent(this, TableModelEvent.HEADER_ROW);
        fireEvent(event);
    }
}
 
源代码7 项目: marathonv5   文件: TableSorter.java
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;
}
 
源代码8 项目: netbeans   文件: TableSorter.java
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;
}
 
源代码9 项目: netbeans   文件: TableSorter.java
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();
}
 
源代码10 项目: netbeans   文件: TableSorter.java
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 event is known to be preserving the sorting or 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, 
    //
    // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
    int column = e.getColumn();
    if ((e instanceof SortingSafeTableModelEvent)
            || e.getFirstRow() == e.getLastRow()
               && column != TableModelEvent.ALL_COLUMNS
               && getSortingStatus(column) == NOT_SORTED) {
        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();
}
 
源代码11 项目: netbeans   文件: ResultSetJXTable.java
@Override
public void tableChanged(TableModelEvent e) {
    if(e.getFirstRow() == TableModelEvent.HEADER_ROW) {
        updateHeader();
    }
}
 
源代码12 项目: cropplanning   文件: TableSorter.java
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;
}
 
源代码13 项目: evosql   文件: TableSorter.java
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;
        }
 
源代码14 项目: tda   文件: TableSorter.java
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;
}
 
@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();
	if (e.getFirstRow() == e.getLastRow() && column != TableModelEvent.ALL_COLUMNS
			&& getSortingStatus(column) == NOT_SORTED && modelToView != null) {
		int viewIndex = getModelToView()[e.getFirstRow()];
		fireTableChanged(new TableModelEvent(ExtendedJTableSorterModel.this, viewIndex, viewIndex, column,
				e.getType()));
		return;
	}

	// Something has happened to the data that may have invalidated the row order.
	clearSortingState();
	fireTableDataChanged();
	return;
}
 
源代码16 项目: beast-mcmc   文件: TableSorter.java
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;
}
 
源代码17 项目: beast-mcmc   文件: TableSorter.java
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();
}
 
源代码18 项目: java-swing-tips   文件: TableSorter.java
@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;
}
 
源代码19 项目: jplag   文件: TableSorter.java
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;
}
 
源代码20 项目: wandora   文件: SimpleTable.java
/**
 * Convenience method to detect a structureChanged table event type.
 * @param e the event to examine.
 * @return true if the event is of type structureChanged or null, false else.
 */
protected boolean isStructureChanged(TableModelEvent e) {
    return e == null || e.getFirstRow() == TableModelEvent.HEADER_ROW;
}