2010-12-09 7 views
4

Quelqu'un peut-il expliquer comment utiliser l'arbre de cellules GWT. J'essaye de le google mais ne trouvant aucun didacticiel valable?GWT Cell tree, comment utiliser?

Merci

+0

La réponse actuelle sélectionnée est obsolète parce que les liens ne sont pas valides. – Ben

+0

liens sont mis à jour –

Répondre

4

Essayez;

Google Example 1

comprend procédé onModuleLoad. :)

+1

Merci, grands exemples – Noor

+1

Les exemples sont périmés ... Les liens ne fonctionnent plus – Ben

+0

lien sont mis à jour –

2

Pour ceux qui n'aiment pas l'exemple google vitrine comme moi peut utiliser cet exemple; http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/cellview/client/CellTree.html

vous pouvez simplement copier le coller et cela fonctionne. "


exemple Trivial


public class CellTreeExample implements EntryPoint { 

    /** 
    * The model that defines the nodes in the tree. 
    */ 
    private static class CustomTreeModel implements TreeViewModel { 

    /** 
    * Get the {@link NodeInfo} that provides the children of the specified 
    * value. 
    */ 
    public <T> NodeInfo<?> getNodeInfo(T value) { 
     /* 
     * Create some data in a data provider. Use the parent value as a prefix 
     * for the next level. 
     */ 
     ListDataProvider<String> dataProvider = new ListDataProvider<String>(); 
     for (int i = 0; i < 2; i++) { 
     dataProvider.getList().add(value + "." + String.valueOf(i)); 
     } 

     // Return a node info that pairs the data with a cell. 
     return new DefaultNodeInfo<String>(dataProvider, new TextCell()); 
    } 

    /** 
    * Check if the specified value represents a leaf node. Leaf nodes cannot be 
    * opened. 
    */ 
    public boolean isLeaf(Object value) { 
     // The maximum length of a value is ten characters. 
     return value.toString().length() > 10; 
    } 
    } 

    public void onModuleLoad() { 
    // Create a model for the tree. 
    TreeViewModel model = new CustomTreeModel(); 

    /* 
    * Create the tree using the model. We specify the default value of the 
    * hidden root node as "Item 1". 
    */ 
    CellTree tree = new CellTree(model, "Item 1"); 

    // Add the tree to the root layout panel. 
    RootLayoutPanel.get().add(tree); 
    } 
} 

"