use of com.apple.eawt.QuitResponse 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 com.apple.eawt.QuitResponse in project energy3d by concord-consortium.
the class Mac method init.
public static void init() {
final Application application = Application.getApplication();
application.setDockIconImage(Toolkit.getDefaultToolkit().getImage(MainFrame.class.getResource("icons/icon.png")));
application.setOpenFileHandler(new OpenFilesHandler() {
@Override
public void openFiles(final OpenFilesEvent e) {
MainApplication.isMacOpeningFile = true;
SceneManager.getTaskManager().update(new Callable<Object>() {
@Override
public Object call() throws Exception {
// somehow newFile() must be called to set up the scene before we can correctly load the content when an NG3 file is double-clicked without an open instance
if (Scene.getURL() == null) {
Scene.newFile();
}
try {
Scene.open(new File(e.getFiles().get(0).toString()).toURI().toURL());
} catch (final Throwable err) {
BugReporter.report(err, e.getFiles().get(0).toString());
}
return null;
}
});
}
});
application.setAboutHandler(new AboutHandler() {
@Override
public void handleAbout(final AboutEvent e) {
MainFrame.getInstance().showAbout();
}
});
application.setPreferencesHandler(new PreferencesHandler() {
@Override
public void handlePreferences(final PreferencesEvent e) {
MainFrame.getInstance().showPreferences();
}
});
application.setQuitHandler(new QuitHandler() {
@Override
public void handleQuitRequestWith(final QuitEvent e, final QuitResponse r) {
MainFrame.getInstance().exit();
r.cancelQuit();
}
});
}
Aggregations