-
Notifications
You must be signed in to change notification settings - Fork 23
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
Support for ChangeListener #31
Conversation
@Petikoch @samuelgruetter |
Hi @mikebaum, thanks for pointing me to https://docs.oracle.com/javase/tutorial/uiswing/events/eventsandcomponents.html (didn't know it). I just updated the PR. Best regards, Peti |
Okay I finished my review. After addressing the comments, perhaps you can squash all your commits into one patch. |
Thanks a lot @mikebaum for the review. I'll update the PR tonight or tomorrow. Best regards, Peti |
@Petikoch Sounds good, thanks for the PR. |
@mikebaum, the PR is updated. |
Method method = object.getClass().getMethod(methodName, parameterTypes); | ||
if (!Modifier.isPublic(method.getModifiers())) { | ||
throw new IllegalArgumentException( | ||
"'" + object + "' has not the expected signature to support change listeners in " |
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.
This message relies on the object having a sane implementation of toString(), perhaps, it would be more informative to rather to use object.getClass().getSimpleName()
. This comment applies to the other instances within this file of using object in a message.
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.
Good point. I updated the PR.
Okay I finished my review. Just a few minor things to change. Once you make those updates, please squash all the commits into one commit and I'll merge it. 👍 Although I'm not a big fan of reflection, in this case, for the reasons you stated it is a reasonable compromise. We could potentially generalize and use this approach if we discover other event sources that do not share a common interface. It's a shame we don't have java 8, because then we could have used method references rather than reflection. |
Hi @mikebaum, I finally managed to squash all changes into one commit and update my feature branch :-) |
@mikebaum, after sleeping one night... the following idea came up... what do you think about putting just one fromChangeEvents method with a single parameter of type Object into SwingObservable? I think this would be better. |
@Petikoch I think it's okay the way it is. This way the users of |
@Petikoch merged, good work! |
@mikebaum thanks again a lot for the review! |
Could we have a release that contains this 0.26 maybe? |
This library doesn't seem to be under active development. It is setup to support one-button release though. Let me see if I can get a release out but the version-tool doesn't seem to like 0.x version patterns. |
@kittinunf I've released |
Thanks @akarnokd for releasing! |
@akarnokd Thanks for releasing that update. Just wondering where is the "release" button? I would have released it long ago, but alas life distracted me. @Petikoch poke @kittinunf @Petikoch I have outstanding PRs on this project, would one of you like to review them. Also, I laid out a bunch of issues that I consider the minimum to release a v.1 of this project. It's not particularly challenging code, but necessary. Would any of you be interested in spending some hours finish this up? I'll work on it too, I could knock out a few of them quickly. I'll send you all a virtual beer! |
There is a release tab on GitHub where if you create a new release with tag vx.y.z, the CI will perform the release automatically. |
Hi @mikebaum,
I implemented support for ChangeListener's for: JTabbedPane, JSlider, JSpinner, SpinnerModel, AbstractButton, ButtonModel and JViewport. Would be nice to have that soon in RxSwing.
About the implementation:
Since there is no "common" interface for the two common methods addChangeListener and removeChangeListener of classes like JTabbedPane, JSlider, etc... I decided to use internally reflection to avoid duplicated code. Using reflection gives a little performance penalty, but in the seldom case of registering / unregistering change listeners, this should not be an issue.
I know this PR is competing the work and the two PR's from @samuelgruetter. It's based on the typical style of RxSwing and does not introduce refactorings, but comes "ready to use" with tests. So it's a quick solution to have support for ChangeListener now, without considering design improvements. What do you @samuelgruetter and @mikebaum think?
Best regards from Lucerne in Switzerland,
Peti