Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » fix for problem with radio button
fix for problem with radio button [message #480639] Tue, 18 August 2009 04:39 Go to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
The deselected radio button handlers may be waiting for a notification.
The current SWTBotRadio.click() was providing a notify(SWT.selection) for
the selected button, but not for any button that was automatically
deselected. I modified the code in deselectOtherRadioButtons as follows
to fix this issue which was breaking one of my tests. It should also be a
little more efficient since it doesn't toggle off buttons that are already
deselected.

private void deselectOtherRadioButtons() {
if (hasStyle(widget.getParent(), SWT.NO_RADIO_GROUP))
return;
Widget[] siblings = SWTUtils.siblings(widget);
for (Widget sib : siblings) {
if ( widget == sib) continue; // skip the selected button
if ((sib instanceof Button) && hasStyle(widget, SWT.RADIO) &&
((Button)sib).getSelection()==true){
((Button) sib).setSelection(false);
sib.notifyListeners(SWT.Selection, createEvent());
}
}
}
Re: fix for problem with radio button [message #480640 is a reply to message #480639] Tue, 18 August 2009 04:55 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
I did a quick check and see that SWTBotMenu has the possibility of
handling menu items with style SWT.RADIO, so I think it will also need a
notify for the menu items toggled off automatically by a RADIO menu item
selection. Currently it doesn't appear to have code to handle this case,
but I did not investigate it closely.
Re: fix for problem with radio button [message #480641 is a reply to message #480639] Tue, 18 August 2009 05:12 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
Also a potential race issue in the same area of code. Seems to me the
asyncExec in SWTBotRadio.click() should be changed to syncExec, since
otherwise there is a possibility that the notify(SWT.Selection); for the
selected button gets executed before the widget.setSelection(true); for
the selected button.
Re: fix for problem with radio button [message #480652 is a reply to message #480640] Tue, 18 August 2009 06:26 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
logged in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=286897
Re: fix for problem with radio button [message #481101 is a reply to message #480652] Wed, 19 August 2009 15:53 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
I added an swtbot test case for both radio button Selection notification
and for radio menuItem Selection notification to the bug report. The
radio menuItem deselection is also broken. I haven't posted a fix for it
yet, but it should be similar to the radioButton fix.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=286897
Re: fix for problem with radio button [message #481154 is a reply to message #481101] Wed, 19 August 2009 20:10 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
I've now made attachments to the bug report to fix the handling of
MenuItem with style SWT.RADIO. It was previously handling these just like
SWT.CHECK, just toggling the single button, so that multiple MenuItems in
the radio group could become selected. I added notification similar to
the SWTBotRadio. There are fixed versions of SWTBotRadio, SWTBotMenu and
SiblingFinder. These are all based on sources of the downloaded SWTBot
2.0.0.371-dev-e34.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=286897
Re: fix for problem with radio button [message #481373 is a reply to message #480641] Thu, 20 August 2009 16:50 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Jay Norwood wrote:
> Also a potential race issue in the same area of code. Seems to me the
> asyncExec in SWTBotRadio.click() should be changed to syncExec, since
> otherwise there is a possibility that the notify(SWT.Selection); for the
> selected button gets executed before the widget.setSelection(true); for
> the selected button.
>

There is no race issue because the notify methods sends notifiction in
the UI thread with a syncexec. Since the asyncexec is posted before the
syncexec in the notify method, it will be executed first.

--
Pascal GĂ©linas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: fix for problem with radio button [message #481394 is a reply to message #481373] Thu, 20 August 2009 19:11 Go to previous message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
Pascal Gelinas wrote:

> There is no race issue because the notify methods sends notifiction in
> the UI thread with a syncexec. Since the asyncexec is posted before the
> syncexec in the notify method, it will be executed first.

ok, so no need to change it from asyncexec. Thanks.
Previous Topic:No SWTBotTreeItem recursive expand
Next Topic:SWTBot.treeWithRoot(String)
Goto Forum:
  


Current Time: Fri Dec 19 21:55:05 GMT 2014

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

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