Skip to content

Add named object index and improve ObjectService #374

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

Merged
merged 4 commits into from
Jan 13, 2020
Merged

Conversation

imagejan
Copy link
Member

@imagejan imagejan commented Jan 4, 2020

Fixes #371.

@imagejan imagejan requested a review from ctrueden January 9, 2020 13:55
@@ -227,7 +231,7 @@ public Number getStepSize() {
final List<?> choicesList = item.getChoices();
final String[] choices = new String[choicesList.size()];
for (int i = 0; i < choices.length; i++) {
choices[i] = choicesList.get(i).toString();
choices[i] = objectService.getName(choicesList.get(i));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change to DefaultWidgetModel is probably superfluous. I figured that dropdown choices such as for images and other objects will be rendered by ObjectWidget and require changing the renderer for list cells as done in scijava/scijava-ui-swing@2411016.

The getChoicesmethod of WidgetModel seems to be exclusively used for the choices attribute of Parameters, right? What confused me was the generic typing List<?> of item.getChoices().

In summary, I am not sure whether we should change this line to use ObjectService, or leave it unchanged.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intuitively, using the ObjectService seems less hacky, so let's change it for now, and revert if any problems arise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Judging from:

@Override
public List<T> getChoices() {
final T[] choices = getType().getEnumConstants();
return choices == null ? null : Arrays.asList(choices);
}
)

... the ModuleItem#getChoices() seems to be used for enums, other than for String choices.

But I didn't find an actual application case where the choice widget is used when and enum parameter is requested. Is there any?

In any case, the above line will probably never be called on Named objects or on objects registered to the ObjectService, so I'll remove it in a follow-up commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve ObjectService with names for objects
2 participants