Skip to content
Snippets Groups Projects
Commit 89eb56df authored by Stéphane  DALLONGEVILLE's avatar Stéphane DALLONGEVILLE
Browse files

Fixed 'Call IJ Plugin' and 'Get Active Image Plus' block (regression)

parent c7782f69
No related branches found
No related tags found
No related merge requests found
......@@ -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)
{
......
......@@ -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();
......
......@@ -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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment