1 19 20 package org.netbeans.modules.editor; 21 22 import java.awt.event.InputEvent ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 import java.util.Map ; 26 import java.util.logging.Level ; 27 import java.util.logging.Logger ; 28 import org.netbeans.api.editor.mimelookup.MimeLookup; 29 import org.netbeans.api.editor.mimelookup.MimePath; 30 import org.netbeans.editor.BaseSettingsInitializer; 31 import org.netbeans.editor.Settings; 32 import org.netbeans.editor.SettingsDefaults; 33 import org.netbeans.editor.ext.ExtSettingsNames; 34 import org.netbeans.editor.ext.ExtSettingsInitializer; 35 import org.netbeans.modules.editor.options.OptionUtilities; 36 import org.netbeans.modules.editor.options.AllOptionsFolder; 37 import org.netbeans.editor.BaseKit; 38 import org.netbeans.editor.SettingsNames; 39 import org.netbeans.modules.editor.impl.KitsTracker; 40 import org.netbeans.modules.editor.options.BaseOptions; 41 import org.netbeans.modules.editor.options.BasePrintOptions; 42 import org.openide.util.Utilities; 43 44 50 51 public class NbEditorSettingsInitializer extends Settings.AbstractInitializer { 52 53 private static final Logger LOG = Logger.getLogger(NbEditorSettingsInitializer.class.getName()); 54 55 public static final String NAME = "nb-editor-settings-initializer"; 57 private static boolean mainInitDone; 58 59 public static void init() { 60 if (!mainInitDone) { 61 mainInitDone = true; 62 Settings.addInitializer(new BaseSettingsInitializer(), Settings.CORE_LEVEL); 63 Settings.addInitializer(new ExtSettingsInitializer(), Settings.CORE_LEVEL); 64 Settings.addInitializer(new NbEditorSettingsInitializer()); 65 66 Settings.reset(); 67 68 BasePrintOptions bpo = (BasePrintOptions) BasePrintOptions.findObject(BasePrintOptions.class, true); 70 bpo.init(); 71 } 72 } 73 74 public NbEditorSettingsInitializer() { 75 super(NAME); 76 } 77 78 85 public void updateSettingsMap(Class kitClass, Map settingsMap) { 86 87 if (kitClass == BaseKit.class) { 88 settingsMap.put(BaseOptions.TOOLBAR_VISIBLE_PROP, Boolean.TRUE); 89 settingsMap.put(BaseOptions.LINE_NUMBER_VISIBLE_PROP, SettingsDefaults.defaultLineNumberVisible); 90 91 int activationMask; 95 96 activationMask = Utilities.isMac()? InputEvent.META_MASK: InputEvent.CTRL_DOWN_MASK; 97 settingsMap.put(SettingsNames.HYPERLINK_ACTIVATION_MODIFIERS, Integer.valueOf(activationMask)); 98 } 99 100 if (kitClass == NbEditorKit.class) { 101 if (AllOptionsFolder.getDefault().baseInitialized()){ 103 settingsMap.put(ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST, 105 OptionUtilities.getPopupStrings(OptionUtilities.getGlobalPopupMenuItems()) 106 ); 107 } 108 } 109 110 List mimeTypes = KitsTracker.getInstance().getMimeTypesForKitClass(kitClass); 111 for(Iterator i = mimeTypes.iterator(); i.hasNext(); ) { 112 String mimeType = (String ) i.next(); 113 114 if (LOG.isLoggable(Level.FINE)) { 115 LOG.fine("Initializing settings for '" + mimeType + "', " + kitClass); 116 } 117 118 MimePath mimePath = MimePath.parse(mimeType); 121 BaseOptions bo = (BaseOptions) MimeLookup.getLookup(mimePath).lookup(BaseOptions.class); 122 if (bo == null) { 123 if (LOG.isLoggable(Level.FINE)) { 124 LOG.fine("Top level mime type '" + mimeType + "' with no BaseOptions."); } 126 } 127 } 128 } 129 } 130 | Popular Tags |