Fast tree (Ext GWT) : Tree « GWT « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JDK 6
25.JNDI LDAP
26.JPA
27.JSP
28.JSTL
29.Language Basics
30.Network Protocol
31.PDF RTF
32.Reflection
33.Regular Expressions
34.Scripting
35.Security
36.Servlets
37.Spring
38.Swing Components
39.Swing JFC
40.SWT JFace Eclipse
41.Threads
42.Tiny Application
43.Velocity
44.Web Services SOA
45.XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Java » GWT » TreeScreenshots 
Fast tree (Ext GWT)
Fast tree (Ext GWT)
 
/*
 * Ext GWT - Ext for GWT
 * Copyright(c) 2007-2009, Ext JS, LLC.
 * licensing@extjs.com
 
 * http://extjs.com/license
 */

package com.google.gwt.sample.hello.client;

import java.util.ArrayList;
import java.util.List;

import com.extjs.gxt.ui.client.data.BaseModelData;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.data.ModelKeyProvider;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.TreePanelEvent;
import com.extjs.gxt.ui.client.store.TreeStore;
import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.extjs.gxt.ui.client.widget.layout.FlowLayout;
import com.extjs.gxt.ui.client.widget.treepanel.TreePanel;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.RootPanel;

public class Hello implements EntryPoint {
  public void onModuleLoad() {
    RootPanel.get().add(new FastTreePanelExample());
  }
}
class FastTreePanelExample extends LayoutContainer {
  private int counter = 0;

  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);
    setLayout(new FlowLayout(12));

    final Html html new Html("This tree is handling 1 child. Expand to get more!");
    html.setStyleName("pad-text");

    LayoutContainer container = new LayoutContainer();
    container.setSize(300350);
    container.setBorders(true);
    container.setLayout(new FitLayout());

    TreeStore<ModelData> store = new TreeStore<ModelData>();
    final TreePanel<ModelData> tree = new TreePanel<ModelData>(store);
    tree.setTrackMouseOver(false);
    tree.setDisplayProperty("name");
    store.setKeyProvider(new ModelKeyProvider<ModelData>() {

      public String getKey(ModelData model) {
        return model.get("id");
      }

    });
    ModelData m = createModel("Fast Tree");
    store.add(m, false);

    tree.setLeaf(m, false);

    tree.addListener(Events.BeforeExpand, new Listener<TreePanelEvent<ModelData>>() {

      public void handleEvent(TreePanelEvent<ModelData> be) {
        if (be.getNode().getItemCount() != 0) {
          return;
        }
        List<ModelData> list = new ArrayList<ModelData>();
        for (int i = 0; i < 500; i++) {
          ModelData m = createModel("Tree Item " + i);
          list.add(m);
        }

        tree.getStore().insert(be.getNode().getModel(), list, 0true);
        for (ModelData m : list) {
          tree.setLeaf(m, false);
        }
      }
    });

    tree.addListener(Events.Expand, new Listener<TreePanelEvent<ModelData>>() {

      public void handleEvent(TreePanelEvent<ModelData> be) {
        html.setHtml("<span>This tree is handling " + tree.getStore().getAllItems().size()
            " children. Expand to get more!</span>");

      }

    });

    add(html);
    container.add(tree);
    add(container);
    
  }

  private ModelData createModel(String n) {
    ModelData m = new BaseModelData();
    m.set("name", n);
    m.set("id", String.valueOf(counter++));
    return m;
  }

}

   
  
Ext-GWT.zip( 4,297 k)
Related examples in the same category
1.Use TreeListener
2.Create Tree With Pending Item
3.Tree node expanding and collapsing animation (Smart GWT)Tree node expanding and collapsing animation (Smart GWT)
4.Trees can show skinnable connector lines (Smart GWT)Trees can show skinnable connector lines (Smart GWT)
5.Tree with DataArrivedHandler (Smart GWT)Tree with DataArrivedHandler (Smart GWT)
6.Trees with multiple columns of data for each node. (Smart GWT)Trees with multiple columns of data for each node. (Smart GWT)
7.Sortable tree table (Smart GWT)Sortable tree table (Smart GWT)
8.Tree Editing Sample (Smart GWT)Tree Editing Sample (Smart GWT)
9.Parent Linking Tree Sample (Smart GWT)Parent Linking Tree Sample (Smart GWT)
10.Load tree data from a collection of local beans (Smart GWT)Load tree data from a collection of local beans (Smart GWT)
11.Tree data can be specified as a tree of nodes where each node lists its children (Smart GWT)Tree data can be specified as a tree of nodes where each node lists its children (Smart GWT)
12.Drag and drop to move parts and folders within and between the trees (Smart GWT)Drag and drop to move parts and folders within and between the trees (Smart GWT)
13.Tree Drag Reparent Sample (Smart GWT)Tree Drag Reparent Sample (Smart GWT)
14.Closed tree folders automatically open if you hover over them momentarily (Smart GWT)Closed tree folders automatically open if you hover over them momentarily (Smart GWT)
15.Load tree data from a collection of local beans (Smart GWT)Load tree data from a collection of local beans (Smart GWT)
16.Tree view dropdown (Smart GWT)Tree view dropdown (Smart GWT)
17.Trees sort per folder. (Smart GWT)Trees sort per folder. (Smart GWT)
18.Load On Demand Tree Sample (Smart GWT)Load On Demand Tree Sample (Smart GWT)
19.Basic TreePanel Example (Ext GWT)Basic TreePanel Example (Ext GWT)
20.CheckBox Tree Node (Ext GWT)CheckBox Tree Node (Ext GWT)
21.Adding Context Menu to Tree (Ext GWT)Adding Context Menu to Tree (Ext GWT)
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.