Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » CommandContributionItem does not set checkedState for radio styles
CommandContributionItem does not set checkedState for radio styles [message #789502] Fri, 03 February 2012 03:40 Go to next message
Kevin Pfarr is currently offline Kevin PfarrFriend
Messages: 5
Registered: July 2009
Junior Member
I'm using the RCP version 3.7.1 and ran into an issue with menu contributions having a radio style.

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

Re: CommandContributionItem does not set checkedState for radio styles [message #789860 is a reply to message #789502] Fri, 03 February 2012 13:55 Go to previous messageGo to next message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

I believe radio state is not managed by the UIElements, but by toggle state and radio state. See http://blog.eclipse-tips.com/2009/03/commands-part-6-toggle-radio-menu.html

PW


Re: CommandContributionItem does not set checkedState for radio styles [message #789879 is a reply to message #789860] Fri, 03 February 2012 14:28 Go to previous messageGo to next message
Kevin Pfarr is currently offline Kevin PfarrFriend
Messages: 5
Registered: July 2009
Junior Member
So why would a handler implement IElementUpdater and utilize the UIElement.setChecked method? The javadoc says...

'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
Re: CommandContributionItem does not set checkedState for radio styles [message #792033 is a reply to message #789879] Mon, 06 February 2012 14:33 Go to previous message
Paul Webster is currently offline Paul WebsterFriend
Messages: 6859
Registered: July 2009
Location: Ottawa
Senior Member

It can be used that way, especially if the handler is completely responsible for the state (checked state for a toggle, or shared state for a radio button). There are some pitfalls, like correctly setting the last state on a new session (when the handlers aren't loaded by default).

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.

PW


Previous Topic:How to change folder path in Eclipse's custom Import Wizard
Next Topic:Decorators extension point and expression-based constraints
Goto Forum:
  


Current Time: Fri Apr 26 03:01:44 GMT 2024

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

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

Back to the top