use of de.jaret.util.ui.table.model.IRowSorter in project translationstudio8 by heartsome.
the class JaretTable method updateRowList.
/**
* Update the internal rowlist according to filter and sorter.
*
*/
private void updateRowList() {
_rows = new ArrayList<IRow>();
if (_model != null) {
for (int i = 0; i < _model.getRowCount(); i++) {
IRow row = _model.getRow(i);
if (i < _fixedRows) {
// fixed rows are exluded from filtering
_rows.add(row);
} else if (_rowFilter == null || (_rowFilter != null && _rowFilter.isInResult(row))) {
if (!_autoFilterEnabled || _autoFilter.isInResult(row)) {
if (!_rows.contains(row)) {
_rows.add(row);
}
}
}
}
}
// sort either by column sort order or by a set row sorter
RowComparator comparator = new RowComparator();
IRowSorter rs = null;
if (comparator.canSort()) {
rs = comparator;
} else {
rs = _rowSorter;
}
if (rs != null) {
List<IRow> fixedRows = new ArrayList<IRow>();
// the exclusion of the fixed rows may be solved more elegant ...
if (_excludeFixedRowsFromSorting) {
for (int i = 0; i < _fixedRows; i++) {
fixedRows.add(_rows.remove(0));
}
}
Collections.sort(_rows, rs);
if (_excludeFixedRowsFromSorting) {
for (int i = fixedRows.size() - 1; i >= 0; i--) {
_rows.add(0, fixedRows.get(i));
}
}
}
// to be sure no one misses this
updateYScrollBar();
}
use of de.jaret.util.ui.table.model.IRowSorter in project translationstudio8 by heartsome.
the class JaretTable method setRowSorter.
/**
* Set a row sorter. A row sorter will be overruled by sorting setup on columns.
*
* @param rowSorter The rowSorter to set.
*/
public void setRowSorter(IRowSorter rowSorter) {
IRowSorter oldValue = _rowSorter;
if (_rowSorter != null) {
_rowSorter.removePropertyChangeListener(this);
}
_rowSorter = rowSorter;
if (_rowSorter != null) {
_rowSorter.addPropertyChangeListener(this);
}
updateRowList();
redraw();
// fire the change for the sorter object
firePropertyChange(PROPERTYNAME_ROWSORTER, oldValue, _rowSorter);
// fire the general sorting change
firePropertyChange(PROPERTYNAME_SORTING, null, "x");
}
Aggregations