/** * Swap positions of two children. * * @param index1 Index of first child. * @param index2 Index of second child. */ public void swap(int index1, int index2) { if (index1 != index2) { BaseComponent child1 = delegate.get(index1); BaseComponent child2 = delegate.get(index2); delegate.set(index1, child2); delegate.set(index2, child1); parent.invokeIfAttached("swapChildren", index1, index2); modCount++; } } }
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(); }
parent.invokeIfAttached("addChild", child, index);