The command is not visible in my eclipse plugin - eclipse

I am new to Eclipse plugin development. Recently, I downloaded a completed source code of an Eclipse plugin from another team. The popup menu of the plugin is not visible, so I just created a simple popup-menu-command for testing.
In the project, I only changed the plugin.xml to :
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
description="some description"
id="com.something.aCommand"
name="somet name">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="com.something.aCommand"
label="Create HTML" style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.something.aHandler"
commandId="com.something.aCommand">
</handler>
</extension>
</plugin>
(The aCommand and aHandler are nicknames of the real command and handler which do exist)
This sample is similar to the example here http://www.vogella.com/tutorials/EclipsePlugin/article.html#extending-the-eclipse-ide
And I tested it by Run as-> Eclipse Appliication, the right-click-pupup-command "Create HTML" is not visible.
Besides, this project does not contain fragment.e4mi file, does this mean it is a Eclipse 3 plug-in ? Because I find almost all eclipse plug-in tutorials are using fragment.e4mi and the e4 model fragment UI.
Environment:
Windows 10 64-bits
Eclipse Oxygen.1a Release (4.7.1a)

This is basically OK but is only contributing to the Package Explorer view (id org.eclipse.jdt.ui.PackageExplorer)
For Project Explorer to context menu id is org.eclipse.ui.navigator.ProjectExplorer#PopupMenu.
You can also use popup:org.eclipse.ui.popup.any to contribute to any menu.

Related

Add menu entry to Configure menu in Eclipse

I develop an Eclipse plug-in and I need to add an entry to the Configure menu. I don't find any way to do this.
My plug-in extension look like this:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
locationURI="menu:org.eclipse.ui.projectConfigure?after=org.eclipse.m2e.enableNatureAction">
<command
commandId="org.tatami.commands.commandConfigure"
label="Convert to Tatami Project"
style="push">
</command> tooltip="Convert to Tatami Project">
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="tatami.commands.ConfigureHandler"
description="Ajouter le framework de test Tatami au Projet"
id="org.tatami.commands.commandConfigure"
name="Convert to Tatami Project">
</command>
</extension>
Do you find any error in my code?
did you find any error when starting ?
You could try :
locationURI="popup:org.eclipse.ui.projectConfigure?after=additions">

Showing submenuItem from "New"Menu in Both PackageExplorer and ProjectExplorer

In Eclipse plugin.xml,how to make a submenuItem from New Menu to be visible not only in project explorer but also in package explorer.
My source code is ...
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
locationURI="popup:common.new.menu?after=additions">
<command
commandId="org.eclipse.ui.newWizard"
icon="icons/schema-file_16x16.png"
label="%schemaFile.command.label"
style="push">
</command>
</menu>
</extension>
But this submenu is only visible in ProjectExplorer, but not in PackageExplorer.
How to do to be visible in both package and project. If someone know the code please share to me.

Standard Menu does not appear on eclipse plugin

I am writing an Eclipse plugin for which I want to re-use the File > New... menu leading to the wizard to include my start menu's. For this, I have the following simple code:
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="false"
locationURI="menu:file">
<menu label="New">
<command
commandId="org.eclipse.ui.file.newQuickMenu">
</command>
</menu>
</menuContribution>
</extension>
My expectation is that I should see File > New... But no such menu appears. What am I missing?

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

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
In the end it was really straight forward. The example below uses the command framework. It doesn't have the handlers, so just click the class hyperlink whenever you need a class generated.
Create a new eclipse plugin project called com.test.plugin.project
In the dependency tab of the plugin.xml file add the following dependencies
org.eclipse.jdt
org.eclipse.jdt.core
org.eclipse.jdt.ui
org.eclipse.jface.text
Put this in the plugin.xml tab section:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.menus">
<menuContribution
allPopups="true"
locationURI="popup:org.eclipse.ui.popup.any">
<menu
label="Test Project Sub Menu">
<command
commandId="com.test.plugin.project.command.packageexplorer"
id="packageexplorerId"
style="push">
<visibleWhen
checkEnabled="false">
<iterate
ifEmpty="false"
operator="or">
<instanceof
value="org.eclipse.jdt.internal.core.CompilationUnit">
</instanceof>
</iterate>
</visibleWhen>
</command>
<command
commandId="com.test.plugin.project.command.classfile"
id="classfileId"
style="push">
<visibleWhen
checkEnabled="false">
<iterate
ifEmpty="false"
operator="or">
<and>
<with
variable="selection">
<instanceof
value="org.eclipse.jface.text.TextSelection">
</instanceof>
</with>
<with
variable="activeEditorId">
<equals
value="org.eclipse.jdt.ui.CompilationUnitEditor">
</equals>
</with>
</and>
</iterate>
</visibleWhen>
</command>
</menu>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
id="com.test.plugin.project.command.packageexplorer"
name="Only Show In Package Explorer">
</command>
<command
id="com.test.plugin.project.command.classfile"
name="Only Show In Class File">
</command>
</extension>
</plugin>
What this does
It creates one popup menu in a sub menu when you right click on a java file inside the package explorer (and only when you click on a java file).
It create a different popup menu in a sub menu when you right click on a java file.

How to extend the source menu in Eclipse? (or: What is its locationURI?)

I am developing an eclipse plugin and trying to extend the source menu (mainMenubar/Source - visible when editing in the java-editor) in Eclipse 3.7.
The documentation says to rely on the org.eclipse.ui.menus-extension point since the older extension points are deprecated. It is a complete secret to me where to obtain reliable locationURIs, but I finally managed to find some plausible URI with the Plugin Spy (following an advice here).
So the following should be the extension snippet for the plugin.xml:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.jdt.ui.source.menu">
<command
commandId="some.command.id"
label="Some label"
style="push">
</command>
</menuContribution>
</extension>
Unfortunately, when running the plugin for my development IDE no command appears, and also no error message. Just nothing happens. When I set the locationURI to "menu:help", the new command appears in the help menu, so the problem seems to be really the locationURI.
This thread reports having added an entry in the main Source menu:
<!-- main menu -->
<extension point="org.eclipse.ui.actionSets">
<actionSet label="Java Coding"
description="Action set containing coding related Java actions"
visible="true"
id="org.eclipse.jdt.ui.CodingActionSet2">
<menu label="&Source"
path="edit"
id="org.eclipse.jdt.ui.source.menu">
</menu>
<action class="org.gsoc.eclipse.tostringgenerator.actions.GenerateToStringActionDelegate "
id="org.gsoc.eclipse.tostringgenerator.action"
label="Generate to&String()..."
menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup">
</action>
</actionSet>
</extension>
I ran into the same problem. I finally figured out that extending the Source menu using the (recommended) extension point org.eclipse.ui.menus is not possible.
The reason is that a menu defined in an old style actionSet (like the Source menu) is created after the processing of org.eclipse.ui.menus-extensions. The way it is, these extensions can only contribute to already existing menus.
So sticking to the old API (as suggested by VonC) is probably the best option until the jdt plugin is migrated to the new approach...
You can use the popup: space instead of the menu: space. Here is a working example:
<extension point="org.eclipse.ui.commands">
<command defaultHandler="com.igenox.plugin.dpbuilder.rcp.handler.CreateBuilderHandler"
id="com.igenox.plugin.DPBuilder.CreateBuilderPattern" name="CreateBuilderPattern">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.source.menu?after=DPSeparator">
<command commandId="com.igenox.plugin.DPBuilder.CreateBuilderPattern"
id="createBuilder" label="Create Builder Pattern">
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.source.menu?after=additions">
<separator name="DPSeparator" visible="true">
</separator>
</menuContribution>
</extension>