/** Sorts the data. * * @param cmpr the comparator. * @param ascending whether to sort in the ascending order. * It is ignored since this implementation uses cmprt to compare. */ public void sort(Comparator<E> cmpr, final boolean ascending) { _sorting = cmpr; _sortDir = ascending; Collections.sort(_list, cmpr); fireEvent(ListDataEvent.STRUCTURE_CHANGED, -1, -1); }
public E set(int index, E element) { E ret = _list.set(index, element); fireEvent(ListDataEvent.CONTENTS_CHANGED, index, index); return ret; }
public void add(int index, E element) { _list.add(index, element); fireEvent(ListDataEvent.INTERVAL_ADDED, index, index); }
/** * Notifies a change of the same element to trigger an event of {@link ListDataEvent#CONTENTS_CHANGED}. * @param element * @return true if the element exists * @since 8.0.0 */ public boolean notifyChange(E element) { int i = _list.indexOf(element); if (i >= 0) { fireEvent(ListDataEvent.CONTENTS_CHANGED, i, i); return true; } return false; }
public boolean add(E o) { int i1 = _list.size(); boolean ret = _list.add(o); fireEvent(ListDataEvent.INTERVAL_ADDED, i1, i1); return ret; }
public void set(E arg0) { _it.set(arg0); final int index = _it.nextIndex() - 1; fireEvent(ListDataEvent.CONTENTS_CHANGED, index, index); } };
public void add(E arg0) { final int index = _it.nextIndex(); _it.add(arg0); fireEvent(ListDataEvent.INTERVAL_ADDED, index, index); }
public boolean addAll(int index, Collection<? extends E> c) { int sz = c.size(); if (sz <= 0) { return false; } int i2 = index + sz - 1; boolean ret = _list.addAll(index, c); fireEvent(ListDataEvent.INTERVAL_ADDED, index, i2); return ret; }
public boolean addAll(Collection<? extends E> c) { int sz = c.size(); if (sz <= 0) { return false; } int i1 = _list.size(); int i2 = i1 + sz - 1; boolean ret = _list.addAll(c); fireEvent(ListDataEvent.INTERVAL_ADDED, i1, i2); return ret; }
public void clear() { int i2 = _list.size() - 1; if (i2 < 0) { return; } clearSelection(); _list.clear(); fireEvent(ListDataEvent.INTERVAL_REMOVED, 0, i2); }
public void remove() { removeFromSelection(_current); _it.remove(); final int index = _it.nextIndex(); fireEvent(ListDataEvent.INTERVAL_REMOVED, index, index); }
public E remove(int index) { E ret = _list.get(index); removeFromSelection(ret); //Bug ZK-1428: should remove the object after removeFromSelection //since Listbox.doSelectionChanged will try to get the object again _list.remove(index); fireEvent(ListDataEvent.INTERVAL_REMOVED, index, index); return ret; }
public void remove() { removeFromSelection(_current); _it.remove(); --_nextIndex; fireEvent(ListDataEvent.INTERVAL_REMOVED, _nextIndex, _nextIndex); } };
protected void fireSelectionEvent(E e) { fireEvent(ListDataEvent.SELECTION_CHANGED, indexOf(e), -1); }
/** * Remove from fromIndex(inclusive) to toIndex(exclusive). If fromIndex equals toIndex, * this methods do nothing. * @param fromIndex the begin index (inclusive) to be removed. * @param toIndex the end index (exclusive) to be removed. */ public void removeRange(int fromIndex, int toIndex) { if (fromIndex > toIndex) { throw new UiException( "fromIndex must less than toIndex: fromIndex: " + fromIndex + ", toIndex: " + toIndex); } if (fromIndex == toIndex) { return; } int sz = _list.size(); if (sz == fromIndex) { return; } int index = fromIndex; //B70-ZK-2447 : IndexOutOfBound exception occurs when using ListModelList.removeRange(0, size) with all items selected Set<E> removedObjs = new HashSet<E>(); for (final Iterator<E> it = _list.listIterator(fromIndex); it.hasNext() && index < toIndex; ++index) { final E obj = it.next(); removedObjs.add(obj); it.remove(); } fireEvent(ListDataEvent.INTERVAL_REMOVED, fromIndex, index - 1); for (E obj : removedObjs) removeFromSelection(obj); }