1 19 20 package org.netbeans.lib.editor.codetemplates; 21 import javax.swing.Action ; 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 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 [] { AbbrevKitInstallAction.INSTANCE } 41 ); 42 SettingsUtil.updateListSetting(BaseKit.class, 43 SettingsNames.KIT_INSTALL_ACTION_NAME_LIST, 44 new Object [] { AbbrevKitInstallAction.INSTANCE.getValue(Action.NAME) } 45 ); 46 Settings.addInitializer(new AbbrevSettingsInitializer()); 47 } 48 49 } 50 51 54 public void close() { 55 finish(); 56 } 57 58 61 public void uninstalled() { 62 finish(); 63 } 64 65 private void finish() { 66 Settings.removeInitializer(AbbrevSettingsInitializer.NAME); 67 Settings.reset(); 68 69 } 71 72 private static final class AbbrevSettingsInitializer extends Settings.AbstractInitializer { 73 74 static final String NAME = "bookmarks-settings-initializer"; 76 AbbrevSettingsInitializer() { 77 super(NAME); 78 } 79 80 public void updateSettingsMap(Class kitClass, java.util.Map settingsMap) { 81 if (kitClass == BaseKit.class) { 82 SettingsUtil.updateListSetting(settingsMap, 83 SettingsNames.CUSTOM_ACTION_LIST, 84 new Object [] { AbbrevKitInstallAction.INSTANCE } 85 ); 86 SettingsUtil.updateListSetting(settingsMap, 87 SettingsNames.KIT_INSTALL_ACTION_NAME_LIST, 88 new Object [] { AbbrevKitInstallAction.INSTANCE.getValue(Action.NAME) } 89 ); 90 } 91 } 92 93 } 94 95 } 96 | Popular Tags |