Wait for PlugIn dialog is closed

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

Wait for PlugIn dialog is closed

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

Re: Wait for PlugIn dialog is closed

Michael Entrup
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