Пример #1
0
 /**
  * Returns this component's index (relative or absolute) in the parent's children list. Returns -1
  * if child or parent are not in model or the child is not found in the parent's children list.
  *
  * @param absolute - true, relative (to its type in parent) - false
  */
 public int getIndex(boolean absolute) {
   AXIComponent parent = getParent();
   if (parent == null || !isInModel()) return -1;
   List<AXIComponent> childs = Collections.emptyList();
   if (absolute) childs = parent.getChildren();
   else childs = parent.getChildren((Class<AXIComponent>) this.getClass());
   for (int i = 0; i < childs.size(); i++) {
     if (childs.get(i) == this) {
       return i;
     }
   }
   return -1;
 }
Пример #2
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);
  }
Пример #3
0
  private void populateChildElements(
      List<AbstractElement> childrenElements, AXIComponent component) {
    for (AXIComponent child : component.getChildren()) {
      if (child instanceof ContentModel) continue;

      if (child instanceof AbstractElement) {
        childrenElements.add((AbstractElement) child);
        continue;
      }
      populateChildElements(childrenElements, child);
    }
  }