KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > javadoc > settings > DocumentationSettings


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.javadoc.settings;
21
22 import java.lang.reflect.Modifier JavaDoc;
23
24 import org.openide.options.SystemOption;
25 import org.openide.util.HelpCtx;
26 import org.openide.util.NbBundle;
27 import org.openide.ServiceType;
28
29 //import org.netbeans.modules.javadoc.comments.AutoCommenter;
30
import org.netbeans.modules.javadoc.search.JavadocSearchType;
31 import org.netbeans.modules.javadoc.*;
32 import org.openide.util.Lookup;
33
34 /** Options for JavaDoc
35 *
36 * @author Petr Hrebejk
37 */

38 public class DocumentationSettings extends SystemOption {
39
40     private static final String JavaDoc PROP_SEARCH_SORT = "idxSearchSort"; //NOI18N
41
private static final String JavaDoc PROP_SEARCH_NO_HTML = "idxSearchNoHtml"; //NOI18N
42
private static final String JavaDoc PROP_SEARCH_SPLIT = "idxSearchSplit"; //NOI18N
43
private static final String JavaDoc PROP_AUTOCOMENT_SPLIT = "autocommentSplit"; //NOI18N
44
private static final String JavaDoc PROP_AUTOCOMENT_MOD_MASK = "autocommentModifierMask"; //NOI18N
45
private static final String JavaDoc PROP_AUTOCOMENT_PACKAGE = "autocommentPackage"; //NOI18N
46
private static final String JavaDoc PROP_AUTOCOMENT_ERR_MASK = "autocommentErrorMask"; //NOI18N
47
private static final String JavaDoc PROP_SEARCH = "searchEngine"; //NOI18N
48
private static final String JavaDoc PROP_FS_SETTING = "fileSystemSettings"; //NOI18N
49

50     static final long serialVersionUID =-574331845406968391L;
51
52     private transient boolean initializing = false;
53
54     /** Constructor for DocumentationSettings */
55     protected void initialize () {
56         super.initialize ();
57         initializing = true;
58         if( getProperty( PROP_SEARCH_SORT ) == null )
59             setIdxSearchSort("A"); //NOI18N
60
if( getProperty( PROP_SEARCH_NO_HTML ) == null )
61             setIdxSearchNoHtml(false);
62         if( getProperty( PROP_SEARCH_SPLIT ) == null )
63             setIdxSearchSplit(50);
64         if( getProperty( PROP_AUTOCOMENT_SPLIT ) == null )
65             setAutocommentSplit(35);
66         if( getProperty( PROP_AUTOCOMENT_MOD_MASK ) == null )
67             setAutocommentModifierMask(Modifier.PROTECTED | Modifier.PUBLIC);
68         if( getProperty( PROP_AUTOCOMENT_PACKAGE ) == null )
69             setAutocommentPackage(false);
70         if( getProperty( PROP_AUTOCOMENT_ERR_MASK ) == null )
71             // XXX temporarily commented to remove dependency on the org.netbeans.modules.javadoc.comments package
72
// setAutocommentErrorMask(AutoCommenter.JDC_OK | AutoCommenter.JDC_ERROR | AutoCommenter.JDC_MISSING);
73
setAutocommentErrorMask(7);
74         initializing = false;
75     }
76
77     public static DocumentationSettings getDefault(){
78         return (DocumentationSettings)DocumentationSettings.findObject(DocumentationSettings.class,true);
79     }
80
81     /** @return human presentable name */
82     public String JavaDoc displayName() {
83         return NbBundle.getBundle(DocumentationSettings.class).getString("CTL_Documentation_settings"); //NOI18N
84
}
85
86     public HelpCtx getHelpCtx () {
87         return new HelpCtx (DocumentationSettings.class);
88     }
89     
90     /** Getter for autocommentModifierMask
91     */

92     public int getAutocommentModifierMask() {
93         return ((Integer JavaDoc)getProperty( PROP_AUTOCOMENT_MOD_MASK )).intValue();
94         //return autocommentModifierMask;
95
}
96
97     /** Setter for autocommentModifierMask
98     */

99     public void setAutocommentModifierMask(int mask) {
100         putProperty( PROP_AUTOCOMENT_MOD_MASK, new Integer JavaDoc(mask), !(initializing || isReadExternal()) );
101         //autocommentModifierMask = mask;
102
}
103
104     /** Getter for autocommentPackage
105     */

106     public boolean getAutocommentPackage() {
107         return ((Boolean JavaDoc)getProperty( PROP_AUTOCOMENT_PACKAGE )).booleanValue();
108         //return autocommentPackage;
109
}
110
111     /** Setter for autocommentPackage
112     */

113     public void setAutocommentPackage(boolean pckg) {
114         putProperty( PROP_AUTOCOMENT_PACKAGE, pckg ? Boolean.TRUE : Boolean.FALSE, !(initializing || isReadExternal()) );
115         //autocommentPackage = pckg;
116
}
117
118
119     /** Getter for autocommentErrorMask
120     */

121     public int getAutocommentErrorMask() {
122         return ((Integer JavaDoc)getProperty( PROP_AUTOCOMENT_ERR_MASK )).intValue();
123         //return autocommentErrorMask;
124
}
125
126     /** Setter for documentation autocommentErrorMask
127     */

128     public void setAutocommentErrorMask(int mask) {
129         putProperty( PROP_AUTOCOMENT_ERR_MASK, new Integer JavaDoc(mask), !(initializing || isReadExternal()) );
130         //autocommentErrorMask = mask;
131
}
132
133     /** Getter for property idxSearchSort.
134      *@return Value of property idxSearchSort.
135      */

136     public String JavaDoc getIdxSearchSort() {
137         return (String JavaDoc)getProperty( PROP_SEARCH_SORT );
138         //return idxSearchSort;
139
}
140
141     /** Setter for property idxSearchSort.
142      *@param idxSearchSort New value of property idxSearchSort.
143      */

144     public void setIdxSearchSort(String JavaDoc idxSearchSort) {
145         putProperty( PROP_SEARCH_SORT , idxSearchSort, !(initializing || isReadExternal()) );
146         //this.idxSearchSort = idxSearchSort;
147
}
148
149     /** Getter for property idxSearchNoHtml.
150      *@return Value of property idxSearchNoHtml.
151      */

152     public boolean isIdxSearchNoHtml() {
153         return ((Boolean JavaDoc)getProperty( PROP_SEARCH_NO_HTML )).booleanValue();
154         //return idxSearchNoHtml;
155
}
156
157     /** Setter for property idxSearchNoHtml.
158      *@param idxSearchNoHtml New value of property idxSearchNoHtml.
159      */

160     public void setIdxSearchNoHtml(boolean idxSearchNoHtml) {
161         putProperty( PROP_SEARCH_NO_HTML, idxSearchNoHtml ? Boolean.TRUE : Boolean.FALSE, !(initializing || isReadExternal()) );
162         //this.idxSearchNoHtml = idxSearchNoHtml;
163
}
164
165     /** Getter for property idxSearchSplit.
166      *@return Value of property idxSearchSplit.
167      */

168     public int getIdxSearchSplit() {
169         return ((Integer JavaDoc)getProperty( PROP_SEARCH_SPLIT )).intValue();
170         //return idxSearchSplit;
171
}
172
173     /** Setter for property idxSearchSplit.
174      *@param idxSearchSplit New value of property idxSearchSplit.
175      */

176     public void setIdxSearchSplit(int idxSearchSplit) {
177         putProperty( PROP_SEARCH_SPLIT , new Integer JavaDoc(idxSearchSplit), !(initializing || isReadExternal()) );
178         //this.idxSearchSplit = idxSearchSplit;
179
}
180
181     /** Getter for property autocommentSplit.
182      * @return Position of the splitter in the autocomment window.
183      */

184     public int getAutocommentSplit() {
185         return ((Integer JavaDoc)getProperty( PROP_AUTOCOMENT_SPLIT )).intValue();
186         //return autocommentSplit;
187
}
188     /** Setter for property autocommentSplit.
189      * @param autocommentSplit Position of the splitter in the autocomment window.
190      */

191     public void setAutocommentSplit(int autocommentSplit) {
192         putProperty( PROP_AUTOCOMENT_SPLIT , new Integer JavaDoc(autocommentSplit), !(initializing || isReadExternal()) );
193         //this.autocommentSplit = autocommentSplit;
194
}
195     
196     /** Getter for property search.
197      * @return Value of property search.
198     */

199     public ServiceType getSearchEngine() {
200         JavadocSearchType.Handle searchType = (JavadocSearchType.Handle)getProperty( PROP_SEARCH );
201         JavadocSearchType type = null;
202         
203         if (searchType != null) {
204             type = (JavadocSearchType)searchType.getServiceType();
205         }
206         if (type == null) {
207             if (isWriteExternal()) {
208                 return null;
209             }
210             type = (JavadocSearchType)Lookup.getDefault().lookup(org.netbeans.modules.javadoc.search.Jdk12SearchType.class);
211             if (type != null)
212                 return type;
213             // find ANY search engine
214
type = (JavadocSearchType)Lookup.getDefault().lookup(JavadocSearchType.class);
215         }
216         return type;
217     }
218     
219     /** Setter for property search.
220      * @param search New value of property search.
221     */

222     public void setSearchEngine(ServiceType search) {
223         if (search == null &&
224             isReadExternal()) {
225             putProperty(PROP_SEARCH, null, false);
226         } else {
227             putProperty( PROP_SEARCH , new JavadocSearchType.Handle( search ), !(initializing || isReadExternal()));
228     }
229     }
230
231     
232     public java.util.HashMap JavaDoc getFileSystemSettings(){
233         java.util.HashMap JavaDoc map = (java.util.HashMap JavaDoc)getProperty( PROP_FS_SETTING );
234                 
235         if (map == null) {
236             if (isWriteExternal()) {
237                 return null;
238             }
239             return new java.util.HashMap JavaDoc();
240     }
241         return map;
242     }
243
244     public void setFileSystemSettings(java.util.HashMap JavaDoc map){
245         if (map == null &&
246             isReadExternal()) {
247             putProperty( PROP_FS_SETTING, null, false);
248         } else {
249             java.util.HashMap JavaDoc old = (java.util.HashMap JavaDoc)putProperty( PROP_FS_SETTING , map, !(initializing || isReadExternal()));
250             if( old != null && old.equals(map) )
251                 firePropertyChange(PROP_FS_SETTING, null, null);
252     }
253     }
254     
255 }
256
Popular Tags