From 89eb56df607bd75642b85e584748c648d410fea8 Mon Sep 17 00:00:00 2001
From: Stephane Dallongeville <stephane.dallongeville@pasteur.fr>
Date: Tue, 2 Nov 2021 17:03:17 +0100
Subject: [PATCH] Fixed 'Call IJ Plugin' and 'Get Active Image Plus' block
(regression)
---
.../adufour/blocks/tools/ij/CallIJPlugin.java | 30 ++++++++++++-------
.../blocks/tools/ij/GetActiveImagePlus.java | 2 +-
.../adufour/protocols/gui/link/DragZone.java | 12 +-------
3 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java b/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java
index e9b08f4..c1202ef 100644
--- a/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java
+++ b/src/main/java/plugins/adufour/blocks/tools/ij/CallIJPlugin.java
@@ -12,13 +12,13 @@ import plugins.adufour.vars.lang.VarString;
public class CallIJPlugin extends Plugin implements IJBlock
{
VarImagePlus varIp = new VarImagePlus("Input ImagePlus", null);
-
+
VarString pluginName = new VarString("plug-in name", "");
-
+
VarString pluginParams = new VarString("parameters", "");
-
+
VarImagePlus varActiveIP = new VarImagePlus("Output (active) ImagePlus", null);
-
+
@Override
public void run()
{
@@ -26,21 +26,31 @@ public class CallIJPlugin extends Plugin implements IJBlock
{
ImagePlus imgPlus = varIp.getValue(false);
String params = pluginParams.getValue(false);
-
+
if (imgPlus != null)
IJ.run(imgPlus, pluginName.getValue(true), params);
else
IJ.run(pluginName.getValue(true), params);
- // Set the output image (if available) with the following priority
- ImagePlus output = IJ.getImage();
+ ImagePlus output = null;
+
+ try
+ {
+ // Set the output image (if available) with the following priority
+ output = WindowManager.getCurrentImage();
+ }
+ catch (RuntimeException e)
+ {
+ // just in case
+ }
+
// Default to the current "temporary" image (if any)
if (output == null)
output = WindowManager.getTempCurrentImage();
// Default to the input image (may have been modified "in-place"
if (output == null)
output = varIp.getValue();
-
+
varActiveIP.setValue(output);
}
catch (RuntimeException e)
@@ -48,7 +58,7 @@ public class CallIJPlugin extends Plugin implements IJBlock
throw new IcyHandledException(e.getLocalizedMessage());
}
}
-
+
@Override
public void declareInput(VarList inputMap)
{
@@ -56,7 +66,7 @@ public class CallIJPlugin extends Plugin implements IJBlock
inputMap.add("ImageJ plug-in name", pluginName);
inputMap.add("ImageJ plug-in parameters", pluginParams);
}
-
+
@Override
public void declareOutput(VarList outputMap)
{
diff --git a/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java b/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java
index f5fe702..6c1ccd0 100644
--- a/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java
+++ b/src/main/java/plugins/adufour/blocks/tools/ij/GetActiveImagePlus.java
@@ -27,7 +27,7 @@ public class GetActiveImagePlus extends Plugin implements IJBlock
public void run()
{
// Set the output image (if available) with the following priority
- ImagePlus imgPlus = IJ.getImage();
+ ImagePlus imgPlus = WindowManager.getCurrentImage();
// Default to the current "temporary" image (if any)
if (imgPlus == null)
imgPlus = WindowManager.getTempCurrentImage();
diff --git a/src/main/java/plugins/adufour/protocols/gui/link/DragZone.java b/src/main/java/plugins/adufour/protocols/gui/link/DragZone.java
index 5bc1f74..d4c2e1f 100644
--- a/src/main/java/plugins/adufour/protocols/gui/link/DragZone.java
+++ b/src/main/java/plugins/adufour/protocols/gui/link/DragZone.java
@@ -10,7 +10,6 @@ import java.awt.dnd.InvalidDnDOperationException;
import plugins.adufour.blocks.lang.BlockDescriptor;
import plugins.adufour.blocks.lang.WorkFlow;
import plugins.adufour.vars.lang.Var;
-import sun.awt.dnd.SunDragSourceContextPeer;
/**
* Button defining an area on a panel from where an output variable can be dragged to another panel
@@ -56,16 +55,7 @@ public class DragZone<T> extends DragDropZone implements DragGestureListener
}
catch (final InvalidDnDOperationException idoe)
{
- try
- {
- SunDragSourceContextPeer.setDragDropInProgress(false);
- }
- catch (Throwable t)
- {
-
- }
-
- DragSource.getDefaultDragSource().startDrag(dge, DragSource.DefaultLinkDrop, transferable, null);
+ dge.startDrag(DragSource.DefaultLinkDrop, transferable, null);
}
}
}
\ No newline at end of file
--
GitLab