1 19 20 package org.netbeans.modules.html.editor.options; 21 22 import java.util.MissingResourceException ; 23 import org.netbeans.editor.SettingsNames; 24 import org.netbeans.editor.ext.ExtSettingsNames; 25 import org.netbeans.editor.ext.html.HTMLSettingsNames; 26 import org.netbeans.modules.editor.html.HTMLKit; 27 import org.netbeans.modules.editor.html.HTMLIndentEngine; 28 import org.netbeans.modules.editor.options.OptionSupport; 29 import org.openide.util.HelpCtx; 30 import org.netbeans.modules.editor.NbEditorUtilities; 31 import org.netbeans.modules.editor.options.BaseOptions; 32 import org.openide.util.NbBundle; 33 import java.awt.Color ; 34 import java.awt.Dimension ; 35 36 42 public class HTMLOptions extends BaseOptions { 43 44 public static final String HTML = "html"; 46 public static final String COMPLETION_AUTO_POPUP_PROP = "completionAutoPopup"; 48 public static final String COMPLETION_AUTO_POPUP_DELAY_PROP = "completionAutoPopupDelay"; 50 public static final String COMPLETION_INSTANT_SUBSTITUTION_PROP = "completionInstantSubstitution"; 52 public static final String COMPLETION_LOWER_CASE_PROP = "completionLowerCase"; 54 private static final String HELP_ID = "editing.editor.html"; 56 public static final String JAVADOC_AUTO_POPUP_PROP = "javaDocAutoPopup"; 58 public static final String JAVADOC_BGCOLOR = "javaDocBGColor"; 60 public static final String JAVADOC_PREFERRED_SIZE_PROP = "javaDocPreferredSize"; 62 public static final String CODE_FOLDING_UPDATE_TIMEOUT_PROP = "codeFoldingUpdateInterval"; 65 public static final String CODE_FOLDING_ENABLE_PROP = "codeFoldingEnable"; 67 static final String [] HTML_PROP_NAMES = OptionSupport.mergeStringArrays(BaseOptions.BASE_PROP_NAMES, new String [] { 68 COMPLETION_AUTO_POPUP_PROP, 69 COMPLETION_AUTO_POPUP_DELAY_PROP, 70 COMPLETION_INSTANT_SUBSTITUTION_PROP, 71 COMPLETION_LOWER_CASE_PROP, 72 JAVADOC_AUTO_POPUP_PROP, 73 JAVADOC_PREFERRED_SIZE_PROP, 74 JAVADOC_BGCOLOR, 75 CODE_FOLDING_UPDATE_TIMEOUT_PROP, 76 CODE_FOLDING_ENABLE_PROP 77 }); 78 79 80 static final long serialVersionUID = 75289734362748537L; 81 82 public HTMLOptions() { 83 super(HTMLKit.class, HTML); 84 } 85 86 public boolean getCompletionAutoPopup() { 87 return getSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP); 88 } 89 90 public void setCompletionAutoPopup(boolean v) { 91 setSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP, v, COMPLETION_AUTO_POPUP_PROP); 92 } 93 94 public int getCompletionAutoPopupDelay() { 95 return getSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY); 96 } 97 98 public void setCompletionAutoPopupDelay(int delay) { 99 if (delay < 0) { 100 NbEditorUtilities.invalidArgument("MSG_NegativeValue"); return; 102 } 103 setSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY, delay, 104 COMPLETION_AUTO_POPUP_DELAY_PROP); 105 } 106 107 public boolean getCompletionInstantSubstitution() { 108 return getSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION); 109 } 110 public void setCompletionInstantSubstitution(boolean v) { 111 setSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION, v, 112 COMPLETION_INSTANT_SUBSTITUTION_PROP); 113 } 114 115 public boolean getCompletionLowerCase() { 116 return getSettingBoolean(HTMLSettingsNames.COMPLETION_LOWER_CASE); 117 } 118 public void setCompletionLowerCase(boolean v) { 119 setSettingBoolean(HTMLSettingsNames.COMPLETION_LOWER_CASE, v, 120 COMPLETION_LOWER_CASE_PROP); 121 } 122 123 protected Class getDefaultIndentEngineClass() { 124 return HTMLIndentEngine.class; 125 } 126 127 public HelpCtx getHelpCtx () { 128 return new HelpCtx (HELP_ID); 129 } 130 131 public boolean getJavaDocAutoPopup() { 132 return getSettingBoolean(ExtSettingsNames.JAVADOC_AUTO_POPUP); 133 } 134 135 public void setJavaDocAutoPopup(boolean auto) { 136 setSettingBoolean(ExtSettingsNames.JAVADOC_AUTO_POPUP, auto, 137 JAVADOC_AUTO_POPUP_PROP); 138 } 139 140 public Color getJavaDocBGColor() { 141 return (Color )getSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR); 142 } 143 public void setJavaDocBGColor(Color c) { 144 setSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR, c, 145 JAVADOC_BGCOLOR); 146 } 147 148 public Dimension getJavaDocPreferredSize() { 149 return (Dimension )getSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE); 150 } 151 public void setJavaDocPreferredSize(Dimension d) { 152 setSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE, d, 153 JAVADOC_PREFERRED_SIZE_PROP); 154 } 155 156 157 public int getCodeFoldingUpdateInterval() { 158 return getSettingInteger(HTMLSettingsNames.CODE_FOLDING_UPDATE_TIMEOUT); 159 } 160 161 public void setCodeFoldingUpdateInterval(int timeout) { 162 if (timeout < 0) { 163 NbEditorUtilities.invalidArgument("MSG_NegativeValue"); return; 165 } 166 setSettingInteger(HTMLSettingsNames.CODE_FOLDING_UPDATE_TIMEOUT, timeout, CODE_FOLDING_UPDATE_TIMEOUT_PROP); 167 } 168 169 public boolean getCodeFoldingEnable() { 170 return getSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE); 171 } 172 173 public void setCodeFoldingEnable(boolean state) { 174 setSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE, state, CODE_FOLDING_ENABLE_PROP); 175 } 176 177 180 protected String getString(String key) { 181 try { 182 return NbBundle.getMessage(HTMLOptions.class, key); 183 } catch (MissingResourceException e) { 184 return super.getString(key); 185 } 186 } 187 188 } 189 | Popular Tags |