Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » How to create global actions with dynamic label and enablent
How to create global actions with dynamic label and enablent [message #819754] Tue, 13 March 2012 09:35 Go to next message
Agata Vackova is currently offline Agata Vackova
Messages: 9
Registered: February 2012
Junior Member
I would need to create global actions that can change state in the time, but don't depend on any editor or view. The actions can be in two states:
index.php/fa/7503/0/
or:
index.php/fa/7504/0/
When I define the action with class attribute:
          <action
                class="com.gooddata.clover.designer.actions.SignInAction"
                id="com.gooddata.clover.designer.action.SignIn"
                label="%authorization_sign_in"
                menubarPath="com.gooddata.clover.designer.Server/Server">
          </action>

the label and state can't be changed dynamicaly. But, when I mark the action as "retarget" I can add it to the editor or view only.
What is the proper way of handling such situation?
Re: How to create global actions with dynamic label and enablent [message #819786 is a reply to message #819754] Tue, 13 March 2012 10:23 Go to previous messageGo to next message
Libor Jelinek is currently offline Libor Jelinek
Messages: 143
Registered: January 2012
Location: Prague, Czech Rep.
Senior Member

AFAIK it's not possible to do with out-dated Actions. Actions are considered out-dated, checkout Commands Framework instead. In case of Command Frameworks it is achievable with

<extension point="org.eclipse.ui.menus">
    <menuContribution
          allPopups="false"
          locationURI="menu:com.virtage.plexflow.menu.file?after=additions">
          
          <command
             commandId="com.virtage.plexflow.ui.explorer.NewContainer"
             label="New folder...">
             
             <!-- visible when Explorer editor is focused -->
             <visibleWhen>
                <with variable="activePartId">
                      <equals
                            value="com.virtage.plexflow.ui.explorer.ExplorerEditor">
                      </equals>
                </with>
             </visibleWhen>
             
       </command>
    </menuContribution>
    ...
    


There's a lot of possible <visibleWhen> conditions that are made win use of so-called core expressions.
Re: How to create global actions with dynamic label and enablent [message #819888 is a reply to message #819786] Tue, 13 March 2012 12:54 Go to previous messageGo to next message
Agata Vackova is currently offline Agata Vackova
Messages: 9
Registered: February 2012
Junior Member
Thank you for answer. This way I'm able to control enability of the menu item, but I'm not able to change the label Sad
Re: How to create global actions with dynamic label and enablent [message #819972 is a reply to message #819786] Tue, 13 March 2012 15:06 Go to previous messageGo to next message
Agata Vackova is currently offline Agata Vackova
Messages: 9
Registered: February 2012
Junior Member
Is it possible to provide "visibleWhen" programatically? If it would be possible I could create more diffrent actions and show the one with label I need. But I have no idea how to implement visibleWhen, with the current state of my object.
Re: How to create global actions with dynamic label and enablent [message #820007 is a reply to message #819972] Tue, 13 March 2012 16:04 Go to previous messageGo to next message
Agata Vackova is currently offline Agata Vackova
Messages: 9
Registered: February 2012
Junior Member
At last I've found that it is piece of cake: all I need is to add a dynamic element that implements IContributionItem to my menu. Then I can change the label as well as enablement.
Re: How to create global actions with dynamic label and enablent [message #820051 is a reply to message #820007] Tue, 13 March 2012 17:07 Go to previous message
ModelGeek Mising name is currently offline ModelGeek Mising name
Messages: 515
Registered: June 2011
Senior Member
Hi

i am also looking for similar stuff can you explain or provide some code for that?

thanks in advance

cheers,
Previous Topic:RCP and Database
Next Topic:Open custom editor from cnf
Goto Forum:
  


Current Time: Thu Oct 23 04:05:56 GMT 2014

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

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