Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Menu visible when selection is a subclass of StructuredSelection(visibleWhen on subtypes of StructuredSelection)
Menu visible when selection is a subclass of StructuredSelection [message #546977] Wed, 14 July 2010 19:34 Go to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: February 2010
Junior Member
I have a class: MyStructuredSelection (extends StructuredSelection).

Under certain circumstances I set the selection as an instance of MyStructuredSelection using:

getSite.getSelectionProvider.setSelection(new MyStructuredSelection(...))

I would like to have certain menu contributions visible only when the selection is an instance of MyStructuredSelection.

Is there a way to do set menu visibility based on the type of the selection?

Thank you
Mark Lovell
Re: Menu visible when selection is a subclass of StructuredSelection [message #547069 is a reply to message #546977] Thu, 15 July 2010 12:12 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

Do you mean org.eclipse.ui.menus/menuContributions? visibleWhen (core
expressions) supports <instanceof />

PW

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


Re: Menu visible when selection is a subclass of StructuredSelection [message #547129 is a reply to message #547069] Thu, 15 July 2010 15:58 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 8
Registered: February 2010
Junior Member
Thank you for replying.

Yes I am using org.eclipse.ui.menus/menuContributions.

The visibleWhen processes the objects in the selection's list (selection.toList()) not the selection object (ISelection) itself.

Therefore "instanceof" acts on the objects within the selection's list.

I am hoping to find a way to set a menu's visbility based on the type of the selection (ex MyStructuredSelection extends StructuredSelection) regardless of the objects it contains.

Thoughts?

Re: Menu visible when selection is a subclass of StructuredSelection [message #547158 is a reply to message #547129] Thu, 15 July 2010 17:29 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

mark.lovell@cae.com wrote:

> The visibleWhen processes the objects in the selection's list
> (selection.toList()) not the selection object (ISelection) itself.
> Therefore "instanceof" acts on the objects within the selection's list.

use <variable with="selection"... or <variable
with="activeMenuSelection" as appropriate.

The default variable for visibleWhen is a Collection with the contents
of the selection.

PW


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


Re: Menu visible when selection is a subclass of StructuredSelection [message #547161 is a reply to message #547158] Thu, 15 July 2010 18:05 Go to previous message
No real name is currently offline No real nameFriend
Messages: 8
Registered: February 2010
Junior Member
variable with="selection"... works perfectly.

Thank you very much
Very Happy

Previous Topic:Lauch Configuration
Next Topic:The project was not built since the source file ... could not be read
Goto Forum:
  


Current Time: Tue Apr 16 04:50:54 GMT 2024

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

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

Back to the top