官方网站非常稀少,大多数示例与 EMF 相关并且针对 Eclipse 3.5 但是如果使用 3.4 目标 Eclipse 平台并且不使用 EMF 怎么办。 我对 Tree Viewer 示例特别感兴趣,但是好的示例和文档总是值得赞赏的。
最佳答案
这里有一些很好的资源:
- JFace databinding on eclipse wiki (incl. tutorial)
- The FAQ which links to some snippets
- An example that shows databinding with a ListViewer
我认为 eclipse 3.4 和 3.5 中的 JFace 数据绑定(bind)之间没有重大区别。概念仍然相同(ISWTObservables 等)。
编辑
Lars Vogel使用以下代码演示可观察的列表查看器:
// Define the viewer
viewer = new ListViewer(parent);
viewer.setContentProvider(new ObservableListContentProvider());
List<Person> persons = new ArrayList<Person>();
// Just for testing we create sample data
createExampleData(persons);
input = new WritableList(persons, Person.class);
// Set the writeableList as input for the viewer
viewer.setInput(input);
介绍鼓励这也适用于 TreeViewers。您需要的 Content Provider org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider
。它有点复杂,因为您需要一个列表工厂和一个 TreeStructureAdvisor 来构建这个内容提供者。这就是我能提供的所有帮助。也没有找到示例,到目前为止也没有对树查看器使用数据绑定(bind)。所以从现在开始,JFace API 文档必须成为您的 friend ;)
关于java - 是否有用于 Eclipse 3.4 的 jface 数据绑定(bind)框架的良好示例和文档?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1858682/