5 // Copyright (C) 2007 Lutz Mueller
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
22 // adapted from OSXAdapter.java in package apple.dts.samplecode.osxadapter;
24 import com
.apple
.eawt
.*;
26 public class OSXAdapter
extends ApplicationAdapter
{
28 private static OSXAdapter theAdapter
;
29 private static com
.apple
.eawt
.Application theApplication
;
31 private guiserver mainApp
;
33 private OSXAdapter (guiserver inApp
) {
37 public void handleAbout(ApplicationEvent ae
) {
38 if (mainApp
!= null) {
42 throw new IllegalStateException("handleAbout: MyApp instance detached from listener");
46 public void handlePreferences(ApplicationEvent ae
) {
47 if (mainApp
!= null) {
48 mainApp
.preferences();
51 throw new IllegalStateException("handlePreferences: MyApp instance detached from listener");
55 public void handleQuit(ApplicationEvent ae
) {
56 if (mainApp
!= null) {
60 throw new IllegalStateException("handleQuit: MyApp instance detached from listener");
65 public static void registerMacOSXApplication(guiserver inApp
) {
66 if (theApplication
== null) {
67 theApplication
= new com
.apple
.eawt
.Application();
70 if (theAdapter
== null) {
71 theAdapter
= new OSXAdapter(inApp
);
73 theApplication
.addApplicationListener(theAdapter
);
76 public static void enablePrefs(boolean enabled
) {
77 if (theApplication
== null) {
78 theApplication
= new com
.apple
.eawt
.Application();
80 theApplication
.setEnabledPreferencesMenu(false);