/** * Convenient method to remove a child. If the parent is a proxy, delegates to the shared * component. */ public final void removeChild(AXIComponent child) { if (child.getComponentType() == ComponentType.REFERENCE) { removeChild(Util.getProperty(child), child); return; } // proxy child delete from UI: delete original child if (child.getComponentType() == ComponentType.PROXY && !getModel().inSync()) { AXIComponent oChild = child.getOriginal(); oChild.getParent().removeChild(oChild); return; } removeChild(Util.getProperty(child), child); }
/** * Removes all children one by one. This is a special case where removal is not delegated to the * shared parent. */ public void removeAllChildren() { List<AXIComponent> removedChildren = new ArrayList<AXIComponent>(); for (AXIComponent child : getChildren()) { removedChildren.add(child); } for (AXIComponent child : removedChildren) { removeChild(Util.getProperty(child), child); } }
/** Sets the type. */ public void setType(AXIType type) { if (type instanceof Attribute) { setRef((Attribute) type); return; } int index = this.getIndex(); AXIComponent parent = getParent(); Attribute a = getModel().getComponentFactory().createAttribute(); a.setName(getReferent().getName()); parent.removeChild(this); parent.insertAtIndex(Attribute.PROP_ATTRIBUTE, a, index); a.setType(type); }
private void onChildDeleted(PropertyChangeEvent evt) { AXIComponent parent = (AXIComponent) evt.getSource(); AXIComponent child = (AXIComponent) evt.getOldValue(); if (child instanceof ContentModel) { onContentModelDeleted((ContentModel) child); return; } AXIComponent deletedChild = null; for (AXIComponent c : getChildren()) { if (c.getSharedComponent() == child) { deletedChild = c; break; } } if (deletedChild == null) return; removeChild(Util.getProperty(deletedChild), deletedChild); }