From 409823e784ad7bd75cce7038e50ac55e44c67c44 Mon Sep 17 00:00:00 2001 From: Jean-Marie Burel Date: Sat, 5 Aug 2023 15:28:08 +0100 Subject: [PATCH] open image in imageJ when using as IJ plugin --- .../dataBrowser/view/SearchResultTable.java | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java b/src/main/java/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java index 762914b93..8ac0566b1 100644 --- a/src/main/java/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java +++ b/src/main/java/org/openmicroscopy/shoola/agents/dataBrowser/view/SearchResultTable.java @@ -1,6 +1,6 @@ /* *------------------------------------------------------------------------------ - * Copyright (C) 2014-2021 University of Dundee. All rights reserved. + * Copyright (C) 2014-2023 University of Dundee. All rights reserved. * * * This program is free software; you can redistribute it and/or modify @@ -52,7 +52,10 @@ import org.openmicroscopy.shoola.agents.events.iviewer.ViewImage; import org.openmicroscopy.shoola.agents.events.iviewer.ViewImageObject; import org.openmicroscopy.shoola.agents.imviewer.ImViewerAgent; +import org.openmicroscopy.shoola.env.LookupNames; +import org.openmicroscopy.shoola.env.data.events.ViewInPluginEvent; import omero.gateway.SecurityContext; +import org.openmicroscopy.shoola.env.event.EventBus; import org.openmicroscopy.shoola.env.event.RequestEvent; import org.openmicroscopy.shoola.env.ui.UserNotifier; import org.openmicroscopy.shoola.util.ui.UIUtilities; @@ -222,9 +225,18 @@ private JButton createActionButton(final DataObject obj) { @Override public void actionPerformed(ActionEvent e) { ImageData img = (ImageData) obj; - RequestEvent ev = new ViewImage(new SecurityContext(obj - .getGroupId()), new ViewImageObject(img), null); - ImViewerAgent.getRegistry().getEventBus().post(ev); + SecurityContext ctx = new SecurityContext(img.getGroupId()); + EventBus bus = DataBrowserAgent.getRegistry().getEventBus(); + if (DataBrowserAgent.runAsPlugin() == LookupNames.IMAGE_J) { + ViewInPluginEvent evt = new ViewInPluginEvent(ctx, + img, LookupNames.IMAGE_J); + bus.post(evt); + } else { + RequestEvent evt = new ViewImage(ctx, + new ViewImageObject(img), null); + bus.post(evt); + + } } }); } else {