1 19 package org.netbeans.modules.css.text.syntax; 20 21 import java.awt.Font ; 22 import java.awt.Color ; 23 import java.util.Map ; 24 import java.util.TreeMap ; 25 import java.util.List ; 26 import java.util.ArrayList ; 27 import java.util.Arrays ; 28 29 import org.openide.actions.ToolsAction; 30 import org.openide.windows.TopComponent; 31 32 import org.netbeans.editor.*; 33 import org.netbeans.editor.ext.ExtSettingsNames; 34 35 import org.netbeans.modules.css.actions.*; 36 import org.netbeans.modules.css.text.syntax.CSSTokenContext; 37 38 44 public class CSSEditorSettings extends Settings.AbstractInitializer { 45 46 47 public static final String NAME = "css-settings-initializer"; 49 static final Font boldFont = SettingsDefaults.defaultFont.deriveFont(Font.BOLD); 50 static final Font italicFont = SettingsDefaults.defaultFont.deriveFont(Font.ITALIC); 51 52 53 public CSSEditorSettings() { 54 super(NAME); 55 } 56 57 66 public void updateSettingsMap(Class kitClass, Map settingsMap) { 67 68 if (kitClass == null) return; 70 71 if (kitClass == BaseKit.class) { 72 73 new CSSTokenColoringInitializer().updateSettingsMap(kitClass, settingsMap); 74 76 } 77 78 if ("org.netbeans.modules.css.text.syntax.CSSEditorKit".equals(kitClass.getName())) { 80 81 83 List cssActionNames = new ArrayList 84 (Arrays.asList (new String [] { 85 CopyStyleAction.XML.class.getName(), 86 CopyStyleAction.HTML.class.getName(), 87 CheckStyleAction.class.getName(), 88 null, 89 TopComponent.class.getName(), 94 null, 95 BaseKit.cutAction, 96 BaseKit.copyAction, 97 BaseKit.pasteAction, 98 null, 99 BaseKit.removeSelectionAction, 100 null, 101 ToolsAction.class.getName(), 102 })); 103 104 settingsMap.put (ExtSettingsNames.POPUP_MENU_ACTION_NAME_LIST, cssActionNames); 105 106 settingsMap.put (SettingsNames.ABBREV_MAP, getCSSAbbrevMap()); 108 109 SettingsUtil.updateListSetting (settingsMap, SettingsNames.TOKEN_CONTEXT_LIST, 110 new TokenContext[] { CSSTokenContext.context }); 111 112 } 113 114 } 115 116 118 private Map getCSSAbbrevMap() { 119 Map map = new TreeMap (); 120 121 map.put ("bg", "background: "); map.put ("di", "display: "); map.put ("fs", "font-size: "); 125 return map; 126 } 127 128 129 static class CSSTokenColoringInitializer 130 extends SettingsUtil.TokenColoringInitializer { 131 132 public CSSTokenColoringInitializer() { 133 super(CSSTokenContext.context); 134 } 135 136 public Object getTokenColoring(TokenContextPath tokenContextPath, TokenCategory tokenIDOrCategory, boolean printingSet) { 137 return new Coloring (null, Color.black, null); 138 } 139 140 } 141 142 } 143 | Popular Tags |