我想将文件的位置作为超链接写入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);我可能不应该在偏移量、文件长度等参数中传入0。
感谢您的帮助。
发布于 2009-02-27 10:37:08
好吧,事实证明我写的代码是好的,除了两个小的改动,它实际上应该是
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)感到有点惊讶,偏移量从控制台输出的开始计算。你为什么要自己计算,但那是另一回事了。
发布于 2011-06-26 19:37:03
如果你写(filename:linenumber),这一切都会自动发生。
另请参阅How to get Eclipse Console to hyperlink text to source code files?
https://stackoverflow.com/questions/591018
复制相似问题