Package net.mygwt.ui.client.widget.tree

Examples of net.mygwt.ui.client.widget.tree.TreeItem


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


  }

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

  private static void process(TreeItem item, Element parent) {
    int size = DOM.getChildCount(parent);
    for (int i = 0; i < size; i++) {
      Element li = DOM.getChild(parent, i);
      TreeItem childItem = new TreeItem();
      String id = DOM.getElementAttribute(li, "id");
      if (id != null && !id.equals("")) {
        childItem.setId(id);
      }
      childItem.setText(DOM.getElementProperty(li, "title"));
      item.add(childItem);
      for (int j = 0; j < DOM.getChildCount(li); j++) {
        Element subList = DOM.getChild(li, j);
        process(childItem, subList);
      }
View Full Code Here

   * @param parent the parent element
   * @param child the child element
   * @param position the insert position
   */
  public void insert(Object parent, Object child, int position) {
    TreeItem p = (TreeItem) findItem(parent);
    internalAdd(p, child, position);
  }
View Full Code Here

   * Refreshes this viewer starting with the given element.
   *
   * @param elem the element
   */
  public void refresh(Object elem) {
    TreeItem item = (TreeItem) findItem(elem);
    if (item != null) {
      if (item.getData("loaded") != null) {
        int count = item.getItemCount();
        for (int i = 0; i < count; i++) {
          item.remove(item.getItem(0));
        }
        item.setData("loaded", null);
        loadChildren(item, item.isExpanded());
      }
    }
  }
View Full Code Here

   * Removes the given element from the viewer.
   *
   * @param element the element to be removed
   */
  public void remove(Object element) {
    TreeItem item = (TreeItem) findItem(element);
    if (item != null) {
      TreeItem parent = item.getParentItem();
      parent.remove(item);
      removeElement(item.getData());
      item.setData(null);
    }
  }
View Full Code Here

   * Selects the elements.
   *
   * @param elem the element to be selected
   */
  public void select(Object elem) {
    TreeItem item = (TreeItem) findItem(elem);
    tree.getSelectionModel().select(item);
  }
View Full Code Here

    TreeItem item = (TreeItem) findItem(elem);
    tree.getSelectionModel().select(item);
  }

  public boolean setChecked(Object element, boolean state) {
    TreeItem item = (TreeItem) findItem(element);

    if (item != null) {
      item.setChecked(state);
      return true;
    }

    return false;
  }
View Full Code Here

   *
   * @param element the element
   * @param expanded the expand state
   */
  public void setExpanded(Object element, boolean expanded) {
    TreeItem item = (TreeItem) findItem(element);
    if (item != null) {
      item.setExpanded(expanded);
    }
  }
View Full Code Here

  public void setSelection(ISelection selection, boolean reveal) {
    List selected = selection.toList();
    tree.getSelectionModel().deselectAll();
    TreeItem[] items = tree.getAllItems();
    for (int i = 0; i < items.length; i++) {
      TreeItem item = items[i];
      Object elem = item.getData();
      if (selected.contains(elem)) {
        tree.getSelectionModel().select(item);
      }
    }
  }
View Full Code Here

TOP

Related Classes of net.mygwt.ui.client.widget.tree.TreeItem

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.