【发布时间】:2016-11-07 09:52:31
【问题描述】:
我在 Eclipse 插件中创建了一个自定义编辑器,它以 Tree-Table(TreeViewer) 格式显示 XML 及其几个属性。为了显示剩余的属性,我试图将其与“属性视图”联系起来,但并不能真正取得进展。
我在 SO 上遇到了类似的问题 How to handle property sheet from customized editor in eclipse plugin development? 其中谈到让您的查看器为工作台选择做出贡献并在编辑器中选择的对象上实现 IPropertySource。
在我的例子中,我直接在 treeviewer 输入中设置一个文档对象,如下所示。
IFileEditorInput editorInput = (IFileEditorInput) getEditorInput();
IFile inputIFile = editorInput.getFile();
File f = new File(inputIFile.getLocation().toString());
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f);
}
catch (SAXException | IOException | ParserConfigurationException e) {
e.printStackTrace();
}
//setting root element of doc as input
treeViewer.setInput(doc.getDocumentElement());
现在我应该在哪个对象上实现 IPropertySource 接口来贡献属性?
让我知道我的方向是否正确、遗漏了什么或完全错误。
希望这是有道理的!
【问题讨论】:
-
您将什么设置为编辑器的选择提供者?
-
我将 treeViewer 设置为选择提供者 - 'getSite().setSelectionProvider(treeViewer);'