@Override public boolean first() throws SQLException { if(rowFilter == null || rowFilter.isEmpty()) { return moveCursorTo(1); } else { return moveCursorTo(rowFilter.first()); } }
@Override public void setFilter(Collection<Integer> rowIdSet) { if(rowIdSet != null) { rowFilter = new IntegerUnion(rowIdSet); rowFilterIterator = rowFilter.listIterator(); if(!rowFilter.isEmpty()) { rowId = rowFilter.first() - 1; } else { rowId = 0; } currentRow = null; } else { rowFilter = null; rowFilterIterator = null; } }
@Override public boolean last() throws SQLException { if(rowFilter == null || rowFilter.isEmpty()) { return moveCursorTo((int)getRowCount()); } else { return moveCursorTo(rowFilter.last()); } }
private boolean moveCursorTo(long i) throws SQLException { i = Math.max(0, i); i = Math.min(getRowCount() + 1, i); if(rowFilter != null && !rowFilter.isEmpty()) { i = Math.max(rowFilter.first() - 1, i); i = Math.min(rowFilter.last() + 1, i); rowId = rowFilterIterator.previous(); } else { if(!rowFilter.isEmpty()) { rowId = rowFilter.first(); } else { rowId = rowFilterIterator.next(); } else { if(!rowFilter.isEmpty()) { rowId = rowFilter.last() + 1; } else { rowId = i; boolean validRow = !(rowId == 0 || rowId > getRowCount() || (rowFilter != null && !rowFilter.isEmpty() && (rowId < rowFilter.first() || rowId > rowFilter.last()))); if(validRow) { refreshRowCache();
@Override public void run() { // Update the table values List<Integer> ranges = nextViewSelection.getValueRanges(); Iterator<Integer> intervals = ranges.iterator(); try { table.getSelectionModel().setValueIsAdjusting(true); table.clearSelection(); ProgressMonitor swingPm = pm.startTask("Apply filter", ranges.size()); while (intervals.hasNext()) { int begin = intervals.next(); int end = intervals.next(); table.addRowSelectionInterval(begin, end); swingPm.endTask(); if (swingPm.isCancelled()) { return; } } } finally { table.getSelectionModel().setValueIsAdjusting(false); } if(!nextViewSelection.isEmpty()) { scrollToRow(nextViewSelection.first(), table); } } });