SwingObjectWidget: set values by string comparison#87
SwingObjectWidget: set values by string comparison#87
Conversation
Previously, we were trying to set the JComboBox value with a new instance of the object. We don't always have the possibility to keep a list of the allowed choices for the current model, nor can we override the `equals()` method for the `Object`s of this widget instance. So we have to fall back to comparing all combobox items to the current value by their `toString()` and `ObjectService.getName()` strings.
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/scijava-persist-not-working-for-enums/99827/9 |
|
This is awesome. The reason I didn't merge it instantly is because switching to string comparison over reference and/or object equality is a fundamental change in how the widgets behave, and it honestly makes me nervous that there will be unintended consequences. E.g. it's possible to have two different So... testing needed. I hope to get to it extremely soon; I know how annoying this bug has been. |
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-friends-weekly-dev-update-thread/103718/84 |
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-friends-weekly-dev-update-thread/103718/87 |
|
This pull request has been mentioned on Image.sc Forum. There might be relevant details there: https://forum.image.sc/t/fiji-friends-weekly-dev-update-thread/103718/94 |
Fixes scijava/scijava-common#471.
Previously, we were trying to set the
JComboBoxvalue with a new instance of the object.We don't always have the possibility to keep a list of the allowed choices for the current model, nor can we override the
equals()method for theObjects of this widget instance.So we have to fall back to comparing all combobox items to the current value by their
toString()andObjectService.getName()strings.