Eclipse 插件打印超链接到控制台
Eclipse plugin print hyperlinks to console
我想在 eclipse 插件中将 hyperlinks 打印到控制台。
我看到了How to write a hyperlink to an eclipse console from a plugin,但是在调用myconsole.addHyperlink(fileLink, 10, 5)
时得到了BadLocationException
。我发现 class PatternMatchEvent
有 getLength()
和 getOffset()
我需要 MessageConsole.addHyperlink()
.
使用上面的方法 link 是否仍然是执行此操作的方法(这个问题大约在 12 年前提出),如果是这样,我如何继续访问这些方法?
感谢您的帮助!
您只能在 class 实现 IPatternMatchListener
中使用 PatternMatcherEvent
,它已作为模式匹配侦听器添加到控制台。
如果您没有使用侦听器,则必须通过搜索控制台文本来找到您要放置 hyperlink 的位置的偏移量。
您应该能够使用以下方法获取控制台文本:
IDocument document = myConsole.getDocument();
String text = document.get();
找到要用于 link 的文本:
String hyperlinkText = .... text you want to add the hyperlink to ...
int offset = text.indexOf(hyperlinkText);
如果找到文本,请添加 link:
if (offset >= 0) {
myconsole.addHyperlink(fileLink, offset, hyperlinkText.length());
}
我想在 eclipse 插件中将 hyperlinks 打印到控制台。
我看到了How to write a hyperlink to an eclipse console from a plugin,但是在调用myconsole.addHyperlink(fileLink, 10, 5)
时得到了BadLocationException
。我发现 class PatternMatchEvent
有 getLength()
和 getOffset()
我需要 MessageConsole.addHyperlink()
.
使用上面的方法 link 是否仍然是执行此操作的方法(这个问题大约在 12 年前提出),如果是这样,我如何继续访问这些方法?
感谢您的帮助!
您只能在 class 实现 IPatternMatchListener
中使用 PatternMatcherEvent
,它已作为模式匹配侦听器添加到控制台。
如果您没有使用侦听器,则必须通过搜索控制台文本来找到您要放置 hyperlink 的位置的偏移量。
您应该能够使用以下方法获取控制台文本:
IDocument document = myConsole.getDocument();
String text = document.get();
找到要用于 link 的文本:
String hyperlinkText = .... text you want to add the hyperlink to ...
int offset = text.indexOf(hyperlinkText);
如果找到文本,请添加 link:
if (offset >= 0) {
myconsole.addHyperlink(fileLink, offset, hyperlinkText.length());
}