KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > editor > codetemplates > CodeTemplatesModule


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.lib.editor.codetemplates;
21 import javax.swing.Action JavaDoc;
22 import org.netbeans.editor.BaseKit;
23 import org.netbeans.editor.Settings;
24 import org.netbeans.editor.SettingsNames;
25 import org.netbeans.editor.SettingsUtil;
26 import org.openide.modules.ModuleInstall;
27
28
29 /**
30  * Module installation class for editor.
31  *
32  * @author Miloslav Metelka
33  */

34 public class CodeTemplatesModule extends ModuleInstall {
35
36     public void restored () {
37         synchronized (Settings.class) {
38             SettingsUtil.updateListSetting(BaseKit.class,
39                     SettingsNames.CUSTOM_ACTION_LIST,
40                     new Object JavaDoc[] { AbbrevKitInstallAction.INSTANCE }
41             );
42             SettingsUtil.updateListSetting(BaseKit.class,
43                     SettingsNames.KIT_INSTALL_ACTION_NAME_LIST,
44                     new Object JavaDoc[] { AbbrevKitInstallAction.INSTANCE.getValue(Action.NAME) }
45             );
46             Settings.addInitializer(new AbbrevSettingsInitializer());
47         }
48         
49     }
50     
51     /**
52      * Called when all modules agreed with closing and the IDE will be closed.
53      */

54     public void close() {
55         finish();
56     }
57     
58     /**
59      * Called when module is uninstalled.
60      */

61     public void uninstalled() {
62         finish();
63     }
64     
65     private void finish() {
66         Settings.removeInitializer(AbbrevSettingsInitializer.NAME);
67         Settings.reset();
68         
69         // Go through components and clear the AbbrevDetection.class property
70
}
71
72     private static final class AbbrevSettingsInitializer extends Settings.AbstractInitializer {
73         
74         static final String JavaDoc NAME = "bookmarks-settings-initializer"; // NOI18N
75

76         AbbrevSettingsInitializer() {
77             super(NAME);
78         }
79
80         public void updateSettingsMap(Class JavaDoc kitClass, java.util.Map JavaDoc settingsMap) {
81             if (kitClass == BaseKit.class) {
82                 SettingsUtil.updateListSetting(settingsMap,
83                         SettingsNames.CUSTOM_ACTION_LIST,
84                         new Object JavaDoc[] { AbbrevKitInstallAction.INSTANCE }
85                 );
86                 SettingsUtil.updateListSetting(settingsMap,
87                         SettingsNames.KIT_INSTALL_ACTION_NAME_LIST,
88                         new Object JavaDoc[] { AbbrevKitInstallAction.INSTANCE.getValue(Action.NAME) }
89                 );
90             }
91         }
92         
93     }
94     
95 }
96
Popular Tags