【问题标题】:GWT Cell tree, how to use?GWT Cell 树,如何使用?
【发布时间】:2010-12-09 09:06:41
【问题描述】:

谁能解释如何使用 GWT 单元树。我正在尝试谷歌但没有找到任何有价值的教程??

谢谢

【问题讨论】:

  • 当前选择的答案已过期,因为链接无效。

标签: java gwt interface treeview tree


【解决方案1】:

试试;

Google Example 1

包括 onModuleLoad 方法。 :)

【讨论】:

    【解决方案2】:

    对于像我这样不喜欢google展示示例的人可以使用这个示例; http://google-web-toolkit.googlecode.com/svn/javadoc/2.1/com/google/gwt/user/cellview/client/CellTree.html

    您只需复制粘贴即可。 "


    简单的例子


    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);
      }
    }
    

    "

    【讨论】:

      猜你喜欢
      • 2011-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多