KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > applemenu > Install


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.applemenu;
21
22 import java.awt.AWTEvent JavaDoc;
23 import java.awt.Toolkit JavaDoc;
24 import java.lang.reflect.*;
25 import org.openide.modules.ModuleInstall;
26
27 /** Module installer that installs an com.apple.eawt.ApplicationListener on
28  * the com.apple.eawt.Application object for this session, which will interpret
29  * apple events and call the appropriate action from the actions pool.
30  *
31  * @author Tim Boudreau
32  */

33 public class Install extends ModuleInstall {
34     private CtrlClickHack listener;
35
36     public void restored () {
37         listener = new CtrlClickHack();
38         Toolkit.getDefaultToolkit().addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK);
39         if (System.getProperty("mrj.version") != null) { // NOI18N
40
FontReferenceQueue.install();
41             try {
42                 Class JavaDoc adapter = Class.forName("org.netbeans.modules.applemenu.NbApplicationAdapter");
43                 Method m = adapter.getDeclaredMethod("install", new Class JavaDoc[0] );
44                 m.invoke(adapter, new Object JavaDoc[0]);
45             } catch (NoClassDefFoundError JavaDoc e) {
46             } catch (ClassNotFoundException JavaDoc e) {
47             } catch (Exception JavaDoc e) {
48             }
49         }
50     }
51     
52     public void uninstalled () {
53          if (listener != null) {
54             Toolkit.getDefaultToolkit().removeAWTEventListener(listener);
55             listener = null;
56          }
57         if (System.getProperty("mrj.version") != null) { // NOI18N
58

59             try {
60                 Class JavaDoc adapter = Class.forName("org.netbeans.modules.applemenu.NbApplicationAdapter");
61                 Method m = adapter.getDeclaredMethod("uninstall", new Class JavaDoc[0] );
62                 m.invoke(adapter, new Object JavaDoc[0]);
63             } catch (NoClassDefFoundError JavaDoc e) {
64             } catch (ClassNotFoundException JavaDoc e) {
65             } catch (Exception JavaDoc e) {
66             }
67         }
68     }
69 }
70
Popular Tags