KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > languages > dataobject > LanguagesOptions


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.languages.dataobject;
21
22 import org.netbeans.editor.SettingsNames;
23 import org.netbeans.modules.editor.options.BaseOptions;
24 import org.netbeans.modules.editor.options.OptionSupport;
25 import org.netbeans.modules.languages.dataobject.LanguagesEditorKit;
26 import org.openide.util.HelpCtx;
27 import org.openide.util.NbBundle;
28 import java.util.MissingResourceException JavaDoc;
29 import org.openide.filesystems.FileObject;
30
31 /**
32  *
33  * @author Administrator
34  */

35 public class LanguagesOptions extends BaseOptions {
36     
37     public static String JavaDoc LANGUAGES = "Languages"; // NOI18N
38

39     public static final String JavaDoc CODE_FOLDING_ENABLE_PROP = "codeFoldingEnable"; //NOI18N
40

41     private static LanguagesOptions defaultInstance;
42     
43     static final String JavaDoc[] LANGUAGES_PROP_NAMES = OptionSupport.mergeStringArrays (
44         BaseOptions.BASE_PROP_NAMES,
45         new String JavaDoc[] {
46             CODE_FOLDING_ENABLE_PROP
47         }
48     );
49     
50     public static final LanguagesOptions create(FileObject fo) {
51         if (defaultInstance == null) {
52             String JavaDoc mimeType = fo.getParent().getPath().substring(8); //'Editors/'
53
// System.out.println("@@@ LanguagesOptions.create from " + fo.getPath() + " mimeType = '" + mimeType + "'");
54
defaultInstance = new LanguagesOptions(mimeType);
55         }
56         return defaultInstance;
57     }
58     
59     /** Name of property. */
60     private static final String JavaDoc HELP_ID = "editing.editor.php"; // NOI18N
61

62
63     private String JavaDoc mimeType;
64     
65     public LanguagesOptions(String JavaDoc mimeType) {
66         super(LanguagesEditorKit.class, LANGUAGES);
67         this.mimeType = mimeType;
68 // S ystem.out.println(this + " : " + getClass ().getClassLoader ());
69
// T hread.dumpStack();
70
}
71     
72     protected String JavaDoc getContentType() {
73         return mimeType;
74     }
75     
76     public boolean getCodeFoldingEnable() {
77         return getSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE);
78     }
79     
80     public void setCodeFoldingEnable(boolean state) {
81         setSettingBoolean(SettingsNames.CODE_FOLDING_ENABLE, state, CODE_FOLDING_ENABLE_PROP);
82     }
83     
84     /**
85      * Determines the class of the default indentation engine, in this case
86      * LanguagesIndentEngine.class
87      */

88 // protected Class getDefaultIndentEngineClass() {
89
// return LanguagesIndentEngine.class;
90
// }
91

92     /**
93      * Gets the help ID
94      */

95     public HelpCtx getHelpCtx() {
96         return new HelpCtx(HELP_ID);
97     }
98     
99     /**
100      * Look up a resource bundle message, if it is not found locally defer to
101      * the super implementation
102      */

103     protected String JavaDoc getString(String JavaDoc key) {
104         try {
105             return NbBundle.getMessage(LanguagesOptions.class, key);
106         } catch (MissingResourceException JavaDoc e) {
107             return super.getString(key);
108         }
109     }
110     
111 }
Popular Tags