Hiding context menu - eclipse

One of my plugins depends on WST which has 'Validate' menu item. I tried hiding this menu item using activities, but so far was no successful. Any ideas what am I doing wrong?
Using plug-in spy, I am pretty sure menu is contributed by org.eclipse.wst.validation.internal.ui.ValidationMenuAction
Here is what I did:
<extension
point="org.eclipse.ui.activities">
<activity
id="com.iwaysoftware.integration.tools.validationActivity"
name="validation activity">
</activity>
<activityPatternBinding
activityId="com.iwaysoftware.integration.tools.validationActivity"
pattern="org.eclipse.wst.validation.ui/org.eclipse.wst.validation.internal.ui.ValidationMenuAction">
</activityPatternBinding>
<category
id="com.iwaysoftware.integration.tools.validationCategory"
name="validation category">
</category>
<categoryActivityBinding
activityId="com.iwaysoftware.integration.tools.validationActivity"
categoryId="com.iwaysoftware.integration.tools.validationCategory">
</categoryActivityBinding>

easiest way to remove the validate option is to remove following 3 jars from your plugins folder:
org.eclipse.wst.validation.infopop_1.0.300.v201309101952.jar
org.eclipse.wst.validation.ui_1.2.500.v201310231452.jar
org.eclipse.wst.validation_1.2.600.v201501211647.jar

Related

How to hide help content in an eclipse RCP?

In my eclipse based RCP Application, I want to hide unwanted help contents.
The help content is added via the org.eclipse.help.toc extension point from other plug-ins.
<extension point="org.eclipse.help.toc">
<toc file="help/toc.xml" primary="true">
</toc>
</extension>
I tried to disable it by activities:
<extension point="org.eclipse.ui.activities">
<activity id="disable" name="Disable">
</activity>
<activityPatternBinding activityId="disable"
pattern=".*/org.eclipse.help.toc">
</activityPatternBinding>
</extension>
But no success.
Help content contributions cannot be controlled by activities.
You simply need to exclude the help plug-ins (e.g. org.eclipse.jdt.doc.* for JDT documentation) from the runtime and the corresponding TOC entries will vanish.
I had the same issue and found the solution. You have to set the content to be hidden with HELP_DATA (link).
Here's my helpData.xml content:
<extensions>
<hidden>
<toc id="/org.eclipse.platform.doc.user/toc.xml"/>
</hidden>
</extensions>
and then refer to it in plugin_customization.ini:
org.eclipse.help/HELP_DATA = helpData.xml
and reference your plugin_customization.ini in your eclipse.ini or in the vm arguments of your launch config as
-Declipse.pluginCustomization=${workspace_loc}/com.castortech.iris.vision/plugin_customization.ini

Is there any way to add a shortcut key in eclipse from plugin on runtime?

I am developing a plugin in eclipse . Currently we are using "org.eclipse.ui.bindings" extension point for providing shortcut keys . But it's a static option for providing shortcut key for action . Our user's face some difficulty to using my plugin without shortcut keys . Is there any option to add a shortcut keys on runtime via eclipse plugin ?.
<extension
point="org.eclipse.ui.commands">
<category
name="ZMedia Shortcuts Category"
id="com.zmedia.viewer.commands.category">
</category>
<command
name="Update Zmedia Deployable Instances"
categoryId="com.zmedia.viewer.commands.category"
id="com.zmedia.viewer.commands.UpdateZmediaDeployableInstances">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.zmedia.viewer.handlers.UpdateZmediaDeployableInstances"
commandId="com.zmedia.viewer.commands.UpdateZmediaDeployableInstances">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
commandId="com.zmedia.viewer.commands.UpdateZmediaDeployableInstances"
sequence="M1+M2+ESC">
</key>
</extension>
The extension point description explicitly denies that:
API Information:
There is no public API for defining bindings. To try to achieve stability for the user, bindings are only defined through the extension points. If you are an RCP application, you should be able to override this behaviour in the WorkbenchAdvisor.

Removing context menu entry in Eclipse PDE using Activities

I am using org.eclipse.ui.activities to remove certain context menu entries.
I was successful in removing
Team, Show in Remote Systems View, Restore From Local History
by using the below in my plugin.xml
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.activities">
<activity description="Disable Menu/Context Menu Contributions"
id="com.myapp.myactivity" name="MyViewActivity">
</activity>
<activityPatternBinding activityId="com.myapp.myactivity"
pattern="org.eclipse.team.*"/>
<activityPatternBinding activityId="com.myapp.myactivity"
pattern="org.eclipse.rse.*"/>
<activityPatternBinding activityId="com.myapp.myactivity"
pattern="org.eclipse.compare.*"/>
</extension>
</plugin>
I need to remove the "Profile As" , "Source" , "Configure" entries. I've used plugin spy of eclipse and was able to get the associated class and it's plugin jar like for e.x
<activityPatternBinding activityId="com.myapp.myactivity"
pattern="org\.eclipse\.ui\.workbench/org\.eclipse\.jst\.servlet\.ui\.internal\.actions\.ConvertToWebModuleTypeAction"/>
for Removing Configure->Convert To Dynamic Web Project Entry in the context menu but this doesn't work. Am I missing something here?
From Plugin Spy
The active contribution item identifier:
convertToWebModuleTypeAction
The active contribution location URI:
menu:org.eclipse.ui.projectConfigure?after=convertToWebModuleTypeAction
The active contribution item class:
ConvertToWebModuleTypeAction
The contributing plug-in:
org.eclipse.ui.workbench (3.7.1.v20120104-1859)
Any Help to remove the entries above (i.e Profile As, Source, Configure) will be really appreciated.

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>

How to add a context menu to existing "File" menu in Eclipse Plugin development?

In Eclipse main menu how to contribute to an existing Main Menu for ex need to create a context menu under Main menu "File" . What is the location URI "File"
The location URI for the file menu is menu:file.
See org.eclipse.ui.internal.ide.WorkbenchActionBuilder for information about the different sections and IDs...
Here is an example how to add submenu to File menu:
<extension
point="org.eclipse.ui.actionSets">
<actionSet
id="com.my.plugin.actionSet"
label="My ActionSet"
visible="true">
<menu
id="mymenu"
label="My Menu"
path="file/fileEnd">
<groupMarker
name="start">
</groupMarker>
<separator
name="additions">
</separator>
</menu>
<action
class="com.my.plugin.ActionClass"
id="com.myplugin.action"
label="Action"
menubarPath="file/mymenu/start"
style="push">
</action>
</actionSet>
</extension>
Constants for positioning MyMenu within File menu could be found at org.eclipse.ui.IWorkbenchActionConstants
Cheers,
Max