diff --git a/src/main/java/net/imagej/legacy/plugin/DefaultLegacyOpener.java b/src/main/java/net/imagej/legacy/plugin/DefaultLegacyOpener.java index 45f37159b..691d48e15 100644 --- a/src/main/java/net/imagej/legacy/plugin/DefaultLegacyOpener.java +++ b/src/main/java/net/imagej/legacy/plugin/DefaultLegacyOpener.java @@ -29,8 +29,6 @@ package net.imagej.legacy.plugin; -import ij.ImagePlus; - import io.scif.Metadata; import io.scif.app.SCIFIOApp; import io.scif.img.SCIFIOImgPlus; @@ -62,6 +60,9 @@ import org.scijava.options.OptionsService; import org.scijava.plugin.Plugin; import org.scijava.service.Service; +import org.scijava.ui.UIService; + +import ij.ImagePlus; /** * The default {@link LegacyOpener} plugin. @@ -84,6 +85,7 @@ public class DefaultLegacyOpener implements LegacyOpener { private AppService appService; private IOService ioService; private LogService logService; + private UIService uiService; @Override public Object open(String path, final int planeIndex, @@ -92,14 +94,7 @@ public Object open(String path, final int planeIndex, final Context c = IJ1Helper.getLegacyContext(); ImagePlus imp = null; - legacyService = getCached(legacyService, LegacyService.class, c); - displayService = getCached(displayService, DisplayService.class, c); - moduleService = getCached(moduleService, ModuleService.class, c); - commandService = getCached(commandService, CommandService.class, c); - optionsService = getCached(optionsService, OptionsService.class, c); - appService = getCached(appService, AppService.class, c); - ioService = getCached(ioService, IOService.class, c); - logService = getCached(logService, LogService.class, c); + initServices(c); // Check to see if SCIFIO has been disabled final boolean newStyleIO = @@ -205,13 +200,30 @@ public Object open(String path, final int planeIndex, return imp; } } + else if (displayResult) { + // Attempt to display non-dataset data + uiService.show(data); + } return data; } return path; } + // -- Helper methods -- + private void initServices(final Context c) { + legacyService = getCached(legacyService, LegacyService.class, c); + displayService = getCached(displayService, DisplayService.class, c); + moduleService = getCached(moduleService, ModuleService.class, c); + commandService = getCached(commandService, CommandService.class, c); + optionsService = getCached(optionsService, OptionsService.class, c); + appService = getCached(appService, AppService.class, c); + ioService = getCached(ioService, IOService.class, c); + logService = getCached(logService, LogService.class, c); + uiService = getCached(uiService, UIService.class, c); + } + private T getCached(T service, Class serviceClass, Context ctx) { if (service != null) return service; return ctx.getService(serviceClass);