30
30
package org .scijava .widget ;
31
31
32
32
import java .util .List ;
33
- import java .util .Map ;
34
33
import java .util .Objects ;
35
- import java .util .WeakHashMap ;
36
34
37
35
import org .scijava .AbstractContextual ;
38
36
import org .scijava .Context ;
@@ -60,7 +58,6 @@ public class DefaultWidgetModel extends AbstractContextual implements WidgetMode
60
58
private final Module module ;
61
59
private final ModuleItem <?> item ;
62
60
private final List <?> objectPool ;
63
- private final Map <Object , Object > convertedObjects ;
64
61
65
62
@ Parameter
66
63
private ThreadService threadService ;
@@ -87,7 +84,6 @@ public DefaultWidgetModel(final Context context, final InputPanel<?, ?> inputPan
87
84
this .module = module ;
88
85
this .item = item ;
89
86
this .objectPool = objectPool ;
90
- convertedObjects = new WeakHashMap <>();
91
87
92
88
if (item .getValue (module ) == null ) {
93
89
// assign the item's default value as the current value
@@ -142,27 +138,9 @@ public Object getValue() {
142
138
143
139
@ Override
144
140
public void setValue (final Object value ) {
145
- final String name = item .getName ();
146
141
if (Objects .equals (item .getValue (module ), value )) return ; // no change
147
142
148
- // Check if a converted value is present
149
- Object convertedInput = convertedObjects .get (value );
150
- if (convertedInput != null &&
151
- Objects .equals (item .getValue (module ), convertedInput ))
152
- {
153
- return ; // no change
154
- }
155
-
156
- // Pass the value through the convertService
157
- convertedInput = convertService .convert (value , item .getType ());
158
- if (convertedInput == null ) convertedInput = value ;
159
-
160
- // If we get a different (converted) value back, cache it weakly.
161
- if (convertedInput != value ) {
162
- convertedObjects .put (value , convertedInput );
163
- }
164
-
165
- module .setInput (name , convertedInput );
143
+ module .setInput (item .getName (), value );
166
144
167
145
if (initialized ) {
168
146
threadService .queue (() -> {
@@ -309,11 +287,6 @@ private Object ensureValidObject(final Object value) {
309
287
private Object ensureValid (final Object value , final List <?> list ) {
310
288
for (final Object o : list ) {
311
289
if (o .equals (value )) return value ; // value is valid
312
- // check if value was converted and cached
313
- final Object convertedValue = convertedObjects .get (o );
314
- if (convertedValue != null && value .equals (convertedValue )) {
315
- return convertedValue ;
316
- }
317
290
}
318
291
319
292
// value is not valid; override with the first item on the list instead
0 commit comments