官方网站非常稀缺,大多数示例都是 EMF 相关的,并且适用于 Eclipse 3.5。但是如果使用 3.4 目标 Eclipse 平台并且不使用 EMF 会怎样。我对树查看器示例特别感兴趣,但总是赞赏好的示例和文档。

有帮助吗?

解决方案

这里有一些很好的资源:

我不认为 eclipse 3.4 和 3.5 中的 JFace 数据绑定之间存在重大差异。概念仍然相同(ISWTObservables 等)。

编辑

拉尔斯·沃格尔 使用以下代码演示了一个可观察的列表查看器:

// 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。您需要的内容提供商 org.eclipse.jface.databinding.viewers.ObservableListTreeContentProvider. 。它有点复杂,因为您需要一个列表工厂和一个 TreeStructureAdvisor 来构造这个内容提供程序。这就是我能提供的所有帮助。也没有找到示例,并且到目前为止还没有使用树查看器的数据绑定。因此,从现在开始,JFace API 文档必须成为您的朋友;)

其他提示

这里有一个 综合清单 样品。 这个 与 TreeViewer 特别相关。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top