views:

1157

answers:

3

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);

I should probably not pass in 0 for the offset, filelength parameters etc.

Any help appreciated.

A: 

Can you send plain text to the console, or is nothing showing up at all?

If you can't see anything, this link should point you in the right direction.

Hope it helps

OTisler
A: 

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);

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.

Benjamin
A: 

Hi ,

I am writing a text editor in eclipse and added a console view to it for displaying the error messages and warnings. With the FileLink Class and MessageConsole.addHyperLink method i have successfully added a hyper link to the console which navigates to the corresponding text editor file in the Eclipse workbench. I want to navigate to the line where error occured in the text editor in the eclipse workbench.

FileLink fileLink = new FileLink(file, null, 0, 100, 300); console.addHyperlink(fileLink, 0, 5);

With this, the hyperlink is added to the console and when I click on the hyperlink i was redirected to the corresponding file in the text editor in eclipse workbench. The problem is I am not redirected to the specified line no(300) in the file. The text from the offset 0 and till 100 in the file is selected on the first line instead of line number 300. Could any one help me on this issue please.

Thanks in Advance, Kokila Somasundaram.

Kokila S
This is not an answer - you should [ask your own question](http://stackoverflow.com/questions/ask).
jensgram