1 19 package org.netbeans.modules.refactoring.java; 20 21 import java.io.IOException ; 22 import org.netbeans.api.java.source.ClasspathInfo; 23 import org.openide.ErrorManager; 24 import org.openide.filesystems.FileObject; 25 import org.openide.filesystems.FileSystem; 26 import org.openide.filesystems.Repository; 27 import org.openide.modules.ModuleInstall; 28 29 35 public class RefactoringModule extends ModuleInstall { 36 37 38 private static FileObject optionsFile = null; 39 40 50 public static Object getOption(String key, Object defaultValue) { 51 if (optionsFile == null) { 52 findOptionsFile(); 53 } 54 if (optionsFile == null) 55 return defaultValue; 56 Object o = optionsFile.getAttribute(key); 57 return o != null ? o : defaultValue; 58 } 59 60 68 public static void setOption(String key, Object value) { 69 if (optionsFile == null) { 70 findOptionsFile(); 71 } 72 try { 73 optionsFile.setAttribute(key, value); 74 } catch (IOException e) { 75 ErrorManager.getDefault().notify(e); 76 } 77 } 78 79 private static void findOptionsFile() { 80 FileSystem fs = Repository.getDefault().getDefaultFileSystem(); 81 optionsFile = fs.findResource("Services/org-netbeans-modules-refactoring/options"); } 83 } 84 | Popular Tags |