Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Re: visibleWhen of a menuContribution based on view selection
Re: visibleWhen of a menuContribution based on view selection [message #667624] Sat, 30 April 2011 04:32 Go to next message
Deepak Azad is currently offline Deepak AzadFriend
Messages: 545
Registered: July 2009
Senior Member
On 4/30/2011 12:09 AM, wrote:
> Hi all!
> I've searched the forum but did not find a feasible solution for my
> problem.
> I'm defining a menuContribution to a view toolbar. I've added a
> visibleWhen element and used a with(var=selection) element. This works
> fine when I change the selection in the view, but also let's the
> menuContribution disappear when the view looses it's focus.
> Is there a way to say: I want the contribution to be visible when the
> selection in view A is an instanceof class B...
> Any help is appreciated!
> Markus

This question should be asked in the Platform forum, copying there.
Re: visibleWhen of a menuContribution based on view selection [message #667776 is a reply to message #667624] Mon, 02 May 2011 07:45 Go to previous messageGo to next message
Markus Bischof is currently offline Markus BischofFriend
Messages: 11
Registered: January 2011
Junior Member

Sorry, we do a lot of JDT-things so I was focused on the JDT forum! Smile

So, can anyone give me a hint how to define the following statement through a visibleWhen-expression:

The menuContribution with locationURI 'toolbar:VIEWID?after=addtions" with the command COMMANDID should be visible, when the selection in view VIEWID is of type CLASS.


[Updated on: Mon, 02 May 2011 07:57]

Report message to a moderator

Re: visibleWhen of a menuContribution based on view selection [message #667851 is a reply to message #667776] Mon, 02 May 2011 12:46 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

The application state in eclipse in 3.x is global, which means if you
are looking at the selection, you'll see the selection of the active
part (which most of the time will not be your class B).

A slightly less confusing option would be to make your tool item always
visible and tie its enabled state to your view selection.

The other alternative is to write a property tester that tracks down
your view and asks for its selection:

<test property="com.example.testViewSelection"/>

And allow that your property applies to java.lang.Object. See my sig
for some links, and the org.eclipse.core.expressions.propertyTesters
extension point description. From the property tester method, you can
use any number of API to get the active IWorkbenchPage, and find your
view to check its selection directly.


Paul Webster platform.doc.isv/guide/workbench.htm

Previous Topic:Invoke Ant file with AntRunner
Next Topic:Listener to Auto-Refresh
Goto Forum:

Current Time: Mon May 28 10:02:38 GMT 2018

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

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

Back to the top