Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community ForumsSingleSourcing - Replacement of Widget.notifyListeners
https://www.eclipse.org/forums/index.php/mv/msg/38560/125306/#msg_125306
- we have a single composite with three radio buttons
- all radio-buttons have selectionListeners
- we sometimes change the selectionState of those radio-buttons
programmaticaly (radioButton.setSelection(true)).
Unfortunataly SWT (and thus RAP as well) don't send
SelectionChanged-Events, when calling manually calling setSelection.
In SWT we therefore called 'radioButton..notifyListeners(SWT.Selection,
new Event())' to trigger our listeners.
In RAP there is no 'notifyListeners'-Method :(
Is there any other elegant way, that our listeners get triggered, when we
programmatically change the selection-state of a radio button ?
Kind Regards
Stefan]]>Stefan Hansel2009-03-17T14:48:14-00:00Re: SingleSourcing - Replacement of Widget.notifyListeners
https://www.eclipse.org/forums/index.php/mv/msg/38560/125322/#msg_125322
updateSeletion(), that does whatever is necessary after selecting a
radio button? This method could then also be called after
programmatically changing the selection. In addition the method
would tell by its name what it is for.
Or did I miss something?
stefan.hansel@tolina.de wrote:
> I'm currently scratching my head about the following topic:
>
> - we have a single composite with three radio buttons
> - all radio-buttons have selectionListeners
> - we sometimes change the selectionState of those radio-buttons
> programmaticaly (radioButton.setSelection(true)).
>
> Unfortunataly SWT (and thus RAP as well) don't send
> SelectionChanged-Events, when calling manually calling setSelection.
> In SWT we therefore called 'radioButton..notifyListeners(SWT.Selection,
> new Event())' to trigger our listeners.
>
> In RAP there is no 'notifyListeners'-Method :(
>
> Is there any other elegant way, that our listeners get triggered, when we
> programmatically change the selection-state of a radio button ?
>
> Kind Regards
> Stefan]]>Rüdiger Herrmann2009-03-17T15:02:49-00:00Re: SingleSourcing - Replacement of Widget.notifyListeners
https://www.eclipse.org/forums/index.php/mv/msg/38560/125354/#msg_125354
--=_alternative 0060029BC125757C_=
Content-Type: text/plain; charset="US-ASCII"
>> why don't you have your listener code delegate to, say updateSeletion()
I'm trying to write a replacement for javax.swing.ButtonGroup
(as in SWT radioButton.setSelection(true) doesn't deselect the other
radio-buttons)
As I don't know if anyone else has listeners on the radio-buttons
(actually I even DO know that some have :D), I have to ensure, that proper
events are fired.
>> however, Widget#notifyListeners() is in CVS HEAD and will be available
in 1.2 M6
Good news, at least I can comment my current hack:
<br><tt><font size=2>>> why don't you have your listener code delegate
to, say updateSeletion()</font></tt>
<br><tt><font size=2>I'm trying to write a replacement for javax.swing.ButtonGroup
</font></tt>
<br><tt><font size=2>(as in SWT radioButton.setSelection(true) doesn't
deselect the other radio-buttons)</font></tt>
<br>
<br><tt><font size=2>As I don't know if anyone else has listeners on the
radio-buttons (actually I even DO know that some have :D), I have to ensure,
that proper events are fired.</font></tt>
<br>
<br><tt><font size=2>>> however, Widget#notifyListeners() is in CVS
HEAD and will be available in 1.2 M6</font></tt>
<br><tt><font size=2>Good news, at least I can comment my current hack:</font></tt>
<br>
<br><font size=2 face="Courier New">Listener[] listeners = radioButton.<b>getListeners</b>(SWT.Selection);</font>
<br><font size=2 color=#820040 face="Courier New"><b>for</b></font><font size=2 face="Courier New">
(</font><font size=2 color=#820040 face="Courier New"><b>int</b></font><font size=2 face="Courier New">
j = 0; j < listeners.</font><font size=2 color=#0021bf face="Courier New">length</font><font size=2 face="Courier New">;
j++) {</font>
<br><font size=2 face="Courier New"> Listener
listener = listeners[j];</font>
<br><font size=2 face="Courier New"> Event
selectionEvent = </font><font size=2 color=#820040 face="Courier New"><b>new</b></font><font size=2 face="Courier New">
<b>Event</b>();</font>
<br><font size=2 face="Courier New"> selectionEvent.</font><font size=2 color=#0021bf face="Courier New">type</font><font size=2 face="Courier New">
= SWT.Selection;</font>
<br><font size=2 face="Courier New"> selectionEvent.</font><font size=2 color=#0021bf face="Courier New">widget</font><font size=2 face="Courier New">
= radioButton;</font>
<br><font size=2 face="Courier New"> listener.</font><font size=2 color=#008080 face="Courier New">handleEvent</font><font size=2 face="Courier New">(selectionEvent);</font>
<br><font size=2 face="Courier New">}</font>
<br>
<br>
<br>
<br>
<br>
--=_alternative 0060029BC125757C_=--]]>Stefan Hansel2009-03-17T17:28:40-00:00Re: SingleSourcing - Replacement of Widget.notifyListeners
https://www.eclipse.org/forums/index.php/mv/msg/38560/125369/#msg_125369
radioButton.getListeners(SWT.Selection);
isn't supported in RAP as well ... search goes on ...]]>Stefan Hansel2009-03-17T17:36:43-00:00Re: SingleSourcing - Replacement of Widget.notifyListeners
https://www.eclipse.org/forums/index.php/mv/msg/38560/125394/#msg_125394
stefan.hansel@tolina.de wrote:
>
> >> why don't you have your listener code delegate to, say updateSeletion()
> I'm trying to write a replacement for javax.swing.ButtonGroup
> (as in SWT radioButton.setSelection(true) doesn't deselect the other
> radio-buttons)
>
> As I don't know if anyone else has listeners on the radio-buttons
> (actually I even DO know that some have :D), I have to ensure, that
> proper events are fired.
Ah, I see.
Until you update to M6, you can use event internals like this:
SelectionEvent event = new SelectionEvent( widget, ... );
event.processEvent();
It doesn't work in SWT of course...
>
> >> however, Widget#notifyListeners() is in CVS HEAD and will be
> available in 1.2 M6
> Good news, at least I can comment my current hack:
>
> Listener[] listeners = radioButton.*getListeners*(SWT.Selection);
> *for* (*int* j = 0; j < listeners.length; j++) {
> Listener listener = listeners[j];
> Event selectionEvent = *new* *Event*();
> selectionEvent.type = SWT.Selection;
> selectionEvent.widget = radioButton;
> listener.handleEvent(selectionEvent);
> }
>
>
>
>]]>Rüdiger Herrmann2009-03-17T19:27:02-00:00