How to add a context menu entry to the eclipse editor context menu - eclipse

I'm trying to create a plugin for eclipse and for the one of the requirements is to add an entry to the context menu for all text editors so that on right click I get an option corresponding to the action I want to perform. I've tried to find relevant resources for it but most of the use cases are focused on adding a context menu to a view etc and not to the context menu for the eclipse editor. So far, I tried to implement this using the eclipse context in the activator but as is perhaps obvious, the workspace is not created when the activator's start method executes. Any help would be appreciated!

Related

Eclipse plugin development implementation

I work with Eclipse and PyDev plugin.
I want to develop a plugin which adds to the main menu (where File is located), an item "my own custom menu" which contains in it another menu items.
According to some examples, I eventually implemented it by using the extension point of org.eclipse.ui.actionSets.
My goal is when item of "my custom menu" is clicked, it should invoke Eclipse functionality.
for example:
"my custom menu" has menu item called "open new pyDev project".
When "open new pyDev project" is clicked, I want to open the pyDev project creation window that manually is opened by clicking the following Eclipse menu items: File->new->other->PyDev->PyDev Project.
I searched quite a lot and couldn't find the way to do it.
Does someone know how to achieve my goal?
What you want to do is implement a workbench wizard that will add them to the set of workbench wizards; then you can add a perspective extension to add it the the corresponding menu generically.
You have to look up the perspective ID you are using with PyDev, but this is the recommended way to add new wizard items to the corresponding menu.

Adding custom right click menu into Eclipse's project explorer view in RCP application

Currently I'm using Eclipse's Project Explorer view into my RCP Application by writing the following line of command into my "Perspective.java" file...
layout.addView(IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.LEFT, 0.30f, editorArea);
It is currently giving me all the default right click options that eclipse's project explorer view gives..
i.e. cut, copy, paste, delete, refresh, etc.
I want to add my own custom right click options into these default options. Does anyone know how to do it? Or will have to build my own project explorer view??
Is there anyway from where i can get the code that eclipse used for building the project explorer view?
would like to know what can be done in this situation or any other solution for this??
Thankyou !!
While my comment covers your question, the follow up questions need some more space:
a) how to look at eclipse sources:
*File -> Import ... ->Plug-in Development -> Plug-ins and Fragments -> Next*
Chose *Import as -> Binary Projects* (you can read the source code but not change it. This saces time, because the code doesn't get compiled) ->Next
Chose plugins to import -> Finish
You can find the sources in the projects in "referenced libraries"
b) you need the path to the menu entry and the plugin you want to add to. This can be done with the Plugin spy (Alt+Shift+F1 -> click on the view of which you want to get the id) or or Menu-Spy (Alt+Shift+F2 -> click on the menu entry that you want to add to)in Eclipse.
c) To add a menu entry to the popup, see the How to add items in popup menu? (the one I mentioned in my comment).

Eclipse: Can You Add A Command To The Context Menu

I'm new to Eclipse. Is it possible to add a command to the context menu ( right click in an editor ) without writing a plugin? I don't want to make a code contribution to Eclipse, just put a frequently used command there, in my own copy, for my convenience.
No. You have to write a plugin to contribute a new context menu.
The context menu cannot be changed unless you build your own version of Eclipse

Eclipse plug-in: How to create a new menu for eclipse plugin with key combination?

I've been looking about this question but I couldn't find it. I need to create a new "popup menu" and assign a key pressed (in other words, I need press "F3+right-click" (for example) and this action will be appear a new popup menu, with my actions in my workbench). I don't need a submenu for my right-click... i need a new and alone menu
Example, in eclipse, when i right-click with my mouse over workbench I see a popmenu with: "undo, revert file, save, cut, copy..." and more, but i need create a new menu instead of eclipse menu, so, when I press "F3+right-click" (example) i need see my popup-menu with my actions... this is my problem, i need to create a new menu and call it with key/mouse combination...
I've been reading the forums but i don't know where to post this question and I don't know where to search (maybe i write a wrong question in the search... i think...).
I hope someone can help me.
Thank you very much;)
I assume that you would like to see this menu in an editor (rather than in a view because that would be slightly different). Most of what you need to do here is to extend eclipse extension points through declaring them in the plugin.xml for your plugin.
Thankfully, Eclipse ships with a few extension point wizards to help you get started with this. To get there, do the following
Open the plugin.xml for your plugin
Go to the extensions page
Click on Add...
Click on Extension Wizards
The "Popup Menu" wizard
After filling in all the details, there are still a few more pieces that you need to do.
The wizard creates an Object contribution, that will add the new popup menu to an object of a specified type in all views. You can change this to being an editor contribution, so that the menu item will show in editors instead.
The final step is to connect this menu item with a key-binding. For that, you need to create a new Command extension.
Start with the Command extension point wizard.
After filling in the details, you get a command, a handler, and a binding. You can remove the handler, since you will connect your action created previously to the command you just created.
From here, you need to fill in all of the stub Java classes created by the wizards and you should be in business.
This is a very rough set of steps you need to do to implement the keybindinds (and, yes, it is way more complicated than it needs to be). For more detail, you can go here:
http://www.vogella.de/articles/EclipseCommands/article.html

How to modify the "new" submenu in the Eclipse Navigator?

I am pretty new to eclipse. I notice that depending on the Perspective I am in, the new submenu lists different items in it. Is there a way to pick the items it lists (modifying the perspective) just using the eclipse interface? or am I needing to do a plugin of some sort to enable this.
Go to Window >> Customize Perspective
You should be on the Shortcuts tab and should see a dropdown called Submenus:
Make sure you have the "New" submenu selected and from there you can add New shortcuts.