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

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


   * @param children the children
   * @param index the insert index
   * @param addChildren true to recursivly add all children
   */
  public void insert(M parent, List<M> children, int index, boolean addChildren) {
    TreeModel wrapper = findWrapper(parent);
    if (wrapper != null) {
      List<TreeModel> insert = new ArrayList<TreeModel>();
      for (M model : children) {
        insert.add(wrap(model));
      }
View Full Code Here


   *
   * @param parent the parent model
   * @param child the child model
   */
  public void remove(M parent, M child) {
    TreeModel p = findWrapper(parent);
    TreeModel c = findWrapper(child);
    if (p != null && c != null) {
      remove(p, c, false);
    }
  }
View Full Code Here

   * Removes all the parent's children.
   *
   * @param parent the parent
   */
  public void removeAll(M parent) {
    TreeModel p = findWrapper(parent);
    if (p != null) {
      List<M> children = getChildren(parent);
      for (M m : children) {
        TreeModel child = findWrapper(m);
        if (child != null) {
          remove(p, child, false);
        }
      }
    }
View Full Code Here

        insert.add(wrap(model));
      }
      doInsert(rootWrapper, insert, 0, false, true);
      fireEvent(DataChanged, new TreeStoreEvent(this));
    } else {
      TreeModel wrapper = findWrapper((M) le.parent);
      if (wrapper != null) {
        if (wrapper.getChildren().size() > 0) {
          removeAll((M) le.parent);
        }
        List<TreeModel> insert = new ArrayList<TreeModel>();
        List<M> list = (List<M>) le.data;
        for (M model : list) {
View Full Code Here

  protected List<M> unwrapChildren(TreeModel parent) {
    return unwrap(parent.getChildren());
  }

  protected TreeModel wrap(M model) {
    TreeModel wrapper = new BaseTreeModel();
    modelMap.put(model, wrapper);
    wrapperMap.put(wrapper, model);
    return wrapper;
  }
View Full Code Here

      if (addChildren) {
        for (TreeModel sub : children) {
          M model = unwrap(sub);
          if (model instanceof TreeModel) {
            TreeModel treeSub = (TreeModel) model;
            List<TreeModel> insert = new ArrayList<TreeModel>();
            List<M> c = treeSub.getChildren();
            for (M m : c) {
              insert.add(wrap(m));
            }
            doInsert(sub, insert, getChildCount(model), true, false);
            update(model);
View Full Code Here

   * @param model the model
   */
  public static void buildTree(Tree tree, TreeModel model) {
    TreeItem root = tree.getRootItem();
    for (int i = 0; i < model.getChildCount(); i++) {
      TreeModel m = model.getChild(i);
      TreeItem item = new TreeItem();
      ComponentHelper.setModel(item, m);
      item.setText(m.toString());
      root.add(item);
      process(item, m);
    }
  }
View Full Code Here

    }
  }

  private static void process(TreeItem parentItem, TreeModel model) {
    for (int i = 0; i < model.getChildCount(); i++) {
      TreeModel m = model.getChild(i);
      TreeItem item = new TreeItem();
      item.setText(m.toString());
      ComponentHelper.setModel(item, m);
      parentItem.add(item);
      process(item, m);
    }
  }
View Full Code Here

  public void clearFilters() {
    if (isFiltered()) {
      filtersEnabled = false;
      snapshot = null;
      for (M m : all) {
        TreeModel wrap = findWrapper(m);
        wrap.remove("filtered");
      }
      fireEvent(Filter, createStoreEvent());
    }
  }
View Full Code Here

   */
  public M getChild(M parent, int index) {
    if (parent == null) {
      return getFilteredChildren(rootWrapper).get(index);
    }
    TreeModel p = findWrapper(parent);
    if (p != null) {
      return getFilteredChildren(p).get(index);
    }
    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.