Using Ctrl-Click to call an action?

Hi,

I have created an Action which opens a file based on an XML attribute value:
]]>

The way I have done it is by positioning the cursor in the XML attribute value and calling the Action (e.g. with a keyboard shortcut). This works fine.

I wonder if I can create the same behavior but with a Ctrl+Click on the attribute value.

Is it possible? If yes, how?

Thank you,
Stephane

2 comments
Comment actions Permalink

Hello selie,

I have created an Action which opens a file based on an XML attribute
value: <openfile name="filename.txt"/>

The way I have done it is by positioning the cursor in the XML
attribute value and calling the Action (e.g. with a keyboard
shortcut). This works fine.

I wonder if I can create the same behavior but with a Ctrl+Click on
the attribute value.

Is it possible? If yes, how?


You're asking the wrong question. :) The correct way to implement this behavior
is not to provide new actions, but rather to use ReferenceProviderRegistry
to add a custom PsiReference from your attribute value to the target file.
Then many more features besides Ctrl-click will work automatically or almost
automatically (find usages, rename etc.)

You can search the forums to find more information about using these APIs.

--
Dmitry Jemerov
Development Lead
JetBrains, Inc.
http://www.jetbrains.com/
"Develop with Pleasure!"


0
Comment actions Permalink

Thanks Dmitry,

I've found these 2 posts which are pretty much explaining where to find and how to use the 'Closed API' ReferenceProviderRegistry:

http://intellij.net/forums/thread.jspa?messageID=4934388&#4934388
http://intellij.net/forums/message.jspa?messageID=5047098#5047098

0

Please sign in to leave a comment.