如何从插件写入eclipse控制台的超链接 [英] How to write a hyperlink to an eclipse console from a plugin

查看:187
本文介绍了如何从插件写入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控制台的超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆