Customize Ctrl+Click behavior for Go To Definition

Dear All,

I was wondering if there is a way to customize the Ctrl+Click behavior for Go To Definition. As an example, if the definition of an element resides within a tree, I want to expand the parts of the tree such that the element is actually visible when it is selected. But there are also other examples that come to my mind where customization would be useful.

Your help is much appreciated! Best regards,

Andreas

2 comments
Comment actions Permalink

Take a look at the com.mbeddr.mpsutil.hyperlink language, it provides a flexible way of adding hyperlinks to the editor. You can use it to execute custom code on Ctrl+click.

If you want to customize the Ctrl+click behavior in general, you can do it at the Swing level: use the EditorExtensionRegistry to attach a MouseListener to the EditorComponent.

0
Comment actions Permalink

Hello Sergej,

Thank you very much for your support! Unfortunately, I did not find any examples nor documentation for EditorExtensionRegistry and where to initialize it, but I suspect it would also be possible to add a MouseListener in a project plugin using

this.mbc = project.getProject().getMessageBus().connect();
this.mbc.subscribe(EditorComponentCreateListener.EDITOR_COMPONENT_CREATION, eech);

Are these two way equivalent, or is one preferred over the other?

Another thing is that I would have to implement a MouseListener for each concept where the node of interest is referenced. Would it also be possible to approach it from the "referenced" node instead of the "referencing" node? In other words, is there some kind of listener that would be triggered after a Ctrl+Click, even though the referenced node is hidden in within the collapsed tree (SelectionListener would not work in that case I believe).

Kind regards, Andreas

0

Please sign in to leave a comment.