3

I have a simple Eclipse run configuration launching a Perl script to process an XML file. Nothing special, works alright.

However, picking the run configuration is a bit awkward. My entry doesn't show up in the first level of the context menu. It doesn't show up either under "Run As". I have to pick "Run As > Run Configurations ..." to then select my run configuration "import XML".

The way I'd like this to work is to select one or more XML files and then pick "import XML" (the name of my run configuration) from the context menu. Heck, the best thing would even to be able to double-click the XML file to launch it such as in Windows Explorer. Actually, it would be best if Eclipse were able to determine the applicability of my run configuration "import XML" based on the filename and folder location. Like, make the rc available for all files in Database/XML ending in .xml and not starting with Hooks.

Is there a way to get somewhere near that point? If some Java programming is involved that's not a problem.

Lumi
  • 14,775
  • 8
  • 59
  • 92

3 Answers3

3

The thing you're after is called launch shortcut, check out Eclipse help.

If you want to get something into the first level of context menu, use org.eclipse.ui.menus extension point. Double-click is associated with opening a file in editor. While it is possible to define your launch configuration as an editor, it's certainly not a good practice.

Martti Käärik
  • 3,601
  • 18
  • 28
2

My entry doesn't show up in the first level of the context menu. It doesn't show up either under "Run As". I have to pick "Run As > Run Configurations ..." to then select my run configuration "import XML".

I don't think any run configurations are supposed to show up in the context menu under Run As, although it seems like it should probably contain recently used configurations, to mirror the toolbar run/debug/etc. buttons. Speaking of which, does your launch configuration show up under the run button? It should. That might be the easiest way to go about this.

The way I'd like this to work is to select one or more XML files and then pick "import XML" (the name of my run configuration) from the context menu. Actually, it would be best if Eclipse were able to determine the applicability of my run configuration "import XML" based on the filename and folder location. Like, make the rc available for all files in Database/XML ending in .xml and not starting with Hooks.

Eclipse can't do anything like this out of the box. It's entirely possible to write your own plug-in to do this, though I imagine the effort required would be enough to make it not worth it for what sounds like a one-off program. If I were you I'd probably just keep a console window open and run it from there, or make a really really simple gui to do this.

Chris
  • 3,400
  • 1
  • 27
  • 41
  • Thanks for the run button advice. Guess you're right it might not be worth the effort. Then again, if you've always wanted to do a plugin ... [it can be done](http://www.eclipsepluginsite.com/actions.html). – Lumi Dec 23 '11 at 22:47
  • Dang. I knew I saw that on another Eclipse IDE. But when I put my project in STS, I couldn't find the direct link to my run configuration. Now I see that it was in the Run button dropdown all along. – maximum Jul 23 '20 at 20:09
0

Some googling has shown that what I'm looking for, i.e. a context menu plug-in, has already been done; it is aptly named the ContextMenuPlugin for Eclipse.

Lumi
  • 14,775
  • 8
  • 59
  • 92