我正在编写Eclipse命令插件,并希望在包资源管理器视图中检索当前选定的节点.我希望能够从返回的结果中获取绝对文件路径,其中所选节点位于文件系统上(即c:\ eclipse\test.html).
我该怎么做呢 ?
我有以下XML:
<parent>
<pet>
<data>
<birthday/>
</data>
</pet>
<pet>
<data>
<birthday/>
</data>
</pet>
</parent>
Run Code Online (Sandbox Code Playgroud)
现在我想选择第一个生日元素,parent//birthday[1]
但这会返回两个生日元素,因为它们都是父母的第一个孩子.
我怎样才能选择整个文档的第一个生日元素,无论它位于何处.我已经尝试parent//birthday[position()=1]
但是这也不起作用.
我想将文件的位置作为超链接写入eclipse控制台。当您单击它时,应在eclipse中打开文件。我目前正在做类似的事情(但链接未显示)
console = new MessageConsole("myconsole", null);
console.activate();
ConsolePlugin.getDefault().getConsoleManager().addConsoles(new IConsole[]{ console });
IPath path = Path.fromOSString(filePath);
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
FileLink fileLink = new FileLink(file, null, 0, 0, 0);
console.addHyperlink(fileLink, 0, 0);
Run Code Online (Sandbox Code Playgroud)
我可能不应该为偏移量,文件长度参数等传递0。
任何帮助表示赞赏。