Java GWT:CellTree和编辑器框架

Java GWT:CellTree和编辑器框架,java,gwt,Java,Gwt,我正在用框架编辑器重构我的GWT应用程序 我被一个包含CellTree小部件的视图卡住了。我不知道如何使用编辑器框架包装我的CustomTreeViewModel。 也许我需要对CellTree类进行子类化 精度: 以下是我在CellTree中的数据结构: 根级别为空 ZoneProxy: ZoneProxy parent; List<ZoneProxy> childs; List<PointProxy> points; 我使用两个HashMap使CellTree在没有

我正在用框架编辑器重构我的GWT应用程序

我被一个包含CellTree小部件的视图卡住了。我不知道如何使用编辑器框架包装我的CustomTreeViewModel。 也许我需要对CellTree类进行子类化

精度:
以下是我在CellTree中的数据结构:
根级别为空
ZoneProxy:

ZoneProxy parent;
List<ZoneProxy> childs;
List<PointProxy> points;
我使用两个HashMap使CellTree在没有EditorFramework的情况下工作:

private Map<ZoneProxy,ListDataProvider<ZoneProxy>> treeListDataZones;
private Map<ZoneProxy,ListDataProvider<PointProxy>> treeListDataPoints;
私有地图树数据区;
私有地图树数据点;
当用户单击树中的某个点时,我有一个右侧面板,该面板应显示所单击点的详细信息

我使用EditorFramework获取CellTree填充数据,但我创建了CellTree实现LeafValueEditor的CustomTreeViewModel。我看不出如何与编辑进行更深入的交流。(我不知道我必须用我的数据结构创建哪些子编辑器)

我想我遗漏了一些关于EditorFramework的东西,我要再次阅读Googledevguide

我没有发现任何使用框架编辑器的Celltree的示例。如果有人有一个好的例子,它将对我帮助很大。:)


谢谢

希望它能帮助你。下面是示例代码,对来自的实际代码进行了一些修改。双击文本项进行编辑

import com.google.gwt.cell.client.EditTextCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.cellview.client.CellTree;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.TreeViewModel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GWTTestProject implements EntryPoint {
    /**
     * This is the entry point method.
     */
    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);

    }

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

        EditTextCell textCell=new EditTextCell();
        // Return a node info that pairs the data with a cell.
        return new DefaultNodeInfo<String>(dataProvider, 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;
      }
    }

}

我找到了一个将ListDataProvider适配到ListEditor的适配器。我将看看它是否有效,下面是适配器的链接:我正在尝试使用类似这样的CompositeEditor构建:CompositeEditor。这是个好主意吗?我要检查ListEditor代码,它是一个复合编辑器。但我的是复合材料。。。这会很复杂谢谢你的回答,但我明白这一部分。我要找的是用塑料纸把这棵树包起来。我现在找到了一个解决方案,但还不完整:我在CustomCellTree上实现了LeafValueEditor,这样我就可以将数据放在CellTree中。我需要更深入的层次结构,但我被卡住了。我将完成我的问题。Thx再次布拉伊:)
import com.google.gwt.cell.client.EditTextCell;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.cellview.client.CellTree;
import com.google.gwt.user.client.ui.RootLayoutPanel;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.TreeViewModel;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class GWTTestProject implements EntryPoint {
    /**
     * This is the entry point method.
     */
    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);

    }

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

        EditTextCell textCell=new EditTextCell();
        // Return a node info that pairs the data with a cell.
        return new DefaultNodeInfo<String>(dataProvider, 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;
      }
    }

}