Skip to content

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

Open
@imagejan

Description

@imagejan

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions