[ImageJ-devel] Please don't quit
Lee Kamentsky
leek at broadinstitute.org
Wed Nov 5 10:23:17 CST 2014
Oops never mind, what I tried actually worked. AppQuitEvent.consume() did
the trick. Go figure - you guys really threw the whole kitchen sink into
it, didn't you?
@Plugin(type = Service.class, priority = Priority.HIGH_PRIORITY)
public class CellProfilerAppService extends DefaultAppService {
static boolean canQuit = false;
public static void allowQuit() {
canQuit = true;
}
public static void preventQuit() {
canQuit = false;
}
@EventHandler
public void onEvent(final AppQuitEvent event) {
if (canQuit) {
super.onEvent(event);
} else {
final UIService uiService = getContext().getService(UIService.class);
final LogService logService = getContext().getService(LogService.class);
if (uiService.isVisible()) {
UserInterface ui = uiService.getDefaultUI();
logService.info("Quit action: hide the application frame");
ui.getApplicationFrame().setVisible(false);
} else {
logService.info("Quit action: do nothing");
}
event.consume();
}
}
}
On Wed, Nov 5, 2014 at 11:15 AM, Lee Kamentsky <leek at broadinstitute.org>
wrote:
> Hi all,
> I had a class (
> https://github.com/CellProfiler/CellProfiler/blob/master/java/src/main/java/org/cellprofiler/ijutils/CellProfilerAppEventService.java)
> that implemented the deprecated AppEventService whose purpose was to
> prevent ImageJ from quitting if a user closed its window by overriding
> AppEventService.quit(). Quitting is pretty devastating for CellProfiler
> since the process closes when the user's probable intent was to hide the
> window.
>
> I'm hoping someone can give me a hint about how to do it now - I thought
> I'd cheat by asking instead of figuring it out myself.
>
> Thanks in advance,
> --Lee
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20141105/1f7f559c/attachment.html>
More information about the ImageJ-devel
mailing list