/** * Restores the selection after a model event/sort order changes. * All coordinates are in terms of the model. */ private void restoreSortingSelection(int[] selection, int lead, ModelChange change) { // Convert the selection from model to view for (int i = selection.length - 1; i >= 0; i--) { selection[i] = convertRowIndexToView(change, selection[i]); } lead = convertRowIndexToView(change, lead); // Check for the common case of no change in selection for 1 row if (selection.length == 0 || (selection.length == 1 && selection[0] == list.getSelectedIndex())) { return; } ListSelectionModel selectionModel = getViewSelectionModel(); // And apply the new selection selectionModel.setValueIsAdjusting(true); selectionModel.clearSelection(); for (int i = selection.length - 1; i >= 0; i--) { if (selection[i] != -1) { selectionModel.addSelectionInterval(selection[i], selection[i]); } } SwingXUtilities.setLeadAnchorWithoutSelection( selectionModel, lead, lead); selectionModel.setValueIsAdjusting(false); }
/** * Restores the selection after a model event/sort order changes. * All coordinates are in terms of the model. */ private void restoreSortingSelection(int[] selection, int lead, ModelChange change) { // Convert the selection from model to view for (int i = selection.length - 1; i >= 0; i--) { selection[i] = convertRowIndexToView(change, selection[i]); } lead = convertRowIndexToView(change, lead); // Check for the common case of no change in selection for 1 row if (selection.length == 0 || (selection.length == 1 && selection[0] == list.getSelectedIndex())) { return; } ListSelectionModel selectionModel = getViewSelectionModel(); // And apply the new selection selectionModel.setValueIsAdjusting(true); selectionModel.clearSelection(); for (int i = selection.length - 1; i >= 0; i--) { if (selection[i] != -1) { selectionModel.addSelectionInterval(selection[i], selection[i]); } } SwingXUtilities.setLeadAnchorWithoutSelection( selectionModel, lead, lead); selectionModel.setValueIsAdjusting(false); }
/** * Restores the selection after a model event/sort order changes. * All coordinates are in terms of the model. */ private void restoreSortingSelection(int[] selection, int lead, ModelChange change) { // Convert the selection from model to view for (int i = selection.length - 1; i >= 0; i--) { selection[i] = convertRowIndexToView(change, selection[i]); } lead = convertRowIndexToView(change, lead); // Check for the common case of no change in selection for 1 row if (selection.length == 0 || (selection.length == 1 && selection[0] == list.getSelectedIndex())) { return; } ListSelectionModel selectionModel = getViewSelectionModel(); // And apply the new selection selectionModel.setValueIsAdjusting(true); selectionModel.clearSelection(); for (int i = selection.length - 1; i >= 0; i--) { if (selection[i] != -1) { selectionModel.addSelectionInterval(selection[i], selection[i]); } } SwingXUtilities.setLeadAnchorWithoutSelection( selectionModel, lead, lead); selectionModel.setValueIsAdjusting(false); }
/** * Restores the selection after a model event/sort order changes. * All coordinates are in terms of the model. */ private void restoreSortingSelection(int[] selection, int lead, ModelChange change) { // Convert the selection from model to view for (int i = selection.length - 1; i >= 0; i--) { selection[i] = convertRowIndexToView(change, selection[i]); } lead = convertRowIndexToView(change, lead); // Check for the common case of no change in selection for 1 row if (selection.length == 0 || (selection.length == 1 && selection[0] == list.getSelectedIndex())) { return; } ListSelectionModel selectionModel = getViewSelectionModel(); // And apply the new selection selectionModel.setValueIsAdjusting(true); selectionModel.clearSelection(); for (int i = selection.length - 1; i >= 0; i--) { if (selection[i] != -1) { selectionModel.addSelectionInterval(selection[i], selection[i]); } } SwingXUtilities.setLeadAnchorWithoutSelection( selectionModel, lead, lead); selectionModel.setValueIsAdjusting(false); }