Пример #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
  /**
   * 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);
  }
Пример #3
0
  /**
   * Convenient method to append a child. If the parent is a proxy, delegates to the shared
   * component.
   */
  public final void appendChild(AXIComponent child) {
    if (getComponentType() == ComponentType.PROXY && !getModel().inSync()) {
      getOriginal().appendChild(child);
      return;
    }

    appendChild(Util.getProperty(child), child);
  }
Пример #4
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);
   }
 }
Пример #5
0
 /**
  * Removing a content model is special. For example, if element shipTo and billTo are of type
  * USAddress, and USAddress gets deleted, then delete the proxy children of shipTo and billTo and
  * finally delete USAddress.
  */
 private void onContentModelDeleted(ContentModel contentModel) {
   List<AXIComponent> removeList = new ArrayList<AXIComponent>();
   for (AXIComponent child : getChildren()) {
     if (child.getContentModel() == contentModel) {
       removeList.add(child);
     }
   }
   for (AXIComponent child : removeList) {
     child.getParent().removeChild(Util.getProperty(child), child);
   }
 }
Пример #6
0
  /**
   * Visits each child schema component and creates corresponding axi component, adds them to the
   * parent axi component.
   */
  public void populateChildren(List<AXIComponent> children) {
    if (getSharedComponent() != null) {
      Util.addProxyChildren(this, getSharedComponent(), children);
      return;
    }

    // Safeguard: this can be removed if DesignPatternTest goes through
    if (getPeer() == null) return;

    AXIModelBuilder builder = new AXIModelBuilder(this);
    builder.populateChildren(getPeer(), true, children);
  }
Пример #7
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);
  }
Пример #8
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);
  }