1 19 20 package org.netbeans.modules.web.core.syntax.settings; 21 22 import org.netbeans.modules.web.core.syntax.settings.JspSettings; 23 import org.netbeans.modules.web.core.syntax.*; 24 import java.util.Iterator ; 25 import java.util.Set ; 26 import org.netbeans.modules.editor.NbEditorUtilities; 27 import org.openide.util.NbBundle; 28 import org.openide.util.HelpCtx; 29 import org.netbeans.editor.ext.ExtSettingsNames; 30 import org.openide.text.IndentEngine; 31 import org.openide.util.Lookup; 32 import java.awt.Color ; 33 import java.awt.Dimension ; 34 import org.netbeans.editor.SettingsNames; 35 import org.netbeans.modules.editor.options.BaseOptions; 36 import org.netbeans.modules.editor.options.OptionSupport; 37 38 43 public class JSPOptions extends BaseOptions { 44 static final long serialVersionUID = 1954408023433388323L; 45 46 47 private static final String HELP_ID = "editing.editor.jsp"; 49 public static final String JSP = "jsp"; 51 public static final String COMPLETION_AUTO_POPUP_PROP = "completionAutoPopup"; 53 public static final String COMPLETION_AUTO_POPUP_DELAY_PROP = "completionAutoPopupDelay"; 55 public static final String JAVADOC_AUTO_POPUP_PROP = "javaDocAutoPopup"; 57 public static final String JAVADOC_BGCOLOR = "javaDocBGColor"; 59 public static final String JAVADOC_PREFERRED_SIZE_PROP = "javaDocPreferredSize"; 61 public static final String CODE_FOLDING_UPDATE_TIMEOUT_PROP = "codeFoldingUpdateInterval"; 64 public static final String CODE_FOLDING_ENABLE_PROP = "codeFoldingEnable"; 66 public static final String COMPLETION_INSTANT_SUBSTITUTION_PROP = "completionInstantSubstitution"; 68 static final String [] JSP_PROP_NAMES = OptionSupport.mergeStringArrays( 69 BaseOptions.BASE_PROP_NAMES, 70 new String [] { 71 COMPLETION_AUTO_POPUP_PROP, 72 COMPLETION_AUTO_POPUP_DELAY_PROP, 73 COMPLETION_INSTANT_SUBSTITUTION_PROP, 74 JAVADOC_AUTO_POPUP_PROP, 75 JAVADOC_PREFERRED_SIZE_PROP, 76 JAVADOC_BGCOLOR, 77 CODE_FOLDING_UPDATE_TIMEOUT_PROP, 78 CODE_FOLDING_ENABLE_PROP 79 }); 80 public JSPOptions() { 81 super (JSPKit.class, JSP); 82 } 83 84 85 protected String getString(String s) { 86 try { 87 String res = NbBundle.getBundle(JSPKit.class).getString(s); 88 return (res == null) ? super.getString(s) : res; 89 } 90 catch (Exception e) { 91 return super.getString(s); 92 } 93 } 94 95 public boolean getJavaDocAutoPopup() { 96 return getSettingBoolean(ExtSettingsNames.JAVADOC_AUTO_POPUP); 97 } 98 99 public void setJavaDocAutoPopup(boolean auto) { 100 setSettingBoolean(ExtSettingsNames.JAVADOC_AUTO_POPUP, auto, 101 JAVADOC_AUTO_POPUP_PROP); 102 } 103 104 public boolean getCompletionAutoPopup() { 105 return getSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP); 106 } 107 108 public void setCompletionAutoPopup(boolean v) { 109 setSettingBoolean(ExtSettingsNames.COMPLETION_AUTO_POPUP, v, 110 COMPLETION_AUTO_POPUP_PROP); 111 } 112 113 public int getCompletionAutoPopupDelay() { 114 return getSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY); 115 } 116 public void setCompletionAutoPopupDelay(int delay) { 117 setSettingInteger(ExtSettingsNames.COMPLETION_AUTO_POPUP_DELAY, delay, 118 COMPLETION_AUTO_POPUP_DELAY_PROP); 119 } 120 121 public Color getJavaDocBGColor() { 122 return (Color )getSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR); 123 } 124 public void setJavaDocBGColor(Color c) { 125 setSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR, c, 126 JAVADOC_BGCOLOR); 127 } 128 129 public Dimension getJavaDocPreferredSize() { 130 return (Dimension )getSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE); 131 } 132 public void setJavaDocPreferredSize(Dimension d) { 133 setSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE, d, 134 JAVADOC_PREFERRED_SIZE_PROP); 135 } 136 137 protected Class getDefaultIndentEngineClass() { 138 Class engineClass = null; 139 140 Lookup.Template tmp = new Lookup.Template(IndentEngine.class); 141 Lookup.Result res = Lookup.getDefault().lookup(tmp); 142 Set allClasses = res.allClasses(); 143 for (Iterator it = allClasses.iterator(); it.hasNext();) { 144 Class cls = (Class )it.next(); 145 if (cls.getName().equals(org.netbeans.modules.web.core.syntax.formatting.JspIndentEngine.class.getName())) { engineClass = cls; 147 break; 148 } 149 } 150 151 return (engineClass != null) ? engineClass : super.getDefaultIndentEngineClass(); 152 } 153 154 public HelpCtx getHelpCtx() { 155 return new HelpCtx (HELP_ID); 156 } 157 158 public int getCodeFoldingUpdateInterval() { 159 return getSettingInteger(JspSettings.CODE_FOLDING_UPDATE_TIMEOUT); 160 } 161 162 public void setCodeFoldingUpdateInterval(int timeout) { 163 if (timeout < 0) { 164 NbEditorUtilities.invalidArgument("MSG_NegativeValue"); return; 166 } 167 setSettingInteger(JspSettings.CODE_FOLDING_UPDATE_TIMEOUT, timeout, CODE_FOLDING_UPDATE_TIMEOUT_PROP); 168 } 169 170 public boolean getCodeFoldingEnable() { 171 return getSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE); 172 } 173 174 public void setCodeFoldingEnable(boolean state) { 175 setSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE, state, CODE_FOLDING_ENABLE_PROP); 176 } 177 178 public boolean getCompletionInstantSubstitution() { 179 return getSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION); 180 } 181 public void setCompletionInstantSubstitution(boolean v) { 182 setSettingBoolean(ExtSettingsNames.COMPLETION_INSTANT_SUBSTITUTION, v, 183 COMPLETION_INSTANT_SUBSTITUTION_PROP); 184 } 185 186 } 187 | Popular Tags |