File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
main/java/org/scijava/nwidget/swing
test/java/org/scijava/nwidget Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -162,7 +162,15 @@ else if (source == spinner) {
162162 // -- Helper methods --
163163
164164 private Number number (final Object value , final Number defaultValue ) {
165- final Number converted = convertService .convert (value , Number .class );
165+ // FIXME: discuss best way forward
166+ // Right now, the widgets do not have the T of their model
167+ // Should they? It is nice that they don't, mostly.
168+ // But here, would be handy to have a utility method that converts from
169+ // the given value to one compatible with this widget's model.
170+ // How deep should this conversion logic live.
171+ final Class <?> modelType = model ().member ().getRawType ();
172+ final Number converted = //
173+ (Number ) convertService .convert (value , modelType );
166174 return converted == null ? defaultValue : converted ;
167175 }
168176
Original file line number Diff line number Diff line change 77import javax .swing .JPanel ;
88
99import org .scijava .Context ;
10- import org .scijava .nwidget .NWidgetPanel ;
11- import org .scijava .nwidget .NWidgetService ;
1210import org .scijava .nwidget .swing .NSwingWidgetPanelFactory ;
1311import org .scijava .param .Parameter ;
1412import org .scijava .param .ParameterStructs ;
@@ -26,8 +24,7 @@ public static void main(final String... args) throws Exception {
2624
2725 @ Parameter
2826 private String name = "Chuckles McGee" ;
29- // @Parameter(min = "0", max = "100", style = NumberWidget.SCROLL_BAR_STYLE)
30- @ Parameter
27+ @ Parameter (min = "0" , max = "100" , style = NNumberWidget .SCROLL_BAR_STYLE )
3128 private Integer age = 27 ;
3229 };
3330 final StructInstance <Object > structInstance = //
You can’t perform that action at this time.
0 commit comments