Use EzPlug stop button

22 views
Skip to first unread message

John leger

unread,
Jul 21, 2014, 9:40:50 AM7/21/14
to icy-so...@googlegroups.com
Hi,

I created my plugin with EzPlug and I would like to be able to use the Stop button of the standard interface.

But my plug in is launched using the start button only once, after that all the computations are done without it and so the button stop is disabled and I don't know how I could reactivate it and use it.

My idea is when I do some heavy computation I activate the button and when I have finished, I deactivate it.

But I don't know how ?

And just to be sure the "public void stopExecution()" that i get from the extend EzPlug is what will be called when the Stop button is call ?

Thanks for your ideas.

PS: In the image, the button I'm talking about.

stop.png

Alexandre Dufour

unread,
Jul 21, 2014, 10:07:00 AM7/21/14
to icy-so...@googlegroups.com
Hi John,

I am going to guess that your “heavy” calculations are conducted on one or more threads in the background. Just so you know, the “execute()” method itself runs in a separate thread (so it’s not freezing the graphical interface), so the immediate answer would be for you to shift your calculations directly inside the execute() method, and wait for your extra thread(s) to finish there (it won’t consume extra resources, and will keeping the stop button active).

If for whatever reason you can’t do this, the other option is to forget about the EzStoppable interface, and handle a “stop” button yourself in the interface (you could actually use the convenient EzButton class for that purpose). This way you can enable/disable it and handle click events when needed. You can then further “force” the state of the run button to remain inactive using something like “getUI().setRunButtonEnabled(false)” 

Let me know if that helps…
Alexandre

--
You received this message because you are subscribed to the Google Groups "Icy imaging" group.
To unsubscribe from this group and stop receiving emails from it, send an email to icy-software...@googlegroups.com.
To post to this group, send email to icy-so...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/icy-software/961b75f2-41ca-4604-8d1a-c66c58820d32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<stop.png>

John leger

unread,
Jul 21, 2014, 10:20:33 AM7/21/14
to icy-so...@googlegroups.com
Thanks for your answer.

So i didn't know that but when I was doing my computations, the interface was freezing so that's why I use a thread (because the computation was not done in "execute" either).

My computations are called when we move the slider, so they need to be done on the fly (and after "execute()") as "execute()" is called only once.

I already thought of adding my own "EmergencyStopButton" but if i could use the standard one it would have been better, but no problems I will try this idea.

Alexandre Dufour

unread,
Jul 21, 2014, 10:44:47 AM7/21/14
to icy-so...@googlegroups.com

On 21 Jul 2014, at 15:20, John leger <johnl...@gmail.com> wrote:

> So i didn't know that but when I was doing my computations, the interface was freezing so that's why I use a thread (because the computation was not done in "execute" either).
> My computations are called when we move the slider, so they need to be done on the fly (and after "execute()") as "execute()" is called only once.

That is the reason why the interface is freezing. The run button calls “execute” in a separate thread, but a change listener method (from slider events) will run on the graphical thread.

> I already thought of adding my own "EmergencyStopButton" but if i could use the standard one it would have been better, but no problems I will try this idea

I do have a method (currently hidden) called via “getUI().setRunningState(boolean)” that handles the states of both the run and stop buttons (it’s the one I use internally when the run button is clicked by the user). I could give you public access to that (once I make sure it doesn’t break anything else…), so you can set it to true (again) after each change value on your slider, and set it back to false after your computations are done. Does this seem reasonable?

Alexandre

John leger

unread,
Jul 22, 2014, 6:47:08 AM7/22/14
to icy-so...@googlegroups.com

For now i will try to be cleaner on my side and, if even a cleaner code is not enough I will use that. But for now this button is secondary because my stop function is ugly...

Thanks.
 

Alexandre
Reply all
Reply to author
Forward
0 new messages