Wait for MacroRunner

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Wait for MacroRunner

Peter Haub
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
Reply | Threaded
Open this post in threaded view
|

Re: Wait for MacroRunner

Jan Eglinger
Dear Peter,

 > This I have done by using a MacroRunner in MyPlugin, such as:
 >              ...
 >              String macroStr = "run(" + cmdStr + "," + argStr +");";
 >              macro = new MacroRunner(macroStr);
 >              ...

To run a plugin from within another plugin, you can use

     IJ.run(cmdStr, argStr);

(see http://javadoc.imagej.net/ImageJ1/index.html?ij/IJ.html )

You can record the necessary code for the plugin by running the Macro
recorder (Plugins > Macros > Record...) in Java mode.


Does that help?

Cheers,
Jan



On 17.12.14 12:37, Peter Haub wrote:

> 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

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Wait for MacroRunner

Peter Haub
Hallo Jan,
Hallo Wayne,

Yes, this helps.
Back to IJ.run() I got rid of the all that MacroRunner, ThreadWatchers etc..

Incorrectly I wrote "Test_Plugin" instead of "Test Plugin" to call the
plugin Test_Plugin.
My fault.  :-((

Thanks for your help.

Regards,
Peter


On 17.12.2014 14:41, Jan Eglinger wrote:

> Dear Peter,
>
> > This I have done by using a MacroRunner in MyPlugin, such as:
> >              ...
> >              String macroStr = "run(" + cmdStr + "," + argStr +");";
> >              macro = new MacroRunner(macroStr);
> >              ...
>
> To run a plugin from within another plugin, you can use
>
>     IJ.run(cmdStr, argStr);
>
> (see http://javadoc.imagej.net/ImageJ1/index.html?ij/IJ.html )
>
> You can record the necessary code for the plugin by running the Macro
> recorder (Plugins > Macros > Record...) in Java mode.
>
>
> Does that help?
>
> Cheers,
> Jan
>
>
>
> On 17.12.14 12:37, Peter Haub wrote:
>> 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
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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