public void remove() { owner.removing(current); wrapped.remove(); }
/** * Removes the item at the given index * * @param index the index of the item to remove * @return the removed item * @throws IndexOutOfBoundsException if there is no item at the given index */ public Item removeItem(int index) { Item item = subitems.remove(index); removing(item); return item; }
/** * Removes the given item. Does nothing if the item is not present. * * @param item the item to remove * @return whether the item was removed */ public boolean removeItem(Item item) { boolean removed = subitems.remove(item); if (removed) { removing(item); } return removed; }
public void set(Item o) { Item newItem = o; owner.removing(current); owner.adding(newItem); current = newItem; wrapped.set(newItem); }
/** * Replaces the item at the given index * * @param index the (0-base) index of the item to replace * @param item the new item * @return the old item at this position. The parent of the old item is <i>not</i> cleared * @throws IndexOutOfBoundsException if there is no item at this index */ public Item setItem(int index, Item item) { if (index >= subitems.size() || index < 0) throw new IndexOutOfBoundsException("Could not add a subitem at position " + index + " to " + this); adding(item); Item old = subitems.set(index, item); if (old!=item) removing(old); return old; }