|
|
|
|
|
|
|
Re: [Tree] unwanted automatic SelectionEvents [message #638860 is a reply to message #638784] |
Fri, 12 November 2010 19:26 |
Bogdan B. Messages: 50 Registered: July 2009 |
Member |
|
|
Grant Gayed wrote on Fri, 12 November 2010 10:05 | Hi, sorry for the late reply,
There isn't a way to differentiate between these cases by looking at the
event. This is one of those rare cases where an event gets sent for a
programmatic change, because the selection change could be a side effect of
doing something different (eg.- disposing a TreeItem that has selected child
items). I think the only way to handle this in your case is to set a
boolean flag around your call to remove() that indicates that selection
change events received are a result of the remove() call. I know this is a
bit ugly, but I don't think there's another option (this is why most
programmatic changes do not cause events to be sent).
Grant
|
My use case is a bit more complicated than that:
I reimplemented the PostSelection behaviour because it is not supported (yet) by Eclipse RAP. I mention that I develop a single sourced application which has a rich client version (Eclipse RCP) and a web version (RAP). By PostSelection behaviour I mean that I only schedule my selection actions when the SelectionListener is notified, and after a certain delay I run them or ignore them if other selection events were fired in the meantime (use case: changing selection quickly with the keyboard arrow up/down should only perform the action for the last row I stopped on and ignore the others).
And I am not quite sure that I shall be able to cleanly sync that with your semaphore solution.
I already thought of a semaphore myself, but more precise than a boolean flag:
to record the timestamps before and after .remove() and ignore the events scheduled during this time. But I found 2 problems to this approach:
1) event.time is not supported in Eclipse RAP
2) Even in RCP, I have no idea what the value of event.time is. It's not the number of millis from 1.1.1970, like all other Java dates are. The value is given by Display.getlastEventTime(), which seems to be platform specific:int getLastEventTime () {
return OS.IsWinCE ? OS.GetTickCount () : OS.GetMessageTime ();
} Any Idea of how could I transform that into a Java date?
[Updated on: Fri, 12 November 2010 19:28] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.05708 seconds