CTRL+Click to launch a web page/browser window

Hi,

I'm trying to add functiontionality to open up a web page using CTRL+Click on certain elements. The idea is to open up a web page instead of opening the declaration.


For example if I CTRL+Click the following specially formatted string literal:

exampleID = "2435$345345";

it will open up an external web browser window with URL:

http://www.mysite.com/special_documentation?q=2435$345345


To do this, my plan was to implement my own PsiReference, and having the resolve() method call BrowserUtil.launchBrowser(). This obviously didn't work since resolve() isn't only called during a CTRL+Click.

What is the proper way to make this happen? I thought of a few possibilities, but I have no idea if they are possible:
1. Create my own PsiElement returned by resolve() that, when accessed, somehow launches the webpage instead of switching to a file
2. Create my own listeners, and not use the PsiReference API at all.


Any help on this would be greatly appreaciated.


Thanks!

2 comments
Comment actions Permalink

There's already an existing plugin for that, though I don't know if it still works with current versions:

http://plugins.intellij.net/plugin/index?pr=idea&pluginId=40

0
Comment actions Permalink

Thanks for the response.

I looked into that plugin before, but I guess I didn't realize it did what I wanted. I'll try to work with that.

0

Please sign in to leave a comment.