| Summary: | Event class should override clone() | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Simon Scholz <simon.scholz> |
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | Lars.Vogel, lufimtse |
| Version: | 4.8 | Keywords: | triaged |
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| See Also: | https://git.eclipse.org/r/82005 | ||
| Whiteboard: | |||
|
Description
Simon Scholz
New Gerrit change created: https://git.eclipse.org/r/82005 (In reply to Simon Scholz from comment #0) > Btw normal Listeners are more likely to be used rather than typed > SWTEventListener nowadays, since you can make use of lambdas in there. FYI, we started to introduce helper methods to use lambdas with typed listeners, see https://www.eclipse.org/eclipse/news/4.7/M3#swt-lambda-style-selectionlisteners (In reply to Simon Scholz from comment #0) > In JavaFx the javafx.event.Event class implements java.lang.Cloneable and > overrides the clone() method. IMHO it is pretty convenient to offer the same > for SWT events. This is for instance useful, when you just want to change a > single property of an Event to pass it on, but don´t want to modify the > original Event in order to avoid side effects. > > I got the use case that I got a Listener, which determines its behavior > according to the event.type. So when I want to trigger whats supposed to > happen on SWT.Selection in this listener, I have to ensure that the event I > am passing to it has the SWT.Selection type, even if the original event I > myself am listening to is of type SWT.Mousedown. > Therefore I´d rather create a clone of the SWT.Mousedown event and then set > the type of the clone to SWT.Selection. > > Btw normal Listeners are more likely to be used rather than typed > SWTEventListener nowadays, since you can make use of lambdas in there. Hello Simon, Thank you for submitting this contribution, we appreciate contributions and suggestions as such. While the idea is great, a bug-free implementation of Clonable, that ensure a true deep-copy is not a trivial task. http://www.artima.com/intv/bloch13.html The given patch as is makes a shallow copy and would require a lot of work prior to actually being merged. I left detailed notes in the patch submission. We would be happy to review updates to patches, but it would have to meet the concerns outlined in the patch review. Thank you once again for this bug submission and please let me know if you have any questions. Also, I might be wrong, if you disagree, please share your concerns/thoughts. Thank you for your time. As per above, bug-free implementation of this would be very complex as making deep-copy of events with native data across multiple platforms is not a trivial task, and the benefit appears to be marginal (convenience). As things stand with the current patch, it would introduce more bugs than problems solved. It's unlikely that someone would implement this in the future. Closing as wontfix for now to free up SWT bugzilla, but if someone wants to work on this or original author wants to submit a more rigorous patch, please feel free to reopen. Thank you for your bug and patch submission :-), I think it's a good idea, the devil is in the details here thou. |