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 e9b08f493c49a092726d824f984b7fb413425a7c..c1202efb36ce67053f05a96bbdba090106728fd5 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 f5fe70291cda2a1c54145bf195c35f240b2baa25..6c1ccd0bae892c612f279c390303ee2199e97b2f 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 5bc1f74705f41aff2ff537ed14945ca730b1dac7..d4c2e1f15a89d0d9e96db3fe66db2bddcbdd82b2 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