use of org.cytoscape.application.events.CyShutdownListener in project cytoscape-impl by cytoscape.
the class MacCyActivator method start.
@Override
public void start(BundleContext context) throws Exception {
final CyServiceRegistrar serviceRegistrar = getService(context, CyServiceRegistrar.class);
final CyShutdown shutdown = getService(context, CyShutdown.class);
final TaskFactory aboutTaskFactory = new HelpAboutTaskFactory(serviceRegistrar);
final DialogTaskManager taskManager = getService(context, DialogTaskManager.class);
final CyShutdownEvent[] lastShutdownEvent = new CyShutdownEvent[1];
CyShutdownListener listener = (CyShutdownEvent e) -> {
lastShutdownEvent[0] = e;
};
registerService(context, listener, CyShutdownListener.class, new Properties());
Application application = Application.getApplication();
application.setQuitHandler((QuitEvent event, QuitResponse response) -> {
shutdown.exit(0);
if (lastShutdownEvent[0] != null && !lastShutdownEvent[0].actuallyShutdown()) {
response.cancelQuit();
}
});
application.setAboutHandler((AboutEvent event) -> {
taskManager.execute(aboutTaskFactory.createTaskIterator());
});
}
use of org.cytoscape.application.events.CyShutdownListener in project cytoscape-impl by cytoscape.
the class AppManagerAction method createShutdownListener.
private CyShutdownListener createShutdownListener() {
CyShutdownListener shutdownListener = new CyShutdownListener() {
@Override
public void handleEvent(CyShutdownEvent e) {
if (dialog != null) {
dialog.setVisible(false);
dialog.dispose();
}
serviceRegistrar.unregisterService(this, CyShutdownListener.class);
}
};
return shutdownListener;
}
Aggregations