I would like to add a gap between two buttons on an Eclipse toolbar. Both these buttons are defined in the plugin.xml for the plugin. I have tried specifying a separator, as per the following XML snippet, but nothing shows up.
<menuContribution locationURI="toolbar:com.bogus.viewId.MyView">
<command
commandId="com.bogus.filters.menu"
icon="icons/filter.gif"
label="Filter Menu"
style="pulldown"
tooltip="Filter Menu" />
</menuContribution>
<menuContribution locationURI="toolbar:com.bogus.viewId.MyView">
<separator name="com.bogus.separator1" />
</menuContribution>
<menuContribution locationURI="toolbar:com.bogus.viewId.MyView">
<command
commandId="com.bogus.commands.dangerous"
icon="icons/bomb.png"
label="BOOM!"
tooltip="BOOM!" />
</menuContribution>
As a side note, does anyone know where I can find a decent schema definition for the plugin.xml file? This is the best I could find so far, but its poor.
http://help.eclipse.org/galileo/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/plugin_manifest.html
So it turns out the separator element can have a 'visible' attribute and this must be set to true.
<separator name="com.bogus.separator1" visible="true" />
I found this out by random googling. Still couldn't find a decent schema definition for the plugin.xml.
Above thing is not work for me. Here is my code.
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="com.qas.testpage.toolbar">
<separator name="com.qas.separator1" visible="true">
</separator>
</toolbar>
</menuContribution>
<menuContribution locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar id="com.qas.testpage.toolbar">
<command commandId="com.qas.javatestsuite" icon="icons/qas/testjavasuite.png" tooltip="Create New Java TestSuite Project" id="com.qas.toolbar" label="Java Test Suite Project">
</command>
</toolbar>
</menuContribution>
Related
Can someone tell what is wrong with the below code. It is not working. When perspective changes it should hide respective menu item.
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.search.menu?after=xxxGroup">
<command commandId="com.xxx.udt.ui.xxxOpenFileSearchPage"
label="XXFS"
mnemonic="%XXXOpenFileSearchPage.mnemonic"
icon="icons/full/search/XXXSearchDialog.png"
helpContextId="file_search_action_context">
<visibleWhen
checkEnabled="false">
<with
variable="com.XXX.udt.ui.serviceprovider.ShowActions">
<equals
value="showAction">
</equals>
</with>
</visibleWhen>
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="com.XXX.udt.ui.MCPOpenFileSearchPage"
class="com.XXX.udt.ui.MCPOpenFileSearchPage">
</handler>
</extension>
The visibleWhen expression to check the current perspective is something like:
<visibleWhen>
<with
variable="activeWorkbenchWindow.currentPerspective">
<equals
value="org.eclipse.pde.ui.PDEPerspective">
</equals>
</with>
</visibleWhen>
This particular expression is testing for the Plug-in Development perspective.
Please refer to https://wiki.eclipse.org/Command_Core_Expressions for clear usage of visible-when and enable-when conditions..
I'm trying to hide tab created by us in search widget when perspective changed to some other perspective. I trying put some condition in plugin.xml page but didn't succeed in that. Below is the extension I have to hide.
<extension
point="org.eclipse.search.searchPages">
<page
canSearchEnclosingProjects="true"
class="com.xxx.udt.ui.MCPFileSearchPage"
icon="icons/full/search/xxx.png"
id="com.xxx.udt.ui.page2"
label="MCP Search"
showScopeSection="false"
tabPosition="1">
<!-- <enabledWhen>
<with variable="com.xxx.udt.ui.serviceprovider.ShowActions">
<equals
value="showAction">
</equals>
</with>
</enabledWhen> -->
</page>
<enabledWhen>
<with variable="com.xxx.udt.ui.serviceprovider.ShowActions">
<equals value="showAction"/>
</with>
</enabledWhen>
The org.eclipse.search.searchPages extension point does not support hiding pages based on the perspective (or anything else).
Steps to hide menu item in search menu :
1>Create a menu contribution.
2>create a command for the same.
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.ui.main.menu?after=navigate" >
<menu label="Search"
id="org.eclipse.search.menu"
>
<command commandId="com.unisys.udt.ui.OpenFileSearchPage"
label="%action.FileSearch"
mnemonic="FS"
icon="icons/full/search/SearchDialog.png"
id="com.unisys.udt.ui.OpenFileSearchPage">
</command>
<visibleWhen
checkEnabled="false">
<with
variable="com.udt.ui.serviceprovider.ShowActions">
<equals
value="showAction">
</equals>
</with>
</visibleWhen>
</menu>
</menuContribution>
</extension>
3>create a handler.
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.udt.ui.handlers.OpenFileSearchHandler"
commandId="com..udt.ui.OpenFileSearchPage">
</handler>
4>create one activitypattern binding for the same.
<activityPatternBinding
activityId="xxx.contributions"
isEqualityPattern="true"
pattern="com.udt.ui/com.udt.ui.OpenFileSearchPage">
I have written a simple Eclipse plug-in and wanted to extend the Refactor (alt+shit+T) menu with a new item that would invoke my code.
Unfortunately, after having spent hours researching the possible solutions, I have failed.
I tried some solutions suggested online, but none worked, maybe because I'm using the latest Eclipse Luna and from what I understand the refactoring menu is (was?) defined as something called action sets, and it's apparently deprecated now.
I was able to extend the top-level popup menu using the new commands API, but that's not what I want.
I would just love to see a working example of plugin.xml that adds a custom item to the Refactor popup menu.
Just for the reference, this doesn't work:
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="menu:org.eclipse.jdt.ui.refactoring.menu?after=typeGroup">
<command
commandId="mycommandid"
label="mycommandlabel">
</command>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<command
id="mycommandid"
name="mycommandname">
</command>
</extension>
<extension point="org.eclipse.ui.handlers">
<handler
class="MyHandlerClass"
commandId="mycommandid">
</handler>
</extension>
Try this
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
id="org.forsp.StringHelper.contribution1"
nameFilter="*.*"
objectClass="org.eclipse.ui.IEditorInput">
<menu
id="org.forsp.StringHelper.menu1"
label="Menu"
path="additions">
<separator
name="group1">
</separator>
</menu>
<action
class="org.forsp.stringhelper.popup.actions.NewAction"
enablesFor="1"
id="org.forsp.StringHelper.newAction"
label="New Action"
menubarPath="org.forsp.StringHelper.menu1/group1">
</action>
</objectContribution>
</extension>
I'm trying to contribute a menu item to the Configure menu item/group in Project Explorer.
The following snippet adds my menu item to the same level. Adding <menu label="Configure" /> between <menuContribution ...> and <command ...> creates a duplicate Configure menu item.
What am I doing wrong?
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="com.example.convert" label="Convert to XXX Project..." />
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<command id="com.example.convert" defaultHandler="com.example.ConvertAction" name="Convert to XXX Project" />
</extension>
</plugin>
Using org.eclipse.ui.menus is the more future-safe way so I prefer that whenever I have a choice.
Set the locationURI to popup:org.eclipse.ui.projectConfigure
If you need to find the locationURI of any menu press Alt+Shift+F2, then open the menu as usual and click where you want to insert.
You should be using org.eclipse.ui.popupMenus extension point and adding an objectContribution.
Here's a simplified snippet in the plugin.xml that we are using inside of AJDT to contribute to the configure menu. You should be able to use something like this for your project.
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.resources.IProject"
adaptable="true"
id="iprojectcontributions">
<menu
label="%org.eclipse.ajdt.ui.tools"
id="org.eclipse.ajdt.ui.project.tools">
<separator
name="group0">
</separator>
</menu>
<visibility>
<and>
<objectState name="nature" value="org.eclipse.jdt.core.javanature"/>
<not>
<objectState name="nature" value="org.eclipse.ajdt.ui.ajnature"/>
</not>
<objectState name="open" value="true"/>
</and>
</visibility>
<action
label="%convertToAJP"
class="org.eclipse.ajdt.internal.ui.actions.AddAJNatureAction"
menubarPath="org.eclipse.ui.projectConfigure/additions"
id="addajnatureaction">
</action>
</objectContribution>
</extension>
I have developed a plugin in eclipse that adds an option when user right clicks on a file. But it shows up only in java perspective and not any in other. Can anyone please tell me the reason?
Here is my plugin.xml:
<?xml version="1.0"?>
<plugin>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="plugin.showDifferences" label="Show Differences" style="push">
<activeWhen>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="*.java"/>
</adapt>
</iterate>
</activeWhen>
</command>
</menuContribution>
</extension>
<extension point="org.eclipse.ui.commands">
<command defaultHandler="plugin_demo.Differences" id="plugin.showDifferences" name="Differences" />
</extension>
</plugin>
This is because the Java perspective's Package Explorer view is a different beast than the Project Explorer view that appears in the other perspectives. If you want your right-click option to appear in both views, you'll have to add another <menuContribution> that contributes it to the org.eclipse.ui.navigator.ProjectExplorer view. Something like this:
<menuContribution locationURI="popup:org.eclipse.ui.navigator.ProjectExplorer#PopupMenu?after=additions">
<command commandId="plugin.showDifferences" label="Show Differences" style="push">
<activeWhen>
<iterate>
<adapt type="org.eclipse.core.resources.IResource">
<test property="org.eclipse.core.resources.name" value="*.java"/>
</adapt>
</iterate>
</activeWhen>
</command>
</menuContribution>