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

Add "Load from file..." option to ObjectWidget #380

Open
imagejan opened this issue Jan 17, 2020 · 5 comments
Open

Add "Load from file..." option to ObjectWidget #380

imagejan opened this issue Jan 17, 2020 · 5 comments

Comments

@imagejan
Copy link
Member

As discussed in imagej/imagej-common#71, it would be nice to have a Load from file... option whenever we show a choice dropdown for arbitrary objects (including, but not limited to, images) via the ObjectWidget.

This can possibly be achieved by adding an additional object during the discovery of valid choices here:

/** Asks the object service and convert service for valid choices */
@SuppressWarnings("unchecked")
private List<?> getObjects(final Class<?> type) {
@SuppressWarnings("rawtypes")
List compatibleInputs =
new ArrayList(convertService.getCompatibleInputs(type));
compatibleInputs.addAll(objectService.getObjects(type));
return compatibleInputs;
}

We should display this option whenever we find an IOPlugin that can open objects of the target type, or convertible to the target type.

How can this be achieved? Maybe a custom converter File -> anything that provides a suitable IOPlugin, but converters have to provide a specific output type, right? Maybe a custom implementation in ObjectWidget/AbstractInputHarvester is required?

Also, how can we achieve that uiService.chooseFile() is called (and the file is loaded) only when the input is actually selected and the module processed? Do we have to intercept the ModuleItem#setValue() call, or can we do this with a custom PreprocessorPlugin?

(Just writing down some thoughts, before I forget.)

@imagejan
Copy link
Member Author

imagejan commented Mar 6, 2020

Having a Load from file... option for image inputs would avoid situations of poor user experience such as the one mentioned in this forum thread.

/cc @frauzufall

@ctrueden
Copy link
Member

ctrueden commented Mar 6, 2020

Maybe someone can thinking of a better way to phrase "A(n) X is required but none exists"? That message is pretty confusing, but I couldn't think of a better way to phrase it. "Please open a(n) X before performing this operation", perhaps? And then have some extensible aliasing mechanism for Java class to human-friendly name (e.g. RandomAccessibleInterval ➡️ image)?

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/new-colocalization-cross-correlation-plugin-looking-for-feedback/49492/2

@andmccall
Copy link

Just want to lend my support to a Load from file... option for image inputs. Particularly as I would love to make a user-friendly plugin for the GUI that also has simple headless support that works with files directly, and I imagine this would be a step in that direction (though I'm willing to be wrong on that, not very familiar with development for headless mode).

@imagejan
Copy link
Member Author

When calling from macro or via the command line, SCIFIO's StringToDatasetConverter takes care of converting String inputs to images by loading from file. What's still required is a way to allow optional loading from file when using the UI. This can possibly be done better in scijava-ui-swing on the widget level, where we can call ui.chooseFile() immediately upon selecting the Load from file... option in the dropdown menu.

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

4 participants