KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectstyle > cayenne > modeler > MacOSXSetup


1 package org.objectstyle.cayenne.modeler;
2
3 import org.objectstyle.cayenne.modeler.action.AboutAction;
4 import org.objectstyle.cayenne.modeler.action.ExitAction;
5 import org.objectstyle.cayenne.modeler.util.CayenneAction;
6
7 import com.apple.eawt.ApplicationAdapter;
8 import com.apple.eawt.ApplicationEvent;
9
10 /**
11  * Configures Modeler to better integrate into Mac OS X environment. Has no effect
12  * on other platforms.
13  *
14  * @since 1.1
15  * @author Andrei Adamchik
16  */

17 class MacOSXSetup {
18
19     static void configureMacOSX() {
20         // Application.getApplication().setEnabledPreferencesMenu(true);
21
com.apple.eawt.Application.getApplication().addApplicationListener(new MacEventsAdapter());
22     }
23
24     static class MacEventsAdapter extends ApplicationAdapter {
25
26         public void handleAbout(ApplicationEvent e) {
27             if (!e.isHandled()) {
28                 ((AboutAction) getAction(AboutAction.getActionName())).showAboutDialog();
29                 e.setHandled(true);
30             }
31         }
32
33         public void handleQuit(ApplicationEvent e) {
34             if (!e.isHandled()) {
35                 ((ExitAction) getAction(ExitAction.getActionName())).exit();
36                 e.setHandled(true);
37             }
38         }
39
40         CayenneAction getAction(String JavaDoc name) {
41             return Application.getInstance().getAction(name);
42         }
43     }
44 }
45
Popular Tags