@Override public boolean addAll(Collection<? extends BaseComponent> c) { return addAll(delegate.size(), c); }
@Override public ListIterator<BaseComponent> listIterator(int index) { ListIterator<BaseComponent> iter = listIterator(); while (iter.nextIndex() < index) { iter.next(); } return iter; }
@Override public void remove() { checkModCount(); Assert.state(fetched, "No element to remove"); fetched = false; ChildList.this.remove(--next); expected = modCount; }
oldParent.children.remove(child, true, false);
protected void remove(BaseComponent child, boolean noSync, boolean destroy) { if (child instanceof IComposite) { BaseComponent root = ((IComposite) child).getCompositeRoot(); BaseComponent parent = root == null ? null : root.getParent(); if (parent != null) { parent.children.remove(root, noSync, destroy); } child.parent = null; modCount++; } else { int index = indexOf(child); ComponentException.assertTrue(index != -1, parent, "Child does not belong to this parent"); parent.beforeRemoveChild(child); parent.nameIndex.remove(child); child.parent = null; delegate.remove(child); modCount++; if (!noSync) { parent.invokeIfAttached("removeChild", child, destroy); } child.dead |= destroy; parent.afterRemoveChild(child); } }
/** * Destroys this component. */ public void destroy() { if (dead) { return; } onDestroy(); if (page != null) { page.registerComponent(this, false); } destroyChildren(); if (parent != null) { parent.children.remove(this, false, true); } else { invokeIfAttached("destroy"); } dead = true; fireEvent(new Event("destroy", this)); eventListeners.removeAll(); }
/** * Adds a child to the child list immediately before the reference child. * * @param child Child to add. * @param before The reference child. */ public void addChild(BaseComponent child, BaseComponent before) { if (before == null) { children.add(-1, child); } else { ComponentException.assertTrue(before.getParent() == this, this, "Reference component does not belong to this parent"); int i = children.indexOf(before); children.add(i, child); } }
@Override public void clear() { clear(false); }
@Override public boolean remove(Object o) { remove((BaseComponent) o, false, false); return true; }
/** * Returns the index of this child within its parent. * * @return Index of this child within its parent. If the component has not parent, returns -1. */ public int getIndex() { return getParent() == null ? -1 : getParent().children.indexOf(this); }
@SuppressWarnings("unchecked") @Override public ListIterator<BaseComponent> listIterator() { return IteratorUtils.toListIterator(iterator()); }
@Override public boolean retainAll(Collection<?> c) { List<BaseComponent> remove = new ArrayList<>(delegate); remove.removeAll(c); return removeAll(remove); }
/** * Adds a child to the child list at the specified position. * * @param child Child to add. * @param index The position in the child list where the new child will be inserted. */ public void addChild(BaseComponent child, int index) { children.add(index, child); }
@Override public boolean addAll(int index, Collection<? extends BaseComponent> c) { for (BaseComponent child : c) { add(index++, child); } return true; }
@Override public boolean removeAll(Collection<?> c) { for (Object child : c) { remove(child); } return true; }
/** * Returns true if the component has any children. * * @return True if the component has any children. */ public boolean hasChildren() { return !children.isEmpty(); }
/** * Removes a child from this parent. * * @param child Child to remove. */ public void removeChild(BaseComponent child) { children.remove(child); }
/** * Destroy all children under this component. */ public void destroyChildren() { children.clear(true); }