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: 543
Registered: July 2009
Senior Member
On 4/30/2011 12:09 AM, markusbischof82@gmail.com 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
Hi!

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.

Markus

[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:

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

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.

PW


--
Paul Webster
http://wiki.eclipse.org/Platform_Command_Framework
http://wiki.eclipse.org/Command_Core_Expressions
http://wiki.eclipse.org/Platform_Expression_Framework
http://wiki.eclipse.org/Menu_Contributions
http://wiki.eclipse.org/Menus_Extension_Mapping
http://help.eclipse.org/helios/index.jsp?topic=/org.eclipse. platform.doc.isv/guide/workbench.htm


Previous Topic:problem while creating a jar file
Next Topic:Why can't I use any update sites with 3.6.2 on Windows Vista
Goto Forum:
  


Current Time: Fri Apr 26 12:59:32 GMT 2024

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

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

Back to the top