◐ Shell
clean mode source ↗

Add NameService and NameProvider by imagejan · Pull Request #425 · scijava/scijava-common

This allows to define a way to derive names from objects of third party libraries, e.g. for use in ObjectService, where objects are registered with a name and can be provided e.g. in a drop-down choice in the UI.

This pull request, together with imagej/imagej-legacy#263, will resolve this forum discussion about being able to automatically populate ij.measure.ResultsTable inputs, provided we implement the following ResultsTableNameProvider in a follow-up pull request to imagej-legacy:

package net.imagej.legacy.plugin;

import org.scijava.names.NameProvider;
import org.scijava.plugin.AbstractHandlerPlugin;
import org.scijava.plugin.Plugin;

import ij.measure.ResultsTable;

@Plugin(type=NameProvider.class)
public class ResultsTableNameProvider extends AbstractHandlerPlugin<Object> implements NameProvider {

	@Override
	public String getName(Object thing) {
		return ((ResultsTable) thing).getTitle();
	}

	@Override
	public boolean supports(Object thing) {
		return ResultsTable.class.isAssignableFrom(thing.getClass());
	}
}

(Suggestions welcome to make this even more concise!)

image