Esempio n. 1
0
  /**
   * 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);
  }
Esempio n. 2
0
  /** 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);
  }
Esempio n. 3
0
  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);
  }