Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » SingleSourcing - Replacement of Widget.notifyListeners
SingleSourcing - Replacement of Widget.notifyListeners [message #125306] Tue, 17 March 2009 14:48 Go to next message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
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
Re: SingleSourcing - Replacement of Widget.notifyListeners [message #125322 is a reply to message #125306] Tue, 17 March 2009 15:02 Go to previous messageGo to next message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
why don't you have your listener code delegate to, say
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?

However, Widget#notifyListeners() is in CVS HEAD and will be
available in 1.2 M6 (http://eclipse.org/rap/noteworthy/news_12M6.php)

HTH
Rüdiger

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
Re: SingleSourcing - Replacement of Widget.notifyListeners [message #125354 is a reply to message #125322] Tue, 17 March 2009 17:28 Go to previous messageGo to next message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
Dies ist eine mehrteilige Nachricht im MIME-Format.
--=_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:

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);
}





--=_alternative 0060029BC125757C_=
Content-Type: text/html; charset="US-ASCII"


<br><tt><font size=2>&gt;&gt; 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
&nbsp;</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>&gt;&gt; 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 &lt; 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">&nbsp; &nbsp; &nbsp; &nbsp; Listener
listener = listeners[j];</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; 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">&nbsp; &nbsp; &nbsp; &nbsp; 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">&nbsp; &nbsp; &nbsp; &nbsp; 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">&nbsp; &nbsp; &nbsp; &nbsp; 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_=--
Re: SingleSourcing - Replacement of Widget.notifyListeners [message #125369 is a reply to message #125354] Tue, 17 March 2009 17:36 Go to previous messageGo to next message
Stefan Hansel is currently offline Stefan HanselFriend
Messages: 103
Registered: July 2009
Senior Member
I was too fast:

radioButton.getListeners(SWT.Selection);

isn't supported in RAP as well ... search goes on ...
Re: SingleSourcing - Replacement of Widget.notifyListeners [message #125394 is a reply to message #125354] Tue, 17 March 2009 19:27 Go to previous message
Rüdiger Herrmann is currently offline Rüdiger HerrmannFriend
Messages: 581
Registered: July 2009
Senior Member
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);
> }
>
>
>
>
Previous Topic:JAAS set-up
Next Topic:plots and moving graphics: BIRT or custom Flash widget?
Goto Forum:
  


Current Time: Thu Sep 26 03:24:18 GMT 2024

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

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

Back to the top