Trouble deciding how to add popup menu to eclipse plugin using either action ObjectContributions or command handlers

Posted by user1808408 on Stack Overflow See other posts from Stack Overflow or by user1808408
Published on 2012-12-13T09:31:13Z Indexed on 2012/12/15 11:04 UTC
Read the original article Hit count: 139

Filed under:
|
|
|

The issue is this: Most things I read on the web says that we should avoid actions when creating popup menus because the command framework allows for more decoupling.

Example: http://wiki.eclipse.org/FAQ_What_is_the_difference_between_a_command_and_an_action%3F

Fair enough.

But I am having a heck of a time getting the command framework to add my menu when I right click on a .java file inside the editor, and only when I click inside the editor. I can get the menu to show (using 'with' and the activeEditor variable), but it also shows when I right click on the java file inside the package explorer, which I don't want. I suspect it's because the file is already open inside the editor.

I also have a menu that gets added when I right click on the java file inside the package explorer, using IComplilationUnit. That works fine.

So my problem is solved using a popup menu action for when I click inside the file. I also get access to to all the ISelection stuff there. But the coupling is to high and I lose the flexability of using handlers.

I'm looking for either: Tell me I'm doing it the only way possible; or Tell me how to have my popup appear only when I right click on the java file editor.

Regards

© Stack Overflow or respective owner

Related posts about eclipse

Related posts about plugins