Removing context menu entry in Eclipse PDE using Activities - eclipse

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.

Related

The command is not visible in my eclipse plugin

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.

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

Optional extension points in plugin.xml

I want to define an extension point in my plugin.xml which is not available in my target platform. This is fine for me, because I want to take advantage of it only if it's available .
However ,when I add it Eclipse flags it with an error
Unknown extension point: 'org.eclipse.ui.trace.traceComponents'
Can I somehow mark this extension point as optional? I know that I can reduce the Unresolved extension points severity per-workspace or per-project, but I'd rather not do that for just one error.
The complete plugin.xml is
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="org.apache.sling.slingclipse.preferences"
name="Slingclipse Preferences"
point="org.eclipse.ui.preferencePages">
<page
name="Slingclipse"
class="org.apache.sling.slingclipse.preferences.SlingclipsePreferencePage"
id="org.apache.sling.slingclipse.preferences.defaultPreferences">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.apache.sling.slingclipse.preferences.PreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.ui.startup">
<startup
class="org.apache.sling.slingclipse.SlingclipseStrartup">
</startup>
</extension>
<extension
point="org.eclipse.ui.importWizards">
<category
id="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
name="Sling">
</category>
<wizard
category="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
class="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
icon="icons/sample.gif"
id="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
name="Import from Repository">
<description>
Import a file from the local file system into the workspace.
</description>
</wizard>
</extension>
<extension
point="org.eclipse.ui.trace.traceComponents">
<component
id="org.eclipse.ui.trace.tracingPrefPage"
label="Slingclipse">
<bundle
name="org.apache.sling.slingclipse"></bundle>
</component>
</extension>
</plugin>
You are mixing two concepts here: Development time versus runtime.
Extension points are dependencies declared at development time. Therefore you should have the plugin defining that extension point in your target platform at development time. But you are right, you can generally write the manifest XML for extending that extension point without it being available. In practice this does not work well because many extension points require to implement an interface which itself is also defined in the (non existing) plugin.
To make the functionality be optional for a user (and to not force him to have the defining plugin), you need to make the installation of your plugin optional. But that is not related to the manifest and the use of extension points at all. E.g. you have to declare a feature containing your plugin and make that feature depend on the feature containing the plugin defining the extension point.

Hiding context menu

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

A working example of custom p2 provisioning action

I’m trying to write a custom p2 provisioning action to execute my own code when installing feature. Doing so with installHandler for Update Manager was easy, but as for p2, there’s absolutely no docs on this topic in the web, most of the time eclispe just silently ignores me (even in a log), and the only example I’ve found is not working.
So, if somebody can point me at a working example of custom provisioning action, that would help me understand the whole thing.
Thanks.
Finally, I’ve got it working somehow:
example_plugin:
plugin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.5"?>
<plugin>
<extension point="org.eclipse.equinox.p2.engine.touchpoints" id="example" name="Eclipse Touchpoint">
<touchpoint type="com.company.example.plugin" class="org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint" version="1.0"/>
</extension>
<extension point="org.eclipse.equinox.p2.engine.actions">
<action
class="com.company.example.plugin.CustomAction"
name="do_custom_action"
touchpointType="com.company.example.plugin"
touchpointVersion="1.0"
version="1.0">
</action>
</extension>
</plugin>
META-INF\p2.xml:
provides.0.namespace=com.company.example.plugin
provides.0.name=do_custom_action
provides.0.version=1.0
example_feature:
feature.xml:
<?xml version="1.0" encoding="UTF-8"?>
<feature id="com.company.example.feature" label="Maven installer feature" version="2.2.1.qualifier">
<description url="http://www.example.com/description">[Enter Feature Description here.]</description>
<copyright url="http://www.example.com/copyright">[Enter Copyright Description here.]</copyright>
<license url="http://www.example.com/license">[Enter License Description here.]</license>
<requires>
<import plugin="com.company.example.plugin"/>
</requires>
<plugin
id="com.company.example.plugin"
download-size="0"
install-size="0"
version="0.0.0"
unpack="false"/>
</feature>
p2.inf:
metaRequirements.0.namespace=com.company.example.plugin
metaRequirements.0.name=do_custom_action
metaRequirements.0.range=1.0
instructions.configure = com.company.example.plugin.do_custom_action();
General comments:
Custom touchpoint action is stored in a plugin as a regular class.
Update site must contain proper artifacts.jar/content.jar (don’t know why, took a lot of time to debug this).
If you want to let your touch point action working, there are two approaches,
install your plug-in firstly that provides the new touchpoint action. Then install the contents from the repository using the new touchpoint action.
the iu depending on the new touchpoint action need require the bundle provides the new touchpoint action, it exactly likes what you found. See the example code attached by Simon Kaegi