2009-02-26 107 views
3

我想將文件的位置作爲超鏈接寫入eclipse控制檯。當你點擊它時,它應該在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傳遞的偏移,文件長度參數等

讚賞任何幫助。

回答

4

好了,原來我寫的代碼是好的,除了2級小的改動它實際上應該是

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)必須提供,其從計數控制檯輸出開始。你爲什麼甚至想要自己計算一下,但那是另一次討論。

相關問題