@Override public void intervalRemoved(ListDataEvent e) { if (isAllEntryConsidered()) { _allEntryIndex = findAllEntryIndex(); } }
@Override public void intervalAdded(ListDataEvent e) { if (isAllEntryConsidered()) { _allEntryIndex = findAllEntryIndex(); } }
@Override public void contentsChanged(ListDataEvent e) { if (isAllEntryConsidered()) { _allEntryIndex = findAllEntryIndex(); } }
public CheckBoxListSelectionModel(ListModel model) { _model = model; if (isAllEntryConsidered()) { _allEntryIndex = findAllEntryIndex(); _model.addListDataListener(this); } setSelectionMode(MULTIPLE_INTERVAL_SELECTION); }
public void setModel(ListModel model) { int oldLength = 0; int newLength = 0; if (_model != null) { oldLength = _model.getSize(); _model.removeListDataListener(this); } _model = model; if (_model != null) { newLength = _model.getSize(); _model.removeListDataListener(this); if (isAllEntryConsidered()) { _model.addListDataListener(this); _allEntryIndex = findAllEntryIndex(); } else if (!_allEntryIndexSet) { _allEntryIndex = -1; } } if (oldLength > newLength) { removeIndexInterval(newLength, oldLength); } }
/** * Sets the flag indicating if this CheckBoxListSelectionModel should consider the CheckBoxList.ALL item if there is one. * <p/> * By default, the flag is true. If you want to improve the performance and don't have "all" entry, or if you do have * an entry similar to "all" entry but want to treat it as a normal entry, please set it to false. * * @param allEntryConsidered the flag * @since 3.3.3 */ public void setAllEntryConsidered(boolean allEntryConsidered) { _allEntryConsidered = allEntryConsidered; if (_model != null) { _model.removeListDataListener(this); } if (isAllEntryConsidered()) { _allEntryIndex = findAllEntryIndex(); if (_model != null) { _model.addListDataListener(this); } } else { _allEntryIndex = -1; } }
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; }