Skip to content

Commit 43469c9

Browse files
committed
Revert "WidgetModel: deprecate getChoices & move to iface"
This reverts commit 8794f7a. This change broke scijava-ui-swing, because item.getChoices() can return null. However, even when guarding against null, there is another problem: the current implementation in DefaultWidgetModel leans on the ObjectService, which is not accessible at the WidgetModel interface level. So for now, let's just revert this change. All seems to work fine without meddling here.
1 parent 3239804 commit 43469c9

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

src/main/java/org/scijava/widget/DefaultWidgetModel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,17 @@ public Number getStepSize() {
218218
return NumberUtils.toNumber("1", item.getType());
219219
}
220220

221+
@Override
222+
public String[] getChoices() {
223+
final List<?> choicesList = getItem().getChoices();
224+
if (choicesList == null) return null;
225+
final String[] choices = new String[choicesList.size()];
226+
for (int i = 0; i < choices.length; i++) {
227+
choices[i] = objectService.getName(choicesList.get(i));
228+
}
229+
return choices;
230+
}
231+
221232
@Override
222233
public String getText() {
223234
final Object value = getValue();

src/main/java/org/scijava/widget/WidgetModel.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ public interface WidgetModel extends Contextual {
134134
*/
135135
Number getStepSize();
136136

137-
/** @deprecated Use {@code getItem().getChoices()} instead. */
138-
@Deprecated
139-
default String[] getChoices() {
140-
return getItem().getChoices().stream() //
141-
.map(choice -> choice.toString()) //
142-
.toArray(String[]::new);
143-
}
137+
/**
138+
* Gets the multiple choice list for the module input.
139+
*
140+
* @return The available choices, or an empty list if not multiple choice.
141+
* @see ChoiceWidget
142+
*/
143+
String[] getChoices();
144144

145145
/**
146146
* Gets the input's value rendered as a string.

0 commit comments

Comments
 (0)