private boolean unselectAll(int index0, int index1) { if (getAllEntryIndex() < 0) { return false; } if (index0 == getAllEntryIndex() || index1 == getAllEntryIndex()) { clearSelection(); return true; } else { return false; } }
@Override public int getMinSelectionIndex() { int index = super.getMinSelectionIndex(); if (getAllEntryIndex() < 0) { return index; } if (super.isSelectedIndex(getAllEntryIndex()) && getAllEntryIndex() == 0) { return 1; } return index; }
private void selectAllIf() { if (getAllEntryIndex() < 0) { return; } for (int i = getModel().getSize() - 1; i >= 0; i--) { if (i != getAllEntryIndex() && !isSelectedIndex(i)) { return; } } super.addSelectionInterval(getAllEntryIndex(), getAllEntryIndex()); }
@Override public boolean isSelectedIndex(int index) { boolean selected = super.isSelectedIndex(index); return selected || (getAllEntryIndex() >= 0 && super.isSelectedIndex(getAllEntryIndex())); }
private boolean selectAll(int index0, int index1) { if (getAllEntryIndex() < 0) { return false; } if ((index0 == 0 && index1 == getModel().getSize() - 1) || (index1 == 0 && index0 == getModel().getSize() - 1)) { return false; } if ((index0 >= getAllEntryIndex() && index1 <= getAllEntryIndex()) || (index1 >= getAllEntryIndex() && index0 <= getAllEntryIndex())) { setSelectionInterval(0, getModel().getSize() - 1); return true; } else { return false; } }
@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); } } }
int n = 0; for (int i = iMin; i <= iMax; i++) { if (listSelectionModel.isAllEntryConsidered() && i == listSelectionModel.getAllEntryIndex()) { continue;
/** * Returns an array of all of the selected indices in increasing order. * * @return all of the selected indices, in increasing order * @see #removeSelectionInterval * @see #addListSelectionListener */ public int[] getCheckBoxListSelectedIndices() { CheckBoxListSelectionModel listSelectionModel = getCheckBoxListSelectionModel(); int iMin = listSelectionModel.getMinSelectionIndex(); int iMax = listSelectionModel.getMaxSelectionIndex(); if ((iMin < 0) || (iMax < 0)) { return new int[0]; } int[] temp = new int[1 + (iMax - iMin)]; int n = 0; for (int i = iMin; i <= iMax; i++) { if (listSelectionModel.isAllEntryConsidered() && i == listSelectionModel.getAllEntryIndex()) { continue; } if (listSelectionModel.isSelectedIndex(i)) { temp[n] = i; n++; } } int[] indices = new int[n]; System.arraycopy(temp, 0, indices, 0, n); return indices; }