Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Toggle visibility of toolbar contribution via toggle command
Toggle visibility of toolbar contribution via toggle command [message #502632] Wed, 09 December 2009 08:52 Go to next message
Philipp Kursawe is currently offline Philipp KursaweFriend
Messages: 135
Registered: July 2009
Senior Member
Hello,

I have successfully created a toggle command in one of my menus that has
a little checkbox using the methods described here:
http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle- radio-menu.html

Now in my toggle handler I need access to the contribution I want to
toggle. Which service does give me access to contributions for
"menuExtension" extensions? The contribution in question is a little
Label (as a WorkbenchWindowControlContribution). I want it to show/hide
depending on the toggle state of the command.

How would I do that? And is there already a common toggle hander that
takes care of such tasks?

Thanks,
Phil
Re: Toggle visibility of toolbar contribution via toggle command [message #503142 is a reply to message #502632] Fri, 11 December 2009 05:56 Go to previous messageGo to next message
Prakash G.R. is currently offline Prakash G.R.Friend
Messages: 621
Registered: July 2009
Senior Member
On 09/12/09 2:22 PM, Philipp Kursawe wrote:
> I have successfully created a toggle command in one of my menus that has
> a little checkbox using the methods described here:
> http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle- radio-menu.html
>
> Now in my toggle handler I need access to the contribution I want to
> toggle. Which service does give me access to contributions for
> "menuExtension" extensions? The contribution in question is a little
> Label (as a WorkbenchWindowControlContribution). I want it to show/hide
> depending on the toggle state of the command.

HandlerUtil.toggleCommandState(command) should help you in changing the
state of the command. You can do it for the label's command from the
other toggle command's handler. ICommandService has methods to get the
command & to refresh the UI contributions.


- Prakash
Platform UI Team, IBM

Blog <http://blog.eclipse-tips.com>
Twitter <http://www.twitter.com/Eclipse_Tips>
Re: Toggle visibility of toolbar contribution via toggle command [message #503173 is a reply to message #503142] Fri, 11 December 2009 09:02 Go to previous message
Philipp Kursawe is currently offline Philipp KursaweFriend
Messages: 135
Registered: July 2009
Senior Member
On 12/11/2009 6:56 AM, Prakash G.R. wrote:
> On 09/12/09 2:22 PM, Philipp Kursawe wrote:
>> I have successfully created a toggle command in one of my menus that has
>> a little checkbox using the methods described here:
>> http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle- radio-menu.html
>>
>>
>> Now in my toggle handler I need access to the contribution I want to
>> toggle. Which service does give me access to contributions for
>> "menuExtension" extensions? The contribution in question is a little
>> Label (as a WorkbenchWindowControlContribution). I want it to show/hide
>> depending on the toggle state of the command.
>
> HandlerUtil.toggleCommandState(command) should help you in changing the
> state of the command. You can do it for the label's command from the
> other toggle command's handler. ICommandService has methods to get the
> command & to refresh the UI contributions.

Thanks for your reply!

The problem is, the label control has no command associated with it.
<menuContribution
locationURI="toolbar:rapi4j.ui.status">
<control

class=" rapi4j.ui.powerstatus.internal.PowerStatusControlContributio n "
id="rapi4j.ui.powerstatus.Icon">
<visibleWhen
checkEnabled="false">
<with
variable="osgi.services">
<iterate
operator="or">
<equals
value="rapi4j.ActiveSyncDevice">
</equals>
</iterate>
</with>
</visibleWhen>
</control>
</menuContribution>
<menuContribution
locationURI="menu:rapi4j.ui.tools">
<command
commandId="rapi4j.ui.powerstatus.ToggleStatusIconCommand"
style="toggle">
</command>
</menuContribution>

You can see the toggle command. It would need to show/hide the
"rapi4j.ui.powerstatus.Icon" menu contribution. I thought about
introducing a new variable in the visibleWhen enablement but don't know
which variable. Maybe have a property tester, that checks for toggle
states and make itself a listener for preference changes on toggle
preferences to send a re-eval request to the menu manager?

btw: Here is another bug for you to fix, that occured after you
introduced the new proxy WB contributions:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=297375

Thanks for fixing... I wonder how the "Heap Status" survived those
changes? It still shows up in the correct size, but maybe its not
contributed via plugin.xml as a menuContribution.

Thanks,
Phil
Previous Topic:Irregular shaped splash screen
Next Topic:.instance files
Goto Forum:
  


Current Time: Tue Mar 19 07:05:29 GMT 2024

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

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

Back to the top