Extend an existing Context Menu inside Eclipse Outline View for Xtext - eclipse

We have an eclipse plugin which has been created using Xtext. And now I want to add a context menu to an Element inside the Outline View inside Eclipse. I understand that I need to have a menuContribution which will invoke a Command. But what I dont understand is, do I have to create (define) a command in some way or the other.
My plugin.xml contains an extension point for "org.eclipse.ui.menus".
Menu Contribution is something like this:
I find tutorials that talk about creating menu contributions, but there is nothing which will tie up my menuContribution to a command I want to define.

Typically you will need three extensions:
org.eclipse.ui.command
org.eclipse.ui.handlers
org.eclipse.ui.menu
It requires some fidling to get them right. I suggest you look at some open source code and starts from there.
Introduction article: http://www.vogella.com/tutorials/EclipseCommands/article.html
The locationUri of the context menu you like to contribute to should be popup:org.eclipse.xtext.ui.outline.OutlinePageContextMenu. Found here: https://github.com/eclipse/xtext-eclipse/blob/master/org.eclipse.xtext.ui/src/org/eclipse/xtext/ui/editor/outline/impl/OutlinePage.java

Related

Associate newWizard with nature of selected project

I am trying to add a contribution to the org.eclipse.ui.newWizards extension point so that the entry in the new-menu is only shown, when the selected project has a certain nature.
Is this possible only by declarative use of this extension point?
I already look for an attribute like <enabledwhen>of a menu's action but the wizard's extension point does not seem to offer this possibility.
Any ideas to achieve the said behaviour is welcome.
This is not supported. New wizards always appear everywhere.
The only thing that can be controlled is the 'shortcuts' which appear in the top level of the New menu which can be configured according to the perspective using the org.eclipse.ui.perspectiveExtensions extension point.

What is the use of # Javadoc view in eclipse

I noticed #javadoc view in my eclipse. Could you please tell me what is the use of this and how to use it.
Eclipse actually does provide decent tools for creating your own JavaDoc, which is a good idea, as then others who have to use your code will have the ability to see what it does.
There is a keyboard shortcut for adding a block for a class or method (on Mac it's Command-Shift-J I think, but search Javadoc in the key mappings.
You can define templates for adding things like links, which are pretty important, that make creation of JavaDoc go very quickly
When you document in Eclipse, it is intelligent enough to point to existing docs, so say you make an interface, you document the methods in the interface, then inside each implementer, if you created them after the interface, you will get a block that points you back to the interface
When you have added your own, or other people on your team have, this view let's you see what that will look like, so it's got a dual purpose: for making it easier to read the markup of others' JavaDoc, and for previewing your own.
The view you are showing is the Eclipse # Javadoc view. The Javadoc view shows the Javadoc of the element selected in the Java editor or in a Java view.
To use it, simply open a Java file that contains Javadoc in the Java view (or use the Java perspective). Once you do so the Javadoc view will automatically populate.

Jface TreeViewer nodes Link with files

I writing an eclipse plugin to analyze files for some defects, I get the list of java files, their classes and methods in a jface tree view, I need to open the file in the editor when I double click on the file node of the tree view.
please help me with this.
thanks,
Shasinda
You should either use a common navigator framework with corresponding filters that already has the link and open function built-in for Eclipse Resources, however, is much trickier to set up - see the blog post series starting with http://cvalcarcel.wordpress.com/2009/07/08/writing-an-eclipse-plug-in-part-1-what-im-going-to-do/
Alternatively, you could add a double click listener that opens an editor (or checks existing editors of the current workbenchpage) by looking the open editors. For the basic idea, see the corresponding Eclipse FAQ entry.
Use IDE.openEditor to open the editor.

How to remove a menu itme from menubar in eclipse rcp

I am trying to remove "project" menu from menubar dynamically, means using code. Please help me out. It will be really helpful if someone can provide the exact code.
If you are writing an RCP application you can control what goes into the main menu. If you are adding plugins that you didn't write yourself and they are using extension points to contribute to the main menu, you can use Activities/Capabilities to remove them.
You cannot remove things from the main menu programmatically, unless your code contributed it.

How to add views to Show In menu for particular file types

I use an older plugin called Veloeclipse for editing Velocity templates in Eclipse. There's been no development on this since 2009, which isn't a problem because it's mainly just for syntax highlighting and format validation. The really annoying thing about it, however, is that when I try to do Show In to view the current Velocity template within my Package Explorer or Project Explorer, the only available option is Properties. That's not really useful. I really need to be able to get to the file in one of the regular explorer views.
So I have sort of two questions:
Is there a way to configure this without having to monkey with any code? A configuration file or something? I've grepped through my Eclipse installation and haven't seen anything, but I'm hoping that there's something I'm missing.
So assuming that the answer to my first question is no, how do I go about modifying the plugin code so that it will show more than the Properties view in the Show In menu? Most of what I found on the plugin development wiki comes from the other direction: how to make your view or perspective appear in the Show In menu.
Any help with this would be hugely appreciated!
Try to check the plugin source code. it might do something different than other editors. What I mean is that the show in menu item that you have there is not the usual extension point but a hard coded context menu option.