Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Source links in console(I am looking for a way to activate hyperlinks in the console without spending weeks researching ways that don't work)
Source links in console [message #1829221] Mon, 29 June 2020 06:14 Go to next message
joseph newcomer is currently offline joseph newcomerFriend
Messages: 15
Registered: July 2017
Junior Member
This is not a new topic. I have found messages back to 2006 where people are asking this question, and it always seems that they have invested time and effort in finding solutions that don't work.

All of my output goes through a pair of functions, DebugOptions.print() and DebugOptions.println(). So I would like a library class that would handle all this for me, either before or after the text is put into the console window. All of the references are based on local files, either source files or data files.

And before somebody complains: that is my real name. If you don't believe me, google my name. I leave it as an Exercise For The Reader to figure out which of the many hits is the real me.
Re: Source links in console [message #1829226 is a reply to message #1829221] Mon, 29 June 2020 08:20 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
If I understand your needs right you're printing logs to Eclipse's Console view and you'd like references to local files to be replaced with hyperlinks so that users can click on it and open the corresponding file, that's it?

I had to implement a similar solution a few weeks ago and the only solution I've found is to add a console listener (org.eclipse.ui.console.consolePatternMatchListeners extension point) which basically finds references thanks to a regex then add an hyperlink on the corresponding text range. I've been inspired by this comment on StackOverflow which also provides an helpful code snippet.

AFAIK using a regex-based listener is sadly the only way to add hyperlinks to the standard Eclipse Console view. Have you tried this solution among those that "don't work"?
Re: Source links in console [message #1829231 is a reply to message #1829226] Mon, 29 June 2020 10:03 Go to previous messageGo to next message
joseph newcomer is currently offline joseph newcomerFriend
Messages: 15
Registered: July 2017
Junior Member
OK, that looks better than anything I found otherwise. Thanks.

Now here's another question: it looks like this applies only if one is running the program under Eclipse. What happens if this is run as a standalone program? I don't mind if it does nothing, but I would mind a lot if it caused an exception to the end user, that I didn't know that I should catch.

Meanwhile, I am going to see if I can get that code to work in my app. It turns out that the filename recognition should be easy, because there is a subroutine in my code that formats the file and line number, and it could easily format it as <<filename:line>> and all I need to do is locate the << and matching >> (or I could use a Unicode encoding of a funky character from the math symbols font)
Re: Source links in console [message #1829237 is a reply to message #1829231] Mon, 29 June 2020 12:46 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
joseph newcomer wrote on Mon, 29 June 2020 12:03
Now here's another question: it looks like this applies only if one is running the program under Eclipse. What happens if this is run as a standalone program?

I'm sorry, I just realized you may have no knowledge in Eclipse plug-ins development. I'm not sure to understand which "program" you're referring to and what you mean by "run as standalone program" so here's an summary:

  • The console listener that inserts hyperlinks in the console must be provided as an Eclipse plug-in. The plug-in must be installed in Eclipse IDE to work.
  • Once installed, it should insert hyperlinks in the Console view whenever its regex is matched and no matter which program is printing on the console.

So of course you'll have no hyperlink if you're executing the program outside of Eclipse IDE if that's what you meant by "standalone".

That being said, implementing such a plug-in should be fairly easy and I'd be glad to provide some guidance if needed.
Re: Source links in console [message #1829251 is a reply to message #1829237] Mon, 29 June 2020 16:08 Go to previous messageGo to next message
joseph newcomer is currently offline joseph newcomerFriend
Messages: 15
Registered: July 2017
Junior Member
Ah, now it makes more sense. So what I do is develop an Eclipse plugin which works for my debugging. That's well beyond my current skill set, although I'm willing to learn. Is there an "Eclipse plug-ins for dummies" Web site?
Re: Source links in console [message #1829258 is a reply to message #1829251] Mon, 29 June 2020 18:14 Go to previous messageGo to next message
Emmanuel Chebbi is currently offline Emmanuel ChebbiFriend
Messages: 123
Registered: February 2018
Senior Member
You'll find several resources on the internet; I can personally recommend Eclipse IDE Plug-in Development: Plug-ins, Features, Update Sites and IDE Extensions on Vogella.

Roughly (and off the top of my head), here are the steps to create the plug-in:

  1. Download the latest Eclipse IDE for RCP and RAP developers release (it features tools for plug-in development)
  2. File > New > Plug-in Project
  3. Fill a project name > Next > Finish
  4. The MANIFEST.MF should open. Otherwise, open it (it's in the META-INF folder).
  5. Go to the Extensions tab > Add... > Uncheck "Show only extension points from the required plug-ins" > Select "org.eclipse.ui.console.consolePatternMatchListeners" > Finish
  6. A dialog will show up to warn about a missing dependency, say "Yes"
  7. Still in the MANIFEST.MF editor, you should see a few fields to the right. Fill regex with the regex you want to match.
  8. Click on class to open the Java class creation wizard, then Finish. This class, linked by the StackOverflow comment I referenced above, demonstrates how to match a regex and adds an hyperlink on it.

Complete the class and... you'll be done!

You can test the plug-in by right-click on the project > Run As > Eclipse Application.
Re: Source links in console [message #1829965 is a reply to message #1829258] Tue, 14 July 2020 22:08 Go to previous message
joseph newcomer is currently offline joseph newcomerFriend
Messages: 15
Registered: July 2017
Junior Member
I am considering the idea of putting some regex recognition hooks in my output; life would be easier if I could do something like markdown output to get colors, font changes, hyperlinks, etc. Is there any way to tell if I am running under the IDE, or should I just add a -decorate option to my command line? My centralized logging code and option infrastructure would make this truly trivial to do, once I have the plugin working (in fact, if there is a console Markdown plugin, that would be heavenly). But thank you for the detailed set of steps. I am, of course, familiar with the notion of plugins, and even have delivered products that support plugins, but the details of how to get one written are where the devil is residing.

I also don't understand the "Eclipse for..." model. If I download the latest version of Eclipse RCP and RAP, is that a completely different Eclipse than the one I am using for Java? Do I now have to manage two eclipse installations?
Previous Topic:gerrit login - Authentication failed.
Next Topic:Run button and Run Configurations>Run
Goto Forum:
  


Current Time: Sat Sep 19 22:02:36 GMT 2020

Powered by FUDForum. Page generated in 0.03585 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top