I am stuck with this issue since yesterday. I want to disable (or hide) the default eclipse rename menu item under file contextual menu.
I was able to hide the one under right click menu using activities like:
<extension point="org.eclipse.ui.activities">
<activity id="rename.disable" name="Hidden activities">
<enabledWhen>
<not> <reference definitionId="DataEnginePlugin.testProjectNatureExtension"/></not>
</enabledWhen>
</activity>
<activityPatternBinding activityId="rename.disable" pattern="org.eclipse.ui.edit.rename"/>
</extension>
But, i am not able to disable the global one under File menu (F2).
Any ideas please!!
Thanks
The format of the pattern for the activityPatternBinding is 'contributing plugin id / item id'. Also the default pattern is a regular expression, you want an exact match here. So you want:
<activityPatternBinding
isEqualityPattern="true"
activityId="rename.disable"
pattern="org.eclipse.ui/org.eclipse.ui.edit.rename"/>
Related
I am working on an rcp application with a toolbar for quick access to certain actions, including undo and redo. My problem is that these two specific actions don't show up in the toolbar. I have located the cause to the workbench.xmi file that is generated when the application launches. A tag persistedState with an attribute key="persp.hiddenItems" contains persp.hideToolbarSC:org.eclipse.ui.edit.undo,persp.hideToolbarSC:org.eclipse.ui.edit.redo in the value="..." attribute. If I delete these entries from workbench.xmi, the undo and redo actions show up in the toolbar as they should.
My question is: What can I do so that org.eclipse.ui.edit.undo and org.eclipse.ui.edit.redo don't end up in this attribute to begin with?
I originally used eclipse neon without this problem, but when updating to eclipse 2018-12 this started happening.
Edit:
I finally got it to work by changing the IDs of my undo and redo actions to something else. I had to set the ID with setId(...) and setActionDefinedId(...) in the actions' constructors, and then the commands had to be defined in plugin.xml under <extension point="org.eclipse.ui.commands"> in a <command id="..." name="Undo"></command> tag.
This solutions feels more like a workaround than an actual solution, but it works for me.
This is set by the hiddenToolBarItem element of the org.eclipse.ui.perspectiveExtensions extension point.
The org.eclipse.ui.ide plug-in uses this to disable these tool-bar items:
<extension
point="org.eclipse.ui.perspectiveExtensions">
<perspectiveExtension targetID="*">
<!--
disable "print" button which is defined by org.eclipse.ui.actions.ActionFactory.PRINT
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="print" />
<!--
disable "undo" button which is defined by org.eclipse.ui.actions.ActionFactory.UNDO
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="org.eclipse.ui.edit.undo" />
<!--
disable "redo" button which is defined by org.eclipse.ui.actions.ActionFactory.REDO
and contributed by org.eclipse.ui.internal.ide.WorkbenchActionBuilder
-->
<hiddenToolBarItem id="org.eclipse.ui.edit.redo" />
</perspectiveExtension>
</extension>
I don't see a way to clear this other than leaving out the plug-in.
I ran into the same problem. Undo/Redo disappeared after upgrading to 2019 eclipse.
One way to override the hardcoding in org.eclipse.ui.ide global perspective setting is to modify the perspective state directly. E.g. in ApplicationWorkbenchWindowAdvisor.postWindowOpen()
WorkbenchPage page = (WorkbenchPage) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String str = page.getCurrentPerspective().getPersistedState().get(ModeledPageLayout.HIDDEN_ITEMS_KEY);
str=str.replace("persp.hideToolbarSC:org.eclipse.ui.edit.undo,", "");
str=str.replace("persp.hideToolbarSC:org.eclipse.ui.edit.redo,", "");
page.getCurrentPerspective().getPersistedState().put(ModeledPageLayout.HIDDEN_ITEMS_KEY,str);
So, for learning purposes, I am writing an eclipse plugin which should take an already existing launch configuration, and rerun it with just some new VM - attributes.
Through the org.eclipse.ui.commands extension point i was able to create the command.
<extension point="org.eclipse.ui.commands">
<command
defaultHandler="launchconfigurator.LaunchConfiguratorCommandHandler"
id="launchconfigurator.toolbar.command"
name="JCCRun">
</command>
</extension>
Next I added the button to the toolbar :
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar">
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.debug.ui.launchActionSet">
<command
commandId="launchconfigurator.toolbar.command"
icon="favicon_1_-3.png"
style="pulldown">
<visibleWhen
checkEnabled="true">
</visibleWhen>
</command>
</menuContribution>
At this point i have a button on my toolbar which shows me my button and has an arrow for a drop down menu. But when i click on the menue arrow, nothing happens...
What i want to have is exactly the same menu like the eclipse run or debug buttons have...
Does anyone know how i could aproach this?
I guess there should be something what i need to do with my plugin.xml to make eclipse see my button as a run button, but i am not sure what exactly does eclipse need...
Maybe there is some eclipse source code i could look at?
I even implemented own delegates and tab groups, which i didn't need for my execution but thought it would help... But , sadly, it didn't...
Thx in advance for your answer,
May the force be with you
The 'Run' button is defined using the old style org.eclipse.ui.actionSets extension point:
<action
id="org.eclipse.debug.internal.ui.actions.RunDropDownAction"
toolbarPath="org.eclipse.debug.ui.launchActionSet/debug"
hoverIcon="$nl$/icons/full/etool16/run_exc.png"
class="org.eclipse.debug.internal.ui.actions.RunToolbarAction"
disabledIcon="$nl$/icons/full/dtool16/run_exc.png"
icon="$nl$/icons/full/etool16/run_exc.png"
helpContextId="run_action_context"
label="%RunDropDownAction.label"
style="pulldown">
</action>
So the code that creates the Run dropdown menu is org.eclipse.debug.internal.ui.actions.RunToolbarAction. This is just a tiny class:
public class RunToolbarAction extends AbstractLaunchToolbarAction {
public RunToolbarAction() {
super(IDebugUIConstants.ID_RUN_LAUNCH_GROUP);
}
}
So this is using the more general class AbstractLaunchToolbarAction and specifying the launch group to be shown. You may be able to do something similar.
Does anybody know if there exist some implementation of some popup window, something like in Android: TOAST ?
The notifications are part of Mylyn commons.
To integrate them, add the Mylyn Commons Notifications feature from http://download.eclipse.org/mylyn/releases/latest to your target platform definition. The relevant bundles are
org.eclipse.mylyn.commons.notifications.ui
org.eclipse.mylyn.commons.notifications.core.
You can add a category and an event to the notifications extension point like this:
</extension>
<extension
point="org.eclipse.mylyn.commons.notifications.ui.notifications">
<category
icon="icons/obj16/repository.gif"
id="myNotificationCategory"
label="My Category">
</category>
<event
categoryId="myNotificationCategory"
icon="icons/obj16/some-image.gif"
id="myEvent"
label="Hello World">
<defaultHandler
sinkId="org.eclipse.mylyn.commons.notifications.sink.Popup">
</defaultHandler>
<description>
This is the description of the event.
</description>
</event>
</extension>
To trigger a notification, use the NotificationService like this:
AbstractUiNotification notification = ...
NotificationsUi.getService().notify( asList( notification ) );
The notification must be a subclass of AbstractUiNotification where the eventId passed to the constructor must match the one from the extension.
The notifications plug-in also adds a preference page under General > Notifications that lets the user choose which notifications should be shown.
No, but you can use the plugin org.eclipse.mylyn.commons.ui, which contains interesting classes to display notification(s) at the bottom right of the screen.
In eclipse's plugin extentions we can have pop up menus applicable for particular item depending on the type we specify in the nameFilter field. But now i want it to be reversed,
means I want this pop up menu not to be shown for some types of items(based on its extensions).
So is it possible. Need help badly.
Thanks
I haven't try it, but...
<viewerContribution
id="IlexGuiConsole.viewerContribution2"
targetID="IlexGuiConsole.viewerContribution2">
<action
class="ilexguiconsole.Action2"
id="IlexGuiConsole.action2"
label="label">
<enablement>
<not>
<objectClass
name="ilexguiconsole.Object2">
</objectClass>
</not>
</enablement>
</action>
</viewerContribution>
I want to write an Eclipse-plugin that performs an Action with a selected Project. I used the plugin Template with submenu. My plugin.xml looks like this :
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.core.internal.resources.Project"
id="testplugin2.contribution1">
<menu
label="Propertie Manager"
path="additions"
id="testplugin2.menu1">
<separator
name="group1">
</separator>
</menu>
<action
label="list all *.properties"
class="testplugin2.popup.actions.ListPropertiesAction"
menubarPath="testplugin2.menu1/group1"
enablesFor="1"
id="testplugin2.projectAction">
</action>
</objectContribution>
</extension>
this works fine for everything but javaProjects. It turns out that javaProjects are not Projects. I want this Action to appear when a javaProjects or a normal Projects is selected and not if something else is selected.
How can I make the submenu appeare exactly if a javaProject or a Project is selected?
I didn't test it, but maybe this works:
<objectcontribution ...>
<visibility>
<objectClass
name="org.eclipse.jdt.core.IJavaProject" />
</visibility>
</objectContribution>
You can also try "enablement" instead of "visibility".
eclipse help pages on popup menus
Make sure the adaptable property of your object contribution is set to true (it defaults to false):
adaptable="true"
#iain suggestion to target the interface is also good practice.
Just tried your example and the menus were showing as expected on a Java project.
Always bear in mind adpatability to org.eclipse.core.resources.IResource in general to ensure your menus, actions to be consistently displayed and enabled (whatever the explorer or actual object class being rendered).
Finally, beware that the org.eclipse.ui.popupMenus extension point is deprecated.
Though in my experience using it is faster and easier than the recommended org.eclipse.ui.commands, you may end up having a hard time migrating all your menus when it is removed (that is, if it is removed at some point).
Cheers,
You should not reference the internal class in you object class. You should use the public interface instead
objectClass="org.eclipse.core.internal.resources.Project"
Try
objectClass="org.eclipse.core.IProject"
I haven't tried this but IJavaProject should adapt to the IProject, so this should work for both.