[英]GWT : CellTree with Editor Framework
我正在使用框架编辑器重构我的GWT应用程序。
我陷入了一个包含CellTree小部件的视图。 我没有看到如何使用编辑器Framework包装我的CustomTreeViewModel 。 也许我需要继承CellTree类?
精度:
这是我在CellTree中的数据结构:
rootLevel为null
ZoneProxy:
ZoneProxy parent;
List<ZoneProxy> childs;
List<PointProxy> points;
所以我可以有这个:
|_ Zone 1
| |_Zone 1.1
| |_Zone 1.2
| |_Point 1
| |_Point 2
|_ Zone 2
.
.
.
我使用两个hashMaps使CellTree在没有EditorFramework的情况下工作:
private Map<ZoneProxy,ListDataProvider<ZoneProxy>> treeListDataZones;
private Map<ZoneProxy,ListDataProvider<PointProxy>> treeListDataPoints;
当用户单击树中的一个点时,我有一个右侧面板,该面板应显示单击的点的详细信息。
我用EditorFramework获得了CellTree填充数据,但是我制作了实现LeafValueEditor的CellTree的CustomTreeViewModel。 我看不到如何与编辑人员更深入地交流。 (我不知道必须使用数据结构创建的子编辑器)
我想我缺少EditorFramework的功能,我将再次阅读Google DevGuide。
我找不到在Framework Editor中使用Celltree的任何示例。 如果有人有一个很好的榜样,它将对我有很大帮助。 :)
谢谢
希望对您有帮助。 这是示例代码,其中对Here的实际代码进行了一些修改。 双击文本项进行编辑。
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;
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.