1 19 20 package org.netbeans.modules.properties.syntax; 21 22 import java.util.MissingResourceException ; 23 24 import org.netbeans.editor.LocaleSupport; 25 import org.netbeans.editor.Settings; 26 27 import org.openide.modules.ModuleInstall; 28 import org.openide.text.PrintSettings; 29 import org.openide.util.NbBundle; 30 import org.openide.util.SharedClassObject; 31 32 37 public class RestoreColoring extends ModuleInstall { 38 39 40 private static LocaleSupport.Localizer localizer; 41 42 43 public void restored() { 44 addInitializer(); 45 installOptions(); 46 } 47 48 49 public void uninstalled() { 50 uninstallOptions(); 51 } 52 53 54 public void addInitializer() { 55 Settings.addInitializer(new PropertiesSettingsInitializer()); 56 } 57 58 59 public void installOptions() { 60 PrintSettings printSettings = (PrintSettings)SharedClassObject.findObject(PrintSettings.class, true); 61 printSettings.addOption((PropertiesPrintOptions)SharedClassObject.findObject(PropertiesPrintOptions.class, true)); 62 63 64 LocaleSupport.addLocalizer(localizer = new LocaleSupport.Localizer() { 66 public String getString(String key) { 67 try { 68 return NbBundle.getBundle(RestoreColoring.class).getString(key); 69 } catch(MissingResourceException mre) { 70 return null; 71 } 72 } 73 }); 74 } 75 76 77 public void uninstallOptions() { 78 PropertiesPrintOptions propertiesPrintOptions = (PropertiesPrintOptions)SharedClassObject.findObject(PropertiesPrintOptions.class, false); 79 if(propertiesPrintOptions != null) { 80 PrintSettings printSettings = (PrintSettings)SharedClassObject.findObject(PrintSettings.class, true); 81 printSettings.removeOption(propertiesPrintOptions); 82 } 83 84 LocaleSupport.removeLocalizer(localizer); 86 } 87 88 } 89 | Popular Tags |