-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework SplitButton to not use SWT's internal TypedListener #582
Conversation
return evt; | ||
}; | ||
for (Listener listener : selectionListeners) { | ||
listener.handleEvent(eventFactory.get()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it looks wrong to create a new event for each listener, @lcaron what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It used to be like that, this is why I replicated it.
But when looking at SWT I get the impression that there is only one Event send to all listeners, unless one uses a typed listener (e.g. SelectionListener), then the one event is wrapped in a new SelectionEvent
for each SelectionListener
, see TypedListener
. But the latter is probably a technical detail.
And although Events are not immutable, I think good listeners don't change events.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for "doit" when the event has that sort of thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for "doit" when the event has that sort of thing.
Didn't knew that, thanks for the hint. So maybe there should be one Event
send to all Listeners
and a new SelectionEvent
for each SelectionListener
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's how SWT generally does it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And although Events are not immutable, I think good listeners don't change events.
Actually listeners can give some things back to the caller (e.g. as mentioned doit), there is even a field data
mentioned for "application use" in TypedEvent, I think if one can install listeners to an SWT object one should always be "nice" and only ever modify things if the API tells so.
Unless bounds are changed that will allow this latest Nebula bundle to only installed along with latest version of SWT, this type of change is going to cause grief. If it were "my project" I would probably try to create a utility that allowed me to work reflectively with both the old "APIs" and the new APIs so that these things continue to "just work". |
This change does not use the recent API addition in SWT (as you can see in the CI it builds with the latest SimRel) and just avoids
The new APIs are only used in #583, but there I raised the version bounds. But lets discuss there if any other strategy should be used. |
Sorry, I didn't look in detail of what's being used! |
f806c5f
to
81bba97
Compare
@lcaron, @wimjongman can you please review this as well? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One remark. Otherwise LGTM. I did not run it so I don't know if the widget works the same way it used to.
...lipse.nebula.widgets.splitbutton/src/org/eclipse/nebula/widgets/splitbutton/SplitButton.java
Outdated
Show resolved
Hide resolved
81bba97
to
ea4438c
Compare
I'm not familiar with Nebula in general and the |
ea4438c
to
52365cf
Compare
@wimjongman is there anything missing here or can this be submitted? |
Go for it. Thanks, Hannes! |
I'm not a committer here, but thanks Ed for submitting. |
You get a special mention when we release. 🏅 |
The
org.eclipse.swt.widgets.TypedListener
should be considered an internal class (as the doc states) and leaks the classSWTEventListener
which also resides in an internal package.This reworks
SplitButton
to not useTypedListener
anymore.