Skip to content
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

Persistence of enum choices in Commands #471

Open
stefanhahmann opened this issue Oct 12, 2023 · 1 comment
Open

Persistence of enum choices in Commands #471

stefanhahmann opened this issue Oct 12, 2023 · 1 comment

Comments

@stefanhahmann
Copy link
Contributor

stefanhahmann commented Oct 12, 2023

With 664b3ab and 61e98d7 it was made possible to use enums with custom labels in scijava commands

However, currently enums with custom labels are not persisted, i.e. if the user makes some settings using an enum with custom labels in a dialog, closes this dialog and comes back to this dialog, the selected value would fall back to the default parameter instead of the last selected parameter, which users may consider a bug, since this behavior would be different to other parameter types.

@imagejan
Copy link
Member

imagejan commented Sep 27, 2024

I think this issue is general for enums (i.e. not only enums with custom labels).

Looking at MoBIE's OpenCollectionTableCommand.DataRoot:
https://github.com/mobie/mobie-viewer-fiji/blob/18700b576efcc9574a9395598939bbf354f970e7/src/main/java/org/embl/mobie/command/open/OpenCollectionTableCommand.java#L49-L53

... non-default values seem to be correctly persisted to preference storage:

#@ PrefService ps
#@ ConvertService cs

import org.embl.mobie.command.open.OpenCollectionTableCommand
import org.embl.mobie.command.open.OpenCollectionTableCommand.DataRoot

stringValue = ps.get(OpenCollectionTableCommand.class, "dataRoot")

println(stringValue)  // e.g. UseTableFolder

converted = cs.convert(stringValue, DataRoot.class)

println(converted)  // e.g. UseTableFolder
println(converted.class)  // class org.embl.mobie.command.open.OpenCollectionTableCommand$DataRoot

However, the command dialog still falls back to default value every time.

Hence I think the issue is somewhere in the command module processing, not in the preferences.

@ctrueden would you have a best guess where to dig next?

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

No branches or pull requests

2 participants