Package com.extjs.gxt.ui.client.data

Examples of com.extjs.gxt.ui.client.data.TreeModel


  }

  protected void swapModelInstance(M oldModel, M newModel) {
    super.swapModelInstance(oldModel, newModel);
    if (useKeyProvider != null) {
      TreeModel wrapper = null;
      if (useKeyProvider) {
        wrapper = modelFastMap.get(getKey(oldModel));
      } else {
        wrapper = modelMap.get(oldModel);
      }
      if (wrapper != null) {
        wrapperMap.put(wrapper.<String> get("id"), newModel);
        if (!useKeyProvider && modelMap != null) {
          modelMap.remove(oldModel);
          modelMap.put(newModel, wrapper);
        }
      }
View Full Code Here


      } else {
        modelFastMap = new FastMap<TreeModel>();
        useKeyProvider = true;
      }
    }
    TreeModel wrapper = new BaseTreeModel();
    wrapper.set("id", String.valueOf(counter++));
    if (useKeyProvider) {
      modelFastMap.put(getKey(model), wrapper);
    } else {
      modelMap.put(model, wrapper);
    }
    wrapperMap.put(wrapper.<String> get("id"), model);
    return wrapper;
  }
View Full Code Here

  @SuppressWarnings({"unchecked", "rawtypes"})
  private void doInsert(TreeModel parent, List<TreeModel> children, int index, boolean addChildren, boolean supressEvent) {
    if (parent != null && children != null && children.size() > 0) {
      M modelParent = unwrap(parent);
      for (int i = children.size() - 1; i >= 0; i--) {
        TreeModel child = children.get(i);
        parent.insert(child, index);
        M m = unwrap(child);
        all.add(m);
        registerModel(m);
        if (storeSorter != null) {
          applySort((List) parent.getChildren());
          if (!supressEvent) {
            TreeStoreEvent evt = createStoreEvent();;
            evt.setParent(modelParent);
            evt.setIndex(parent.indexOf(child));
            evt.setChildren(Arrays.asList(m));
            fireEvent(Add, evt);
          }
        }
      }

      if (!supressEvent && storeSorter == null) {
        TreeStoreEvent evt = createStoreEvent();;
        evt.setParent(modelParent);
        evt.setChildren(unwrap(children));
        evt.setIndex(index);
        fireEvent(Add, evt);
      }

      if (addChildren) {
        for (TreeModel sub : children) {
          M model = unwrap(sub);
          if (model instanceof TreeModel) {
            TreeModel treeSub = (TreeModel) model;

            List<M> c = (List) treeSub.getChildren();
            if (c.size() > 0) {
              List<TreeModel> insert = new ArrayList<TreeModel>();
              for (M m : c) {
                insert.add(wrap(m));
              }
View Full Code Here

  }

  private void filterTreeWrap(TreeModel wrap) {
    List<ModelData> children = wrap.getChildren();
    for (int i = 0, len = children.size(); i < len; i++) {
      TreeModel tm = (TreeModel) children.get(i);
      if (isOrDecendantSelected(tm, unwrap(tm))) {
        tm.set("filtered", "false");
      } else {
        tm.set("filtered", "true");
      }
      filterTreeWrap(tm);
    }
  }
View Full Code Here

    if (!isFiltered(model, filterProperty)) {
      return true;
    }
    List<ModelData> children = wrap.getChildren();
    for (int i = 0, len = children.size(); i < len; i++) {
      TreeModel tm = (TreeModel) children.get(i);
      boolean result = isOrDecendantSelected(tm, unwrap(tm));
      if (result) {
        return true;
      }
    }
View Full Code Here

   *
   * @param index the index
   * @return the child
   */
  public M getChild(int index) {
    TreeModel child = rootWrapper.getChild(index);
    if (child != null) {
      return unwrap(child);
    }
    return null;
  }
View Full Code Here

   * @param parent the parent model
   * @param index the index
   * @return the child of the parent at the given index
   */
  public M getChild(M parent, int index) {
    TreeModel p = findWrapper(parent);

    if (p != null) {
      TreeModel child = p.getChild(index);
      if (child != null) {
        return unwrap(child);
      }
    }
    return null;
View Full Code Here

   *
   * @param parent the parent
   * @return the child count or -1 if parent not found in the store
   */
  public int getChildCount(M parent) {
    TreeModel p = findWrapper(parent);
    if (p != null) {
      return p.getChildCount();
    }
    return -1;
  }
View Full Code Here

   *
   * @param parent the children
   * @return the children or null if parent not found in stote
   */
  public List<M> getChildren(M parent) {
    TreeModel p = findWrapper(parent);
    if (p != null) {
      return unwrapChildren(p);
    }
    return null;
  }
View Full Code Here

   *
   * @param item the item
   * @return the item's parent
   */
  public M getParent(M item) {
    TreeModel child = findWrapper(item);
    if (child != null) {
      TreeModel p = child.getParent();
      if (p != null) {
        return unwrap(p);
      }
    }
    return null;
View Full Code Here

TOP

Related Classes of com.extjs.gxt.ui.client.data.TreeModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.