How to write a hyperlink to an eclipse console from a plugin(如何从插件编写到 Eclipse 控制台的超链接)
问题描述
我想将文件的位置作为超链接写入 Eclipse 控制台.当您单击它时,它应该在 eclipse 中打开该文件.我目前正在做这样的事情(但链接不显示)
I would like to write the location of a file to the eclipse console as a hyperlink. When you click on it it should open the file in eclipse. I'm currently doing something like this (but the link doesn't show up)
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);
我可能不应该为偏移量、文件长度参数等传入 0.
I should probably not pass in 0 for the offset, filelength parameters etc.
任何帮助表示赞赏.
推荐答案
好吧,结果我写的代码很好,除了 2 个小改动它实际上应该是
Well, turns out the code I wrote is fine except for 2 minor changes it should actually be
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, -1, -1, -1);
console.addHyperlink(fileLink, 10, 5);
我有点惊讶必须提供偏移量 (10),它从控制台输出的开头开始计算.为什么你甚至想自己计算,但这是另一个讨论.
I was a little suprised that the offset (10) had to be provided, which counts from the beginning of the console output. Why would you even want to calculate that yourself, but that's another discussion.
这篇关于如何从插件编写到 Eclipse 控制台的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何从插件编写到 Eclipse 控制台的超链接


- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01