Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
MacOSXConfiguration |
|
| 1.0;1 | ||||
MacOSXConfiguration$1 |
|
| 1.0;1 | ||||
MacOSXConfiguration$MacApplicationAdapter |
|
| 1.0;1 |
1 | package org.jtheque.core.managers.view; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import com.apple.eawt.Application; | |
20 | import com.apple.eawt.ApplicationAdapter; | |
21 | import com.apple.eawt.ApplicationEvent; | |
22 | import org.jtheque.core.managers.Managers; | |
23 | import org.jtheque.core.managers.view.able.IViewManager; | |
24 | ||
25 | /** | |
26 | * Configuration to improve the compatibility with mac. | |
27 | * | |
28 | * @author Baptiste Wicht | |
29 | */ | |
30 | final class MacOSXConfiguration { | |
31 | 0 | private static final Application APPLICATION = new Application(); |
32 | ||
33 | /** | |
34 | * Construct a new MacOSXConfiguration. This class isn't instanciable. | |
35 | */ | |
36 | private MacOSXConfiguration() { | |
37 | 0 | super(); |
38 | 0 | } |
39 | ||
40 | /** | |
41 | * Configure the application for Mac menus. | |
42 | */ | |
43 | public static void configureForMac() { | |
44 | 0 | APPLICATION.addApplicationListener(new MacApplicationAdapter()); |
45 | 0 | APPLICATION.setEnabledAboutMenu(true); |
46 | 0 | APPLICATION.setEnabledPreferencesMenu(true); |
47 | 0 | } |
48 | ||
49 | /** | |
50 | * An application adapter for MAC OS X. This application handles the event | |
51 | * of the MAC menu to the jtheque application. | |
52 | * | |
53 | * @author Baptiste Wicht | |
54 | */ | |
55 | 0 | private static final class MacApplicationAdapter extends ApplicationAdapter { |
56 | @Override | |
57 | public void handleQuit(ApplicationEvent ev) { | |
58 | 0 | Managers.getCore().getLifeCycleManager().exit(); |
59 | 0 | } |
60 | ||
61 | @Override | |
62 | public void handleAbout(ApplicationEvent ev) { | |
63 | 0 | Managers.getManager(IViewManager.class).displayAboutView(); |
64 | ||
65 | 0 | ev.setHandled(true); |
66 | 0 | } |
67 | ||
68 | @Override | |
69 | public void handlePreferences(ApplicationEvent ev) { | |
70 | 0 | Managers.getManager(IViewManager.class).getViews().getConfigView().display(); |
71 | ||
72 | 0 | ev.setHandled(true); |
73 | 0 | } |
74 | } | |
75 | } |