Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Why does TreeViewer fire SelectionChangedEvent when setSelection() is called?
icon5.gif  Why does TreeViewer fire SelectionChangedEvent when setSelection() is called? [message #537636] Thu, 03 June 2010 08:12
Alexey Romanov is currently offline Alexey Romanov
Messages: 263
Registered: May 2010
Senior Member
The convention in SWT is that when a method such as setSelection is called programmatically, it doesn't fire an event. However, I just found to my surprise that TreeViewer doesn't obey this: SelectionChangedEvent _is_ fired when calling setSelection programmatically Evil or Very Mad while SelectionEvent isn't. Why the difference? Does the same apply to other Viewers? To other events added in JFace?

From SWT FAQ:
Quote:
Q: Why are some events like Selection not fired in response to programmatic widget changes?

A: This is a design decision that was made in order to minimize notification of potentially unwanted events. For example, when the selection of a control is changed programmatically, SWT does not issue a selection event. If this were not the case then changing the selection multiple times would send multiple notifications and run application listener code multiple times, thereby leading to a potential performance problem. Clients that wish to notify widget listeners of changes made programatically can do so by creating an Event object and invoking Widget.notifyListeners(int, Event) on the widget. Note that some programmatically-triggered events are sent, typically in response to low-level widget operations such as focus, move and resize changes.

Previous Topic:No e.doit for SelectionChangedEvent?
Next Topic:Is there a way to assign specific Transfer types to the nodes of a TreeViewer OR to get the dragged
Goto Forum:
  


Current Time: Wed Oct 01 10:27:43 GMT 2014

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

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