@Override public void addSelectionInterval(int index0, int index1) { boolean adjusting = getValueIsAdjusting(); setValueIsAdjusting(true); try { if (!selectAll(index0, index1)) { super.addSelectionInterval(index0, index1); selectAllIf(); } } finally { setValueIsAdjusting(adjusting); } }
@Override public void setSelectionInterval(int index0, int index1) { boolean adjusting = getValueIsAdjusting(); setValueIsAdjusting(true); try { if (!selectAll(index0, index1)) { super.setSelectionInterval(index0, index1); selectAllIf(); } } finally { setValueIsAdjusting(adjusting); } }
@Override public void removeSelectionInterval(int index0, int index1) { boolean adjusting = getValueIsAdjusting(); setValueIsAdjusting(true); try { if (!unselectAll(index0, index1)) { if (getAllEntryIndex() >= 0) { super.removeSelectionInterval(getAllEntryIndex(), getAllEntryIndex()); } super.removeSelectionInterval(index0, index1); } } finally { setValueIsAdjusting(adjusting); } } }
protected void toggleSelections() { int[] indices = _list.getSelectedIndices(); CheckBoxListSelectionModel selectionModel = _list.getCheckBoxListSelectionModel(); selectionModel.removeListSelectionListener(this); selectionModel.setValueIsAdjusting(true); try { if (indices.length > 0) { boolean selected = selectionModel.isSelectedIndex(indices[0]); for (int index : indices) { if (!_list.isCheckBoxEnabled(index)) { continue; } if (selected && selectionModel.isSelectedIndex(index)) { selectionModel.removeSelectionInterval(index, index); } else if (!selected && !selectionModel.isSelectedIndex(index)) { selectionModel.addSelectionInterval(index, index); } } } } finally { selectionModel.setValueIsAdjusting(false); selectionModel.addListSelectionListener(this); _list.repaint(); } }