/** * This method will handle the selection change, if just one row has been selected on this records * creation.<br> */ private void applySingleSelection() { affected.getSelectionModel().setValueIsAdjusting(true); affected.getSelectionModel().clearSelection(); File searchFor = (File) selectedFiles.get(0); for (int i = 0; i < model.getRowCount(); i++) { if (model.getFileAt(sorter.modelIndex(i)).equals(searchFor)) { int newIndex = -1; if (i <= singleFileIndex) { newIndex = singleFileIndex + 1; if (newIndex >= model.getRowCount()) { newIndex = model.getRowCount() - 1; } } else { newIndex = singleFileIndex; } affected.changeSelection(newIndex, 0, false, false); break; } } affected.getSelectionModel().setValueIsAdjusting(false); }
/** This method will select all objects in {@link #selectedFiles}.<br> */ private void handleMulitpleSelection() { HashSet fileSet = new HashSet(selectedFiles); affected.getSelectionModel().setValueIsAdjusting(true); affected.getSelectionModel().clearSelection(); for (int i = 0; !fileSet.isEmpty() && i < model.getRowCount(); i++) { File current = model.getFileAt(sorter.modelIndex(i)); if (fileSet.contains(current)) { fileSet.remove(current); affected.getSelectionModel().addSelectionInterval(i, i); } } affected.getSelectionModel().setValueIsAdjusting(false); }