Search in sources :

Example 1 with AboutHandler

use of com.apple.eawt.AboutHandler 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();
        }
    });
}
Also used : AboutEvent(com.apple.eawt.AppEvent.AboutEvent) PreferencesHandler(com.apple.eawt.PreferencesHandler) OpenFilesHandler(com.apple.eawt.OpenFilesHandler) Callable(java.util.concurrent.Callable) AboutHandler(com.apple.eawt.AboutHandler) QuitHandler(com.apple.eawt.QuitHandler) OpenFilesEvent(com.apple.eawt.AppEvent.OpenFilesEvent) PreferencesEvent(com.apple.eawt.AppEvent.PreferencesEvent) MainApplication(org.concord.energy3d.MainApplication) Application(com.apple.eawt.Application) File(java.io.File) QuitResponse(com.apple.eawt.QuitResponse) QuitEvent(com.apple.eawt.AppEvent.QuitEvent)

Aggregations

AboutHandler (com.apple.eawt.AboutHandler)1 AboutEvent (com.apple.eawt.AppEvent.AboutEvent)1 OpenFilesEvent (com.apple.eawt.AppEvent.OpenFilesEvent)1 PreferencesEvent (com.apple.eawt.AppEvent.PreferencesEvent)1 QuitEvent (com.apple.eawt.AppEvent.QuitEvent)1 Application (com.apple.eawt.Application)1 OpenFilesHandler (com.apple.eawt.OpenFilesHandler)1 PreferencesHandler (com.apple.eawt.PreferencesHandler)1 QuitHandler (com.apple.eawt.QuitHandler)1 QuitResponse (com.apple.eawt.QuitResponse)1 File (java.io.File)1 Callable (java.util.concurrent.Callable)1 MainApplication (org.concord.energy3d.MainApplication)1