Login  Register

Wait for MacroRunner

Posted by Peter Haub on Dec 17, 2014; 11:37am
URL: http://imagej.273.s1.nabble.com/Wait-for-MacroRunner-tp5010982.html

Dear Wayne,

I need to call a plugin via macro call to bypass the user dialogs of the
plugin.
This I have done by using a MacroRunner in MyPlugin, such as:
             ...
             String macroStr = "run(" + cmdStr + "," + argStr +");";
             macro = new MacroRunner(macroStr);
             ...

The problem is that MyPlugin has to wait until the macro thread has been
finished. I managed this by adding a getThread() function into the
MacroRunner.java. In MyPlugin I can wait for the macro thread e.g. by:
             ...
             t = macro.getThread();
             while (!t.isInterrupted() && t.isAlive()){
                 IJ.wait(200);
             }
             ...

My questions are:
Is there a more simple way to achieve my task (calling a plugin from a
plugin with an argument string and bypassing user dialogs)?
If my MacroRunner suggestion is a working option, would it be possible
to add a getThread() function into the MacroRunner code of a next
version of ImageJ? (We would like to stay on the official ImageJ code.)

Thanks
and regards,

Peter

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html