Toggle visibility of toolbar contribution via toggle command [message #502632] |
Wed, 09 December 2009 03:52  |
Eclipse User |
|
|
|
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 #503173 is a reply to message #503142] |
Fri, 11 December 2009 04:02  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.27622 seconds