1 19 20 package org.netbeans.test.editor.suites.abbrevs; 21 22 import org.netbeans.modules.editor.options.BaseOptions; 23 import java.util.ResourceBundle ; 24 import org.openide.util.NbBundle; 25 import org.netbeans.modules.editor.options.BaseOptionsBeanInfo; 26 import java.awt.event.KeyEvent ; 27 import java.util.ArrayList ; 28 import java.util.HashMap ; 29 import java.util.Iterator ; 30 import java.util.Map ; 31 import org.openide.options.SystemOption; 35 36 40 public class Utilities { 41 42 43 44 public Utilities() { 45 } 46 47 public static ResourceBundle getEditorBundle() { 48 return NbBundle.getBundle(BaseOptionsBeanInfo.class); 49 } 50 51 55 public static Object saveAbbreviationsState() { 56 SystemOption[] options = new SystemOption[]{}; 61 Map result = new HashMap (); 62 63 for (int cntr = 0; cntr < options.length; cntr++) { 64 if (options[cntr] instanceof BaseOptions) { 65 BaseOptions baseOptions = (BaseOptions) options[cntr]; 66 result.put(baseOptions.getClass(), baseOptions.getAbbrevMap()); 67 } 68 } 69 return result; 70 } 71 72 public static void restoreAbbreviationsState(Object state) throws ClassCastException { 73 Map abbreviations = (Map ) state; 75 77 { 78 Iterator it = abbreviations.values().iterator(); 79 Map dummy; 80 81 while (it.hasNext()) { 82 dummy = (Map ) it.next(); 83 } 84 } 85 86 88 SystemOption[] options = new SystemOption[] {}; 92 94 for (int cntr = 0; cntr < options.length; cntr++) { 95 if (options[cntr] instanceof BaseOptions) { 96 BaseOptions baseOptions = (BaseOptions) options[cntr]; 97 Map kitAbbreviations = (Map ) abbreviations.get(baseOptions.getClass()); 99 if (kitAbbreviations != null) { 100 baseOptions.setAbbrevMap(kitAbbreviations); 101 } 102 } 103 } 104 105 } 106 107 public static void main(String [] argv) { 108 Utilities.saveAbbreviationsState(); 109 } 110 111 } 112 | Popular Tags |