Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsCommandContributionItem does not set checkedState for radio styles
https://www.eclipse.org/forums/index.php/mv/msg/284152/789502/#msg_789502
I have a view with commands contributed to the view's toolbar using the org.eclipse.ui.menus extension point. The menu contributions have a radio style. The command handlers implement IElementUpdater so it can call setChecked on the element. Here is the problem. The setChecked method in the CommandContributionItem class is not getting past the first if block. That is because the checkedState field is getting set in the handleWidgetSelection method for styles SWT.TOGGLE or SWT.CHECK but not SWT.RADIO. If you include SWT.RADIO it works as expected.
I have a work around by calling setChecked twice; first is the inverse followed by the actual value. But I think this is a bug that should be looked into further.
I have attached a sample plug-in to demonstrate the issue. Open the Radio Toolbar view. Click the Radio 2 button, then click the Toggle Toolbar state button. The selection listener of the button will refresh the commands, calling the setChecked method on the elements.
-Kevin
]]>Kevin Pfarr2012-02-03T03:40:01-00:00Re: CommandContributionItem does not set checkedState for radio styles
https://www.eclipse.org/forums/index.php/mv/msg/284152/789860/#msg_789860
http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html
PW
]]>Paul Webster2012-02-03T13:55:15-00:00Re: CommandContributionItem does not set checkedState for radio styles
https://www.eclipse.org/forums/index.php/mv/msg/284152/789879/#msg_789879
'Update the checked state on this UI element. For example, if this was a toggle or radio button.'
I will look into the radio state as from the URL.
Thanks,
Kevin]]>Kevin Pfarr2012-02-03T14:28:12-00:00Re: CommandContributionItem does not set checkedState for radio styles
https://www.eclipse.org/forums/index.php/mv/msg/284152/792033/#msg_792033
AFAIK then an end-to-end implementation was put in place using the RadioState and tied directly into the CommandContributionItem so that the state of the selection could be restored without instantiating the handler contribution on a new session.