1 19 package org.netbeans.modules.xml.text.syntax; 20 21 import java.util.*; 22 import org.netbeans.editor.ext.ExtSettingsNames; 23 import org.netbeans.modules.editor.NbEditorUtilities; 24 import org.netbeans.modules.xml.text.indent.XMLIndentEngine; 25 import org.netbeans.modules.xml.text.api.XMLDefaultTokenContext; 26 27 28 34 public class XMLOptions extends AbstractBaseOptions { 35 36 private static final long serialVersionUID = 2347735706857337892L; 37 38 public static final String COMPLETION_AUTO_POPUP_PROP = "completionAutoPopup"; 40 public static final String COMPLETION_AUTO_POPUP_DELAY_PROP = "completionAutoPopupDelay"; 42 public static final String COMPLETION_INSTANT_SUBSTITUTION_PROP = "completionInstantSubstitution"; 44 static final String [] XML_PROP_NAMES = new String [] { 45 COMPLETION_AUTO_POPUP_PROP, 46 COMPLETION_AUTO_POPUP_DELAY_PROP, 47 COMPLETION_INSTANT_SUBSTITUTION_PROP, 48 }; 49 50 54 55 public XMLOptions () { 56 super (XMLKit.class, "xml"); } 58 59 protected Class getDefaultIndentEngineClass () { 60 return XMLIndentEngine.class; 61 } 62 63 public boolean getCompletionAutoPopup() { 64 return getSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP); 65 } 66 67 public void setCompletionAutoPopup(boolean v) { 68 setSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP, v, COMPLETION_AUTO_POPUP_PROP); 69 } 70 71 public int getCompletionAutoPopupDelay() { 72 return getSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY); 73 } 74 75 public void setCompletionAutoPopupDelay(int delay) { 76 if (delay < 0) { 77 NbEditorUtilities.invalidArgument("MSG_NegativeValue"); return; 79 } 80 setSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY, delay, 81 COMPLETION_AUTO_POPUP_DELAY_PROP); 82 } 83 84 public boolean getCompletionInstantSubstitution() { 85 return getSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION); 86 } 87 88 public void setCompletionInstantSubstitution(boolean v) { 89 setSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION, v, 90 COMPLETION_INSTANT_SUBSTITUTION_PROP); 91 } 92 93 private static final String [][] TRANSLATE_COLORS = { 96 { "xml-string", "xml-value" }, 99 { "xml-symbol", "xml-operator" }, 101 { "xml-keyword", "xml-doctype" }, 103 { "xml-plain", "xml-text"}, 104 }; 105 106 110 public Map getColoringMap() { 111 Map colors = super.getColoringMap(); 112 113 synchronized (this) { 114 118 for (int i = 0; i<TRANSLATE_COLORS.length; i++) { 119 String oldKey = TRANSLATE_COLORS[i][0]; 120 Object color = colors.get(oldKey); 121 if (color != null) { 122 colors.remove(oldKey); 123 String newKey = TRANSLATE_COLORS[i][1]; 124 colors.put(newKey, color); 125 } 126 } 127 128 131 return colors; 132 } 133 } 134 } 135 | Popular Tags |