KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > settings > storage > api > EditorSettings


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.editor.settings.storage.api;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.lang.ref.WeakReference JavaDoc;
24 import java.util.Collection JavaDoc;
25 import java.util.Map JavaDoc;
26 import java.util.Set JavaDoc;
27 import javax.swing.text.AttributeSet JavaDoc;
28 import org.netbeans.modules.editor.settings.storage.EditorSettingsImpl;
29
30
31 /**
32  * This singleton class contains access methods for editor settings like
33  * font & colors profiles and keymaps.
34  *
35  * @author Jan Jancura
36  */

37 public abstract class EditorSettings {
38
39     /**
40      * Returns default instance of EditorSettings.
41      *
42      * @return default instance of EditorSettings
43      */

44     public static EditorSettings getDefault () {
45         return EditorSettingsImpl.getInstance();
46     }
47
48     /**
49      * Gets all top level mime types registered under the <code>Editors/</code>
50      * folder.
51      *
52      * @return set of mimetypes
53      * @since 1.9
54      */

55     public abstract Set JavaDoc<String JavaDoc> getAllMimeTypes ();
56     
57     /**
58      * Returns set of mimetypes. The set contains only mime types that have
59      * <code>coloring.xml</code> defined in the default profile.
60      *
61      * @return set of mimetypes
62      */

63     public abstract Set JavaDoc<String JavaDoc> getMimeTypes ();
64     
65     /**
66      * Returns name of language for given mime type.
67      *
68      * @return name of language for given mime type
69      */

70     public abstract String JavaDoc getLanguageName (String JavaDoc mimeType);
71
72     
73     // FontColors ..............................................................
74

75     /** Property name constant. */
76     public static final String JavaDoc PROP_CURRENT_FONT_COLOR_PROFILE = "currentFontColorProfile";
77     
78     /**
79      * The name of the property change event for 'All Languages' font and colors.
80      *
81      * @deprecated This has always been meant for internal use only. As per
82      * general contract clients should listen on mime type specific Lookup for
83      * changes in editor settings.
84      */

85     public static final String JavaDoc PROP_DEFAULT_FONT_COLORS = "defaultFontColors"; //NOI18N
86

87     /**
88      * The name of the property change event for 'Highlighting' font and colors.
89      *
90      * @deprecated This has always been meant for internal use only. As per
91      * general contract clients should listen on mime type specific Lookup for
92      * changes in editor settings.
93      */

94     public static final String JavaDoc PROP_EDITOR_FONT_COLORS = EditorSettingsImpl.PROP_EDITOR_FONT_COLORS;
95
96
97     /**
98      * Returns set of font & colors profiles.
99      *
100      * @return set of font & colors profiles
101      */

102     public abstract Set JavaDoc<String JavaDoc> getFontColorProfiles ();
103     
104     /**
105      * Returns true for user defined profile.
106      *
107      * @param profile a profile name
108      * @return true for user defined profile
109      */

110     public abstract boolean isCustomFontColorProfile (String JavaDoc profile);
111     
112     /**
113      * Returns name of current font & colors profile.
114      *
115      * @return name of current font & colors profile
116      */

117     public abstract String JavaDoc getCurrentFontColorProfile ();
118     
119     /**
120      * Sets current font & colors profile.
121      *
122      * @param profile a profile name
123      */

124     public abstract void setCurrentFontColorProfile (String JavaDoc profile);
125     
126     /**
127      * Returns font & color defaults for given profile or null, if the profile
128      * is unknown .
129      *
130      * @param profile a profile name
131      * @return font & color defaults for given profile or null
132      *
133      * @deprecated Use getFontColorSettings(new String[0]).getAllFontColors(profile) instead.
134      */

135     public abstract Collection JavaDoc<AttributeSet JavaDoc> getDefaultFontColors (
136     String JavaDoc profile
137     );
138     
139     /**
140      * Returns default values for font & color defaults for given profile
141      * or null, if the profile is unknown.
142      *
143      * @param profile a profile name
144      * @return font & color defaults for given profile or null
145      *
146      * @deprecated Use getFontColorSettings(new String[0]).getAllFontColorsDefaults(profile) instead.
147      */

148     public abstract Collection JavaDoc<AttributeSet JavaDoc> getDefaultFontColorDefaults (
149     String JavaDoc profile
150     );
151     
152     /**
153      * Sets font & color defaults for given profile.
154      *
155      * @param profile a profile name
156      * @param fontColors font & color defaults to be used
157      *
158      * @deprecated Use getFontColorSettings(new String[0]).setAllFontColors(profile, fontColors) instead.
159      */

160     public abstract void setDefaultFontColors (
161     String JavaDoc profile,
162     Collection JavaDoc<AttributeSet JavaDoc> fontColors
163     );
164     
165     /**
166      * Returns highlighting properties for given profile or null, if the
167      * profile is not known.
168      *
169      * @param profile a profile name
170      * @return highlighting properties for given profile or null
171      */

172     public abstract Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> getHighlightings (
173     String JavaDoc profile
174     );
175     
176     /**
177      * Returns defaults for highlighting properties for given profile,
178      * or null if the profile is not known.
179      *
180      * @param profile a profile name
181      * @return highlighting properties for given profile or null
182      */

183     public abstract Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> getHighlightingDefaults (
184     String JavaDoc profile
185     );
186     
187     /**
188      * Sets highlighting properties for given profile.
189      *
190      * @param profile a profile name
191      * @param highlightings a highlighting properties to be used
192      */

193     public abstract void setHighlightings (
194     String JavaDoc profile,
195     Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> highlightings
196     );
197     
198     /**
199      * Returns FontColorSettings for given mimetypes.
200      *
201      * @return FontColorSettings for given mimetypes
202      */

203     public abstract FontColorSettingsFactory getFontColorSettings (String JavaDoc[] mimeTypes);
204     
205     
206     // KeyMaps .................................................................
207

208     /** Property name constant. */
209     public static final String JavaDoc PROP_CURRENT_KEY_MAP_PROFILE = "currentKeyMapProfile";
210
211     
212     /**
213      * Returns KeyBindingSettings for given mimetypes.
214      *
215      * @return KeyBindingSettings for given mimetypes
216      */

217     public abstract KeyBindingSettingsFactory getKeyBindingSettings (String JavaDoc[] mimeTypes);
218     
219     /**
220      * Returns set of keymap profiles.
221      *
222      * @return set of font & colors profiles
223      */

224     public abstract Set JavaDoc<String JavaDoc> getKeyMapProfiles ();
225     
226     /**
227      * Returns true for user defined profile.
228      *
229      * @param profile a profile name
230      * @return true for user defined profile
231      */

232     public abstract boolean isCustomKeymapProfile (String JavaDoc profile);
233     
234     /**
235      * Returns name of current keymap profile.
236      *
237      * @return name of current keymap profile
238      */

239     public abstract String JavaDoc getCurrentKeyMapProfile ();
240     
241     /**
242      * Sets current keymap profile.
243      *
244      * @param profile a profile name
245      */

246     public abstract void setCurrentKeyMapProfile (String JavaDoc profile);
247
248     /**
249      * PropertyChangeListener registration.
250      *
251      * @param l a PropertyChangeListener to be registerred
252      */

253     public abstract void addPropertyChangeListener (
254         PropertyChangeListener JavaDoc l
255     );
256     
257     /**
258      * PropertyChangeListener registration.
259      *
260      * @param l a PropertyChangeListener to be unregisterred
261      */

262     public abstract void removePropertyChangeListener (
263         PropertyChangeListener JavaDoc l
264     );
265     
266     /**
267      * PropertyChangeListener registration.
268      *
269      * @param propertyName The name of the property to listen on.
270      * @param l a PropertyChangeListener to be registerred
271      */

272     public abstract void addPropertyChangeListener (
273         String JavaDoc propertyName,
274         PropertyChangeListener JavaDoc l
275     );
276     
277     /**
278      * PropertyChangeListener registration.
279      *
280      * @param propertyName The name of the property to listen on.
281      * @param l a PropertyChangeListener to be unregisterred
282      */

283     public abstract void removePropertyChangeListener (
284         String JavaDoc propertyName,
285         PropertyChangeListener JavaDoc l
286     );
287 }
288
Popular Tags