예제 #1
0
  /**
   * 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);
  }
예제 #2
0
 /**
  * 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);
   }
 }
예제 #3
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);
  }
예제 #4
0
  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);
  }