Login  Register

Re: Wait for PlugIn dialog is closed

Posted by Michael Entrup on Jan 25, 2016; 9:33am
URL: http://imagej.273.s1.nabble.com/Wait-for-PlugIn-dialog-is-closed-tp5015424p5015447.html

Hi Thorsten,

do you use a non modal dialog? I think any modal dialog will pause the
execution of a macro until OK/Cancel is pressed. The GenericDialog [1]
is an example for a modal dialog.

If it is necessary to use a non modal dialog, you should have a look at
WaitForUserDialog [2]. In line 60 `wait()` is used to pause the calling
thread. On line 66 `notify()` is used to wake it up. Without this
mechanism the macro is not paused.

I try to visualise the two threads that are involved:

--macro--\--wait()----------------/--resume--run("Quit")--
           \                      /
            \--Dialog--notify()--/

Best regards
Michael


[1] https://github.com/imagej/imagej1/blob/master/ij/gui/GenericDialog.java
[2]
https://github.com/imagej/imagej1/blob/master/ij/gui/WaitForUserDialog.java


On 21.01.2016 14:41, Thorsten Wagner wrote:

> Dear list,
>
> I'm using a java plugin which extends the interface "PlugIn".
>
> This plugins opens a simple swing ui were you can make some settings
> and then press OK and the settings are saved and the dialog is closed.
>
> Now I would like tp use the plugin in a following manner:
> ImageJ is started by console and runs the following macro:
>
> run("Settings Manager");
> run("Quit")
>
> However, the Settings Manager is started but then imagej is closed.
> But I want that the run("Quit") command is not applied until the user
> pressed "OK" in the settins manager.
>
> Any ideas?
>
> Cheers,
> Thorsten
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

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