Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Enabling contribution items to a view toolbar by selection in this view(With the command/handler/menuContribution pattern it is possible to enable/disable a toolbar item depending on the selection in the active part of the active window. However, with multiple views this )
Enabling contribution items to a view toolbar by selection in this view [message #1131076] Thu, 10 October 2013 06:57
Michael Gruebsch is currently offline Michael GruebschFriend
Messages: 16
Registered: March 2012
Junior Member
I have two (or more) Eclipse views defined. Each of these views has its own selection provider, e.g. a JFace table viewer:


In plugin.xml contribution items are placed at the toolbar of each view, e.g.:


The handler of the contribution items are enabled with respect to the current selection, e.g.:


Because the variable "selection" is a global workspace variable I have the following situation at the moment: If view A has a selected entry but is not active and if view B is active but has no selected entry both contribution items (in A as well as in B) are disabled. To enable the contribution item in A the user has to activate the view A (setting the workspace variable "selection" to the actual selection of A). This is confusing for inexperienced users.

How is it possible to control enabling of a contribution item which belongs to a certain view only by the selection in this view?

I would like to use declarative contribution items and not actions defined programmatically in the view itself.

Moreover, I want to avoid the extra burden of defining special workspace variables for each view (org.eclipse.ui.ISourceProvider). These workspace variables would be a solution if for the view class there were only one instance. If multiple instances of a view class are allowed we have the same problem.

I know that the required behaviour is possible with the extension point org.eclipse.ui.viewActions. However this extension point is deprecated as of Kepler.

Is there a solution using declarative contribution items?

Thank you - Michael

PS: I have posted a similar question on SO but have received no answer until now.

[Updated on: Thu, 10 October 2013 07:02]

Report message to a moderator

Previous Topic:Plugins from "dropins" not installed
Next Topic:editing labels in Eclipse
Goto Forum:

Current Time: Tue Oct 06 20:39:19 GMT 2015

Powered by FUDForum. Page generated in 0.01982 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software