KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > core > syntax > settings > JSPOptions


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

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 JavaDoc;
25 import java.util.Set JavaDoc;
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 JavaDoc;
33 import java.awt.Dimension JavaDoc;
34 import org.netbeans.editor.SettingsNames;
35 import org.netbeans.modules.editor.options.BaseOptions;
36 import org.netbeans.modules.editor.options.OptionSupport;
37
38 /**
39  * Options for the java editor kit
40  *
41  * @author Petr Jiricka, Libor Kramolis
42  */

43 public class JSPOptions extends BaseOptions {
44     static final long serialVersionUID = 1954408023433388323L;
45   
46     /** help context ID */
47     private static final String JavaDoc HELP_ID = "editing.editor.jsp"; // NOI18N
48

49     public static final String JavaDoc JSP = "jsp"; // NOI18N
50

51     public static final String JavaDoc COMPLETION_AUTO_POPUP_PROP = "completionAutoPopup"; // NOI18N
52

53     public static final String JavaDoc COMPLETION_AUTO_POPUP_DELAY_PROP = "completionAutoPopupDelay"; // NOI18N
54

55     public static final String JavaDoc JAVADOC_AUTO_POPUP_PROP = "javaDocAutoPopup"; //NOI18N
56

57     public static final String JavaDoc JAVADOC_BGCOLOR = "javaDocBGColor"; // NOI18N
58

59     public static final String JavaDoc JAVADOC_PREFERRED_SIZE_PROP = "javaDocPreferredSize"; //NOI18N
60

61     //code folding properties
62
public static final String JavaDoc CODE_FOLDING_UPDATE_TIMEOUT_PROP = "codeFoldingUpdateInterval"; //NOI18N
63

64     public static final String JavaDoc CODE_FOLDING_ENABLE_PROP = "codeFoldingEnable"; //NOI18N
65

66     public static final String JavaDoc COMPLETION_INSTANT_SUBSTITUTION_PROP = "completionInstantSubstitution"; // NOI18N
67

68     static final String JavaDoc[] JSP_PROP_NAMES = OptionSupport.mergeStringArrays(
69                                             BaseOptions.BASE_PROP_NAMES,
70                                             new String JavaDoc[] {
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     /** @return localized string */
85     protected String JavaDoc getString(String JavaDoc s) {
86         try {
87             String JavaDoc res = NbBundle.getBundle(JSPKit.class).getString(s);
88             return (res == null) ? super.getString(s) : res;
89         }
90         catch (Exception JavaDoc 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 JavaDoc getJavaDocBGColor() {
122         return (Color JavaDoc)getSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR);
123     }
124     public void setJavaDocBGColor(Color JavaDoc c) {
125         setSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR, c,
126             JAVADOC_BGCOLOR);
127     }
128     
129     public Dimension JavaDoc getJavaDocPreferredSize() {
130         return (Dimension JavaDoc)getSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE);
131     }
132     public void setJavaDocPreferredSize(Dimension JavaDoc d) {
133         setSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE, d,
134             JAVADOC_PREFERRED_SIZE_PROP);
135     }
136     
137     protected Class JavaDoc getDefaultIndentEngineClass() {
138     Class JavaDoc engineClass = null;
139     
140     Lookup.Template tmp = new Lookup.Template(IndentEngine.class);
141         Lookup.Result res = Lookup.getDefault().lookup(tmp);
142         Set JavaDoc allClasses = res.allClasses();
143         for (Iterator JavaDoc it = allClasses.iterator(); it.hasNext();) {
144             Class JavaDoc cls = (Class JavaDoc)it.next();
145             if (cls.getName().equals(org.netbeans.modules.web.core.syntax.formatting.JspIndentEngine.class.getName())) { //NOI18N
146
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"); // NOI18N
165
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