Add "Load from file..." option to ObjectWidget
As discussed in https://github.com/imagej/imagej-common/issues/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: https://github.com/scijava/scijava-common/blob/560ad964a7a1e859edd4dbe4fc48d7d9e09523f2/src/main/java/org/scijava/widget/AbstractInputHarvester.java#L131-L139
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.)
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
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)?
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
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).
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.