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

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


  }

  protected void appendModel(ModelData p, List<ModelData> models, int index) {
    if (models.size() == 0) return;
    if (models.get(0) instanceof TreeModel) {
      TreeModel test = (TreeModel) models.get(0);
      // drop is in form from tree store
      if (test.getPropertyNames().contains("model")) {

        List<ModelData> children = new ArrayList<ModelData>();
        for (ModelData tm : models) {
          ModelData child = tm.get("model");
          children.add(child);
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

   */
  public boolean hasChildren(M parent) {
    if (parent == null) {
      return rootWrapper.getChildCount() > 0;
    } else {
      TreeModel p = findWrapper(parent);
      if (p != null) {
        for (ModelData child : p.getChildren()) {
          if (!isFiltered((TreeModel) child)) {
            return true;
          }
        }
      }
View Full Code Here

   * @param children the children
   * @param index the insert index
   * @param addChildren true to recursively 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

        applyFilters(filterProperty);
      } else {
        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.getData();
        for (M model : list) {
View Full Code Here

  }

  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

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.