Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » perspective shortcuts in menus (commands) without "other.."(How can I add a Menu with perspecitves shortcuts and without the "other.." entry)
perspective shortcuts in menus (commands) without "other.." [message #544693] Mon, 05 July 2010 09:45 Go to next message
Christian  is currently offline Christian Friend
Messages: 2
Registered: July 2010
Junior Member
Hallo,

I am looking for a possibility to

1. add perspecitves shortcuts to a menu using commands (e.g. to build something like the Eclispe "Window"-> "Show Perspective" menu.

Only possibility I found that far is to use ContributionItemFactory.PERSPECTIVES_SHORTLIST.create(window ); in ApplicationActionBarAdvisor.java

Is there an approach that uses commands only? It is a little bit "unaesthetic" to have two places in the quellcode to maintain menus.

2. Remove the "other.." entry from the PERSPECTIVE_SHORTLIST. Since I am restricting the user, based on his roles, to specific perspectives I obviously don't want him to see all other perspectives, but that's what this "other..." menu does: Show ALL perspectives...

thanks in advance

Chrisitan aka Mable
Re: perspective shortcuts in menus (commands) without "other.." [message #544852 is a reply to message #544693] Mon, 05 July 2010 17:34 Go to previous messageGo to next message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Take a look here http://eclipsesource.com/blogs/2009/03/31/replacing-the-pers pective-switcher-in-rcp-apps/

As you will see in the article it's a dynamic menu contribution that extracts the perspectives list from the PerspectiveRegistry. You can take all the perspectives and put them in a menu or you could easily take only the one that follow a naming rule (in my case I needed only the perspectives ending a specific word).

HTH
Catalin Gerea


Time is what you make of it.
Re: perspective shortcuts in menus (commands) without "other.." [message #544892 is a reply to message #544852] Mon, 05 July 2010 22:24 Go to previous messageGo to next message
Christian  is currently offline Christian Friend
Messages: 2
Registered: July 2010
Junior Member
Yes, I got that link also from a colleague today.

That solves my problem, though I find it kind of irritating, that there is no command to achieve this, or at least to display the standard "show perspective" menuitem (especially with so many people being commited to get Actions marked as deprecated)...

Anyway that solution does work and if it's the best way to go, so be it.

Thanks for the fast reply

[Updated on: Mon, 05 July 2010 22:25]

Report message to a moderator

Re: perspective shortcuts in menus (commands) without "other.." [message #545144 is a reply to message #544892] Tue, 06 July 2010 18:20 Go to previous message
Catalin Gerea is currently offline Catalin GereaFriend
Messages: 89
Registered: July 2009
Location: Bucharest, Romania
Member

Hello Christian

I used a dynamic menu contribution because in my case the number in the perspectives can be changed dynamically. Also it had the advantage that I could do a little customization otherwise not possible.

But if you have a fixed number of perspectives you can go for the extension point approach: define a command that has the handler the ShowPerspectiveHandler class.
Then put the menu entry has has the command defined above with the correct parameter (the name of the perspective to be opened).
Then add the visibleWhen conditions based on the user roles.
This approach has the disadvantage that when you add a new perspective to the application you have to add a new menu entry (double work).

There is also the possibility to have the command defined in code and not via extension point. The same goes for the handler.

Take a look at the following classes: PerspectiveMenu, ChangeToPerspectiveMenu and ShowPerspectiveHandler to see how the opening of the perspective is handled via code and how the perspectives shortcuts are added to the menu (including the 'Other...' menu entry).

HTH
Catalin Gerea


Time is what you make of it.
Previous Topic:How do I set initial RCP window size
Next Topic:Missing requirement problem
Goto Forum:
  


Current Time: Thu Apr 25 21:44:06 GMT 2024

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

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

Back to the top