KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > html > editor > options > HTMLOptions


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.html.editor.options;
21
22 import java.util.MissingResourceException JavaDoc;
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 JavaDoc;
34 import java.awt.Dimension JavaDoc;
35
36 /**
37 * Options for the java editor kit
38 *
39 * @author Miloslav Metelka
40 * @version 1.00
41 */

42 public class HTMLOptions extends BaseOptions {
43
44     public static final String JavaDoc HTML = "html"; // NOI18N
45

46     public static final String JavaDoc COMPLETION_AUTO_POPUP_PROP = "completionAutoPopup"; // NOI18N
47

48     public static final String JavaDoc COMPLETION_AUTO_POPUP_DELAY_PROP = "completionAutoPopupDelay"; // NOI18N
49

50     public static final String JavaDoc COMPLETION_INSTANT_SUBSTITUTION_PROP = "completionInstantSubstitution"; // NOI18N
51

52     public static final String JavaDoc COMPLETION_LOWER_CASE_PROP = "completionLowerCase"; // NOI18N
53

54     private static final String JavaDoc HELP_ID = "editing.editor.html"; // !!! NOI18N
55

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

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

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

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

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

67     static final String JavaDoc[] HTML_PROP_NAMES = OptionSupport.mergeStringArrays(BaseOptions.BASE_PROP_NAMES, new String JavaDoc[] {
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"); // NOI18N
101
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 JavaDoc 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 JavaDoc getJavaDocBGColor() {
141         return (Color JavaDoc)getSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR);
142     }
143     public void setJavaDocBGColor(Color JavaDoc c) {
144         setSettingValue(ExtSettingsNames.JAVADOC_BG_COLOR, c,
145             JAVADOC_BGCOLOR);
146     }
147     
148     public Dimension JavaDoc getJavaDocPreferredSize() {
149         return (Dimension JavaDoc)getSettingValue(ExtSettingsNames.JAVADOC_PREFERRED_SIZE);
150     }
151     public void setJavaDocPreferredSize(Dimension JavaDoc 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"); // NOI18N
164
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     /**
178      * Get localized string
179      */

180     protected String JavaDoc getString(String JavaDoc key) {
181         try {
182             return NbBundle.getMessage(HTMLOptions.class, key);
183         } catch (MissingResourceException JavaDoc e) {
184             return super.getString(key);
185         }
186     }
187
188 }
189
Popular Tags