Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Plugin Development Environment (PDE) » How do I get different togglestates of a command between views
How do I get different togglestates of a command between views [message #893562] Wed, 04 July 2012 14:52 Go to next message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Hi there,

I have an RCP application (using indigo) with multiple navigation views (some of them also multi-instance). Those views all need to have a common command, lets call it 'alphasort'.
This command should be a toggle command and should appear in the toolbars & menus of all the views. Most of the time there are at least two views visible (parallel to each other for Drag&Drop).

The command has a default handler doing the same on every view (setting special sorter). What I want to have is that there is a toggle-state for this command for every view, not a single togglestate for the command.
Right now i have a single togglestate so that toggling in one view will toggle the command in the other views too. I read this behaviour as designed behaviour (see 'https://bugs.eclipse.org/bugs/show_bug.cgi?id=221980#c5').

I defined the command using the article of Prakash ('http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html'), see plugin.xml-snippet below.
There was a similar question like mine asked by 'Jay in August 25, 2011 5:57 AM', any replies on that?

Questions:
- Is there a way to get a togglestate for each view?
- Would it help to create view-dependend handler (using activeWhen-definition) and let the handler manage the togglestate or do i have to define the command multiple times (one for each view)?
- I did not see any way to add the toggle-state to the handler-definition in plugin.xml (this was my first idea getting what i want).


snippet of plugin.xml
      <command
            defaultHandler="<myPackages>.CreatorToggleCommandAbstractHandler"
            id="EditorialManagement.Actions.AlphaSortCommand"
            name="AlphaSort">
         <state
               class="org.eclipse.jface.commands.ToggleState"
               id="org.eclipse.ui.commands.toggleState">
         </state>
      </command>
 


If you need any more information, please ask!
Thanks for any help
Alex

[Updated on: Wed, 04 July 2012 15:27]

Report message to a moderator

icon9.gif  Re: How do I get different togglestates of a command between views [message #895237 is a reply to message #893562] Thu, 12 July 2012 08:40 Go to previous messageGo to next message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
After having searched for days, I found the following post http://www.eclipse.org/forums/index.php/mv/msg/206187/660046/

Looks like there is now way to use a commands-toggle-state for multiple viewparts when each of this parts needs its own toggle-state for the command.

--> This means i need to multiply command-definition (12 times in my case for each of my four toggle-commands == 48 new commands with toggle-state) to have a special command for all viewparts that want to use the command. Sad

Lucky for me that the commands only need a default-handler without enablement.

If anyone has a better idea (using eclipse.indigo as base), don't hessitate to give me a hint

Greets Alex
Re: How do I get different togglestates of a command between views [message #897143 is a reply to message #895237] Sun, 22 July 2012 13:52 Go to previous messageGo to next message
jim liu is currently offline jim liuFriend
Messages: 37
Registered: February 2011
Location: shanghai
Member
is it a global command?
create a global command
use visibleWhen for view


java eclipse Search
http://javafind.appspot.com/

[Updated on: Sun, 22 July 2012 13:54]

Report message to a moderator

Re: How do I get different togglestates of a command between views [message #897197 is a reply to message #897143] Mon, 23 July 2012 06:42 Go to previous message
Alexander Haag is currently offline Alexander HaagFriend
Messages: 119
Registered: July 2009
Senior Member
Hi jim liu,

yes it has been a global command. I tried to use visibleWhen-conditions but it would not have the result i needed. As a matter of fact by having a global command with a global toggle-state, this state will be used for all views the command is used in menus or toolbars no matter if you use visibleWhen-conditions or not.

As I leaned later on, a context-sensitive-toggle-state will not be available until eclipse 4.x. So I created lots of new commandIDs (all having the same handler) just to get unique toggle-states for all my views the command should be used in.

I know that we will get a hard time if we need to change this again (my plugin.xml is now roughly 16000 lines) but it works for me.

As our RCP-Application will not be migrated to eclipse 4.x we will have to live with this but I'm ok with it.

Thanks for your help
Alex
Previous Topic:plugin developed using C++
Next Topic:How to add the green jump annotation?
Goto Forum:
  


Current Time: Thu Apr 18 15:41:09 GMT 2024

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

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

Back to the top