/** * Convenient method to insert a child at a specified index. If the parent is a proxy, delegates * to the shared component. */ public final void addChildAtIndex(AXIComponent child, int index) { if (getComponentType() == ComponentType.PROXY && !getModel().inSync()) { getOriginal().addChildAtIndex(child, index); return; } insertAtIndex(Util.getProperty(child), child, index); }
/** 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 onChildAdded(PropertyChangeEvent evt) { if (!isChildrenInitialized()) return; AXIComponent parent = (AXIComponent) evt.getSource(); AXIComponent child = (AXIComponent) evt.getNewValue(); int index = -1; for (int i = 0; i < parent.getChildren().size(); i++) { if (parent.getChildren().get(i) == child) { index = i; break; } } if (index == -1) return; AXIComponentFactory factory = getModel().getComponentFactory(); AXIComponent proxy = factory.createProxy(child); insertAtIndex(Util.getProperty(child), proxy, index); }