KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > settings > storage > EditorSettingsImpl


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;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.util.Collection JavaDoc;
26 import java.util.Collections JavaDoc;
27 import java.util.Enumeration JavaDoc;
28 import java.util.HashMap JavaDoc;
29 import java.util.HashSet JavaDoc;
30 import java.util.Map JavaDoc;
31 import java.util.Set JavaDoc;
32 import java.util.logging.Level JavaDoc;
33 import java.util.logging.Logger JavaDoc;
34 import javax.swing.text.AttributeSet JavaDoc;
35 import org.netbeans.api.editor.mimelookup.MimePath;
36 import org.netbeans.modules.editor.settings.storage.api.EditorSettings;
37 import org.netbeans.modules.editor.settings.storage.api.FontColorSettingsFactory;
38 import org.netbeans.modules.editor.settings.storage.api.KeyBindingSettingsFactory;
39 import org.openide.filesystems.FileObject;
40 import org.openide.filesystems.FileSystem;
41 import org.openide.filesystems.Repository;
42
43 /**
44  * This class contains access methods for editor settings like font & colors
45  * profiles and keymap profiles.
46  *
47  * @author Jan Jancura
48  */

49 public class EditorSettingsImpl extends EditorSettings {
50
51     private static final Logger JavaDoc LOG = Logger.getLogger(EditorSettingsImpl.class.getName());
52     
53     private final PropertyChangeSupport JavaDoc pcs = new PropertyChangeSupport JavaDoc(this);
54
55     /** The name of the property change event for 'Highlighting' font and colors. */
56     public static final String JavaDoc PROP_HIGHLIGHT_COLORINGS = "editorFontColors"; //NOI18N
57

58     /** The name of the property change event for 'Token' font and colors. */
59     public static final String JavaDoc PROP_TOKEN_COLORINGS = "fontColors"; //NOI18N
60

61         
62     /** The name of the default profile. */
63     public static final String JavaDoc DEFAULT_PROFILE = "NetBeans"; //NOI18N
64

65     // XXX: rewrite this using NbPreferences
66
private static final String JavaDoc FATTR_CURRENT_FONT_COLOR_PROFILE = "currentFontColorProfile"; // NOI18N
67
private static final String JavaDoc FATTR_CURRENT_KEYMAP_PROFILE = "currentKeymap"; // NOI18N
68

69     /** Storage folder for the current font & color profile attribute. */
70     private static final String JavaDoc EDITORS_FOLDER = "Editors"; //NOI18N
71
/** Storage folder for the current keybindings profile attribute. */
72     private static final String JavaDoc KEYMAPS_FOLDER = "Keymaps"; // NOI18N
73

74     private static EditorSettingsImpl instance = null;
75     
76     public static synchronized EditorSettingsImpl getInstance() {
77         if (instance == null) {
78             instance = new EditorSettingsImpl();
79         }
80         return instance;
81     }
82
83     public Set JavaDoc<String JavaDoc> getAllMimeTypes () {
84         FileObject editorsFo = Repository.getDefault().getDefaultFileSystem().findResource(EDITORS_FOLDER);
85         HashSet JavaDoc<String JavaDoc> mimeTypes = new HashSet JavaDoc<String JavaDoc>();
86         
87         if (editorsFo != null) {
88             for(FileObject f : editorsFo.getChildren()) {
89                 if (!f.isFolder()) {
90                     continue;
91                 }
92
93                 String JavaDoc firstPart = f.getNameExt();
94                 for(FileObject ff : f.getChildren()) {
95                     if (!ff.isFolder()) {
96                         continue;
97                     }
98
99                     String JavaDoc mimeType = firstPart + "/" + ff.getNameExt(); //NOI18N
100
mimeTypes.add(mimeType);
101                 }
102             }
103         }
104         
105         return mimeTypes;
106     }
107     
108     /**
109      * Returns set of mimetypes.
110      *
111      * @return set of mimetypes
112      */

113     public Set JavaDoc<String JavaDoc> getMimeTypes () {
114     if (mimeTypesWithColoring == null) {
115             init ();
116         }
117     return mimeTypesWithColoring;
118     }
119     
120     /**
121      * Returns name of language for given mime type.
122      *
123      * @return name of language for given mime type
124      */

125     public String JavaDoc getLanguageName (String JavaDoc mimeType) {
126         FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource("Editors/" + mimeType); //NOI18N
127
return fo == null ? mimeType : Utils.getLocalizedName(fo, mimeType, mimeType);
128     }
129
130     
131     // FontColors ..............................................................
132

133     /* package */ void notifyTokenFontColorChange(MimePath mimePath, String JavaDoc profile) {
134         // XXX: this is hack, we should not abuse the event values like that
135
pcs.firePropertyChange(PROP_TOKEN_COLORINGS, mimePath, profile);
136     }
137     
138     /**
139      * Gets display names of all font & color profiles.
140      *
141      * @return set of font & colors profiles
142      */

143     public Set JavaDoc<String JavaDoc> getFontColorProfiles () {
144     if (fontColorProfiles == null) {
145         init ();
146         }
147         
148         Set JavaDoc<String JavaDoc> result = new HashSet JavaDoc<String JavaDoc>();
149         for(String JavaDoc profile : fontColorProfiles.keySet()) {
150             if (!profile.startsWith ("test")) {
151                 result.add(profile);
152             }
153         }
154         
155     return result;
156     }
157     
158     private Set JavaDoc<String JavaDoc> systemFontColorProfiles;
159     
160     /**
161      * Returns true for user defined profile.
162      *
163      * @param profile a profile name
164      * @return true for user defined profile
165      */

166     public boolean isCustomFontColorProfile(String JavaDoc profile) {
167         if (systemFontColorProfiles == null) {
168             init ();
169         }
170         
171         return !systemFontColorProfiles.contains(profile);
172     }
173     
174     private String JavaDoc currentFontColorProfile;
175     
176     /**
177      * Returns name of current font & colors profile.
178      *
179      * @return name of current font & colors profile
180      */

181     public String JavaDoc getCurrentFontColorProfile () {
182         if (currentFontColorProfile == null) {
183             FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
184             FileObject fo = fs.findResource (EDITORS_FOLDER);
185             if (fo != null) {
186                 currentFontColorProfile = (String JavaDoc) fo.getAttribute(FATTR_CURRENT_FONT_COLOR_PROFILE);
187             }
188             if (currentFontColorProfile == null) {
189                 currentFontColorProfile = DEFAULT_PROFILE;
190             }
191         }
192         if (!getFontColorProfiles ().contains (currentFontColorProfile)) {
193             currentFontColorProfile = DEFAULT_PROFILE;
194         }
195         return currentFontColorProfile;
196     }
197     
198     /**
199      * Sets current font & colors profile.
200      *
201      * @param profile a profile name
202      */

203     public void setCurrentFontColorProfile (String JavaDoc profile) {
204         String JavaDoc oldProfile = getCurrentFontColorProfile ();
205         if (oldProfile.equals (profile)) return;
206
207         currentFontColorProfile = profile;
208         
209         // Persist the change
210
FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
211     FileObject fo = fs.findResource (EDITORS_FOLDER);
212         if (fo != null) {
213             try {
214                 fo.setAttribute (FATTR_CURRENT_FONT_COLOR_PROFILE, profile);
215             } catch (IOException JavaDoc ex) {
216                 LOG.log(Level.WARNING, "Can't persist change in current font&colors profile.", ex); //NOI18N
217
}
218         }
219
220         // Notify others
221
pcs.firePropertyChange (PROP_CURRENT_FONT_COLOR_PROFILE, oldProfile, currentFontColorProfile);
222     }
223     
224     /**
225      * Returns font & color defaults for given profile or null, if the profile
226      * is unknown .
227      *
228      * @param profile a profile name
229      * @return font & color defaults for given profile or null
230      *
231      * @deprecated Use getFontColorSettings(new String[0]).getAllFontColors(profile) instead.
232      */

233     public Collection JavaDoc<AttributeSet JavaDoc> getDefaultFontColors(String JavaDoc profile) {
234         return getFontColorSettings(new String JavaDoc[0]).getAllFontColors(profile);
235     }
236     
237     /**
238      * Returns default values for font & color defaults for given profile
239      * or null, if the profile is unknown.
240      *
241      * @param profile a profile name
242      * @return font & color defaults for given profile or null
243      *
244      * @deprecated Use getFontColorSettings(new String[0]).getAllFontColorsDefaults(profile) instead.
245      */

246     public Collection JavaDoc<AttributeSet JavaDoc> getDefaultFontColorDefaults(String JavaDoc profile) {
247         return getFontColorSettings(new String JavaDoc[0]).getAllFontColorDefaults(profile);
248     }
249     
250     /**
251      * Sets font & color defaults for given profile.
252      *
253      * @param profile a profile name
254      * @param fontColors font & color defaults to be used
255      *
256      * @deprecated Use getFontColorSettings(new String[0]).setAllFontColors(profile, fontColors) instead.
257      */

258     public void setDefaultFontColors(String JavaDoc profile, Collection JavaDoc<AttributeSet JavaDoc> fontColors) {
259         getFontColorSettings(new String JavaDoc[0]).setAllFontColors(profile, fontColors);
260     }
261     
262     // Map (String (profile) > Map (String (category) > AttributeSet)).
263
private Map JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, AttributeSet JavaDoc>> highlightings = new HashMap JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, AttributeSet JavaDoc>>();
264     
265     /**
266      * Returns highlighting properties for given profile or null, if the
267      * profile is not known.
268      *
269      * @param profile a profile name
270      * @return highlighting properties for given profile or null
271      */

272     public Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> getHighlightings (
273     String JavaDoc profile
274     ) {
275         // 1) translate profile name
276
profile = getInternalFontColorProfile (profile);
277
278         if (!highlightings.containsKey (profile)) {
279             
280             // 2) init profile for test mime types
281
if (profile.startsWith ("test")) {
282                 highlightings.put (
283                     profile,
284                     getHighlightings (DEFAULT_PROFILE)
285                 );
286             } else {
287                 
288                 // 3) read data form disk or cache
289
Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> m = ColoringStorage.loadColorings
290                     (MimePath.EMPTY, profile, false, false);
291                 highlightings.put (profile, m);
292             }
293         }
294         
295         if (highlightings.get(profile) == null) {
296             return null;
297         } else {
298             return Collections.unmodifiableMap(highlightings.get(profile));
299         }
300     }
301     
302     // Map (String (profile) > Map (String (category) > AttributeSet)).
303
private Map JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, AttributeSet JavaDoc>> highlightingDefaults = new HashMap JavaDoc<String JavaDoc, Map JavaDoc<String JavaDoc, AttributeSet JavaDoc>>();
304     
305     /**
306      * Returns defaults for highlighting properties for given profile,
307      * or null if the profile is not known.
308      *
309      * @param profile a profile name
310      * @return highlighting properties for given profile or null
311      */

312     public Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> getHighlightingDefaults (
313     String JavaDoc profile
314     ) {
315         // 1) translate profile name
316
profile = getInternalFontColorProfile (profile);
317
318         // 2) read data form disk or cache
319
if (!highlightingDefaults.containsKey (profile)) {
320             Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> m = ColoringStorage.loadColorings
321                 (MimePath.EMPTY, profile, false, true);
322             highlightingDefaults.put (profile, m);
323         }
324         
325         if (highlightingDefaults.get(profile) == null) {
326             return null;
327         } else {
328             return Collections.unmodifiableMap(highlightingDefaults.get(profile));
329         }
330     }
331     
332     /**
333      * Sets highlighting properties for given profile.
334      *
335      * @param profile a profile name
336      * @param highlighting a highlighting properties to be used
337      */

338     public void setHighlightings (
339     String JavaDoc profile,
340     Map JavaDoc<String JavaDoc, AttributeSet JavaDoc> fontColors
341     ) {
342         // 1) translate profile name
343
String JavaDoc internalProfile = getInternalFontColorProfile (profile);
344         
345         if (fontColors == null) {
346             // 2) remove coloring / revert to defaults
347
ColoringStorage.deleteColorings
348                 (MimePath.EMPTY, internalProfile, false, false);
349             highlightings.remove (internalProfile);
350             init ();
351         } else {
352
353             if (fontColors.equals (highlightings.get (internalProfile))) return;
354
355             // 2) save new values to cache
356
fontColors = Utils.immutize(fontColors);
357             highlightings.put (internalProfile, fontColors);
358
359             // 3) save new values to disk
360
if (!internalProfile.startsWith ("test")) {
361                 ColoringStorage.saveColorings (
362                     MimePath.EMPTY,
363                     internalProfile,
364                     false,
365                     false,
366                     fontColors.values ()
367                 );
368                 if (fontColorProfiles.get (profile) == null)
369                     fontColorProfiles.put (profile, profile);
370             }
371         }
372         
373         pcs.firePropertyChange(PROP_HIGHLIGHT_COLORINGS, MimePath.EMPTY, internalProfile);
374     }
375     
376     
377     // KeyMaps .................................................................
378

379     /**
380      * Returns set of keymap profiles.
381      *
382      * @return set of font & colors profiles
383      */

384     public Set JavaDoc<String JavaDoc> getKeyMapProfiles () {
385     if (keyMapProfiles == null) init ();
386     return Collections.unmodifiableSet (keyMapProfiles.keySet ());
387     }
388     
389     private Set JavaDoc<String JavaDoc> systemKeymapProfiles;
390     
391     /**
392      * Returns true for user defined profile.
393      *
394      * @param profile a profile name
395      * @return true for user defined profile
396      */

397     public boolean isCustomKeymapProfile (String JavaDoc profile) {
398         if (systemKeymapProfiles == null) {
399             init();
400         }
401         
402         return !systemKeymapProfiles.contains (profile);
403     }
404     
405     private String JavaDoc currentKeyMapProfile;
406     
407     /**
408      * Returns name of current keymap profile.
409      *
410      * @return name of current keymap profile
411      */

412     public String JavaDoc getCurrentKeyMapProfile () {
413         if (currentKeyMapProfile == null) {
414             FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
415             FileObject fo = fs.findResource (KEYMAPS_FOLDER);
416             currentKeyMapProfile = fo == null ? null : (String JavaDoc) fo.getAttribute (FATTR_CURRENT_KEYMAP_PROFILE);
417             if (currentKeyMapProfile == null)
418                 currentKeyMapProfile = DEFAULT_PROFILE;
419         }
420         return currentKeyMapProfile;
421     }
422     
423     /**
424      * Sets current keymap profile.
425      *
426      * @param profile a profile name
427      */

428     public void setCurrentKeyMapProfile (String JavaDoc keyMapName) {
429         String JavaDoc oldKeyMap = getCurrentKeyMapProfile ();
430         if (oldKeyMap.equals (keyMapName)) return;
431
432         currentKeyMapProfile = keyMapName;
433         
434         // Persist the change
435
try {
436             FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
437             FileObject fo = fs.findResource (KEYMAPS_FOLDER);
438             if (fo == null) {
439                 fo = fs.getRoot ().createFolder (KEYMAPS_FOLDER);
440             }
441             fo.setAttribute (FATTR_CURRENT_KEYMAP_PROFILE, keyMapName);
442         } catch (IOException JavaDoc ex) {
443             LOG.log(Level.WARNING, "Can't persist change in current keybindings profile.", ex); //NOI18N
444
}
445         
446         // Notify others
447
pcs.firePropertyChange (PROP_CURRENT_KEY_MAP_PROFILE, oldKeyMap, currentKeyMapProfile);
448     }
449     
450     /**
451      * PropertyChangeListener registration.
452      *
453      * @param l a PropertyChangeListener to be registerred
454      */

455     public void addPropertyChangeListener (
456         PropertyChangeListener JavaDoc l
457     ) {
458         pcs.addPropertyChangeListener (l);
459     }
460     
461     /**
462      * PropertyChangeListener registration.
463      *
464      * @param l a PropertyChangeListener to be unregisterred
465      */

466     public void removePropertyChangeListener (
467         PropertyChangeListener JavaDoc l
468     ) {
469         pcs.removePropertyChangeListener (l);
470     }
471     
472     /**
473      * PropertyChangeListener registration.
474      *
475      * @param propertyName The name of the property to listen on.
476      * @param l a PropertyChangeListener to be registerred
477      */

478     public void addPropertyChangeListener (
479         String JavaDoc propertyName,
480         PropertyChangeListener JavaDoc l
481     ) {
482         pcs.addPropertyChangeListener (propertyName, l);
483     }
484     
485     /**
486      * PropertyChangeListener registration.
487      *
488      * @param propertyName The name of the property to listen on.
489      * @param l a PropertyChangeListener to be unregisterred
490      */

491     public void removePropertyChangeListener (
492         String JavaDoc propertyName,
493         PropertyChangeListener JavaDoc l
494     ) {
495         pcs.removePropertyChangeListener (propertyName, l);
496     }
497     
498
499     // support methods .........................................................
500

501     private Map JavaDoc<String JavaDoc, String JavaDoc> fontColorProfiles;
502     private Map JavaDoc<String JavaDoc, String JavaDoc> keyMapProfiles;
503     private Set JavaDoc<String JavaDoc> mimeTypesWithColoring;
504
505     private EditorSettingsImpl() {
506         
507     }
508     
509     private void init () {
510     fontColorProfiles = new HashMap JavaDoc<String JavaDoc, String JavaDoc>();
511     keyMapProfiles = new HashMap JavaDoc<String JavaDoc, String JavaDoc>();
512     keyMapProfiles.put (DEFAULT_PROFILE, DEFAULT_PROFILE);
513     mimeTypesWithColoring = new HashSet JavaDoc<String JavaDoc>();
514         systemFontColorProfiles = new HashSet JavaDoc<String JavaDoc>();
515         systemKeymapProfiles = new HashSet JavaDoc<String JavaDoc>();
516     FileSystem fs = Repository.getDefault ().getDefaultFileSystem ();
517     FileObject fo = fs.findResource (EDITORS_FOLDER);
518         if (fo != null) {
519             Enumeration JavaDoc e = fo.getFolders (false);
520             while (e.hasMoreElements()) {
521                 init1 ((FileObject) e.nextElement ());
522             }
523         }
524         
525         mimeTypesWithColoring = Collections.unmodifiableSet(mimeTypesWithColoring);
526     }
527     
528     private void init1 (FileObject fo) {
529         Enumeration JavaDoc e = fo.getChildren (false);
530         while (e.hasMoreElements ())
531             init2 ((FileObject) e.nextElement ());
532     }
533     
534     private void init2 (FileObject fo) {
535         if (fo.getNameExt ().equals (ColoringStorage.DEFAULTS_FOLDER) && fo.isFolder () &&
536             fo.getFileObject (ColoringStorage.HIGHLIGHTING_FILE_NAME) != null
537         )
538             addFontColorsProfile (fo, true); // Editors/ProfileName/Defaults/editorColoring.xml
539
else
540         if (fo.getNameExt ().equals (ColoringStorage.HIGHLIGHTING_FILE_NAME))
541             addFontColorsProfile (fo, false); // Editors/ProfileName/editorColoring.xml
542
else
543         if (fo.getFileObject (DEFAULT_PROFILE + "/" + ColoringStorage.DEFAULTS_FOLDER + "/" + ColoringStorage.COLORING_FILE_NAME) != null) //NOI18N
544
addMimeType (fo); // Editors/XXX/YYY/NetBeans/Defaults/coloring.xml
545
else
546         if (fo.getPath ().endsWith ("text/base") && fo.isFolder ()) { //NOI18N
547
if (fo.getFileObject (KeyMapsStorage.DEFAULTS_FOLDER + "/" + KeyMapsStorage.KEYBINDING_FILE_NAME) != null) //NOI18N
548
addKeyMapProfile (fo, true); // Editors/text/base/Defaults/keybindings.xml
549
else
550             if (fo.getFileObject (KeyMapsStorage.KEYBINDING_FILE_NAME) != null)
551                 addKeyMapProfile (fo, false); // Editors/text/base/keybindings.xml
552
Enumeration JavaDoc e = fo.getChildren (false);
553             while (e.hasMoreElements ()) {
554                 FileObject ff = (FileObject) e.nextElement ();
555                 if (!ff.getNameExt().equals(KeyMapsStorage.DEFAULTS_FOLDER)) {
556                     init3 (ff);
557                 }
558             }
559         }
560     }
561         
562     private void init3 (FileObject fo) {
563         if (fo.getFileObject (KeyMapsStorage.DEFAULTS_FOLDER + "/" + KeyMapsStorage.KEYBINDING_FILE_NAME) != null) //NOI18N
564
addKeyMapProfile (fo, true); // Editors/text/base/ProfileName/Defaults/keybindings.xml
565
else
566         if (fo.getFileObject (KeyMapsStorage.KEYBINDING_FILE_NAME) != null)
567             addKeyMapProfile (fo, false); // Editors/text/base/ProfileName/keybindings.xml
568
}
569
570     private void addMimeType(FileObject fo) {
571         String JavaDoc mimeType = fo.getPath().substring(8);
572         mimeTypesWithColoring.add(mimeType);
573     }
574     
575     private void addFontColorsProfile(FileObject fo, boolean systemProfile) {
576         String JavaDoc profile = fo.getParent().getNameExt();
577         String JavaDoc displayName = Utils.getLocalizedName(fo.getParent(), profile, profile);
578         
579         if (systemProfile) {
580             systemFontColorProfiles.add(displayName);
581         }
582         
583         fontColorProfiles.put(displayName, profile);
584     }
585     
586     private void addKeyMapProfile(FileObject fo, boolean systemProfile) {
587         String JavaDoc profile = fo.getNameExt();
588         if (profile.equals("base")) { //NOI18N
589
profile = DEFAULT_PROFILE;
590         }
591         
592         String JavaDoc displayName = Utils.getLocalizedName(fo, profile, profile);
593         
594         if (systemProfile) {
595             systemKeymapProfiles.add(displayName);
596         }
597         
598         keyMapProfiles.put(displayName, profile);
599     }
600     
601     /**
602      * Translates profile's display name to its Id. If the profile's display name
603      * can't be translated this method will simply return the profile's display name
604      * without translation.
605      */

606     String JavaDoc getInternalFontColorProfile(String JavaDoc profile) {
607     if (fontColorProfiles == null) {
608         init ();
609         }
610         
611     String JavaDoc result = fontColorProfiles.get(profile);
612         return result != null ? result : profile;
613     }
614     
615     String JavaDoc getInternalKeymapProfile (String JavaDoc profile) {
616     if (keyMapProfiles == null) {
617         init();
618         }
619         
620     String JavaDoc result = keyMapProfiles.get (profile);
621         if (result != null) {
622             return result;
623         } else {
624             keyMapProfiles.put(profile, profile);
625             return profile;
626         }
627     }
628     
629     public KeyBindingSettingsFactory getKeyBindingSettings (String JavaDoc[] mimeTypes) {
630         mimeTypes = filter(mimeTypes);
631         return KeyBindingSettingsImpl.get(Utils.mimeTypes2mimePath(mimeTypes));
632     }
633
634     public FontColorSettingsFactory getFontColorSettings (String JavaDoc[] mimeTypes) {
635         mimeTypes = filter(mimeTypes);
636         return FontColorSettingsImpl.get(Utils.mimeTypes2mimePath(mimeTypes));
637     }
638     
639     private String JavaDoc [] filter(String JavaDoc [] mimeTypes) {
640         if (mimeTypes.length > 0 && mimeTypes[0].startsWith("test")) { //NOI18N
641
String JavaDoc [] filtered = new String JavaDoc [mimeTypes.length];
642             System.arraycopy(mimeTypes, 0, filtered, 0, mimeTypes.length);
643             filtered[0] = mimeTypes[0].substring(mimeTypes[0].indexOf('_') + 1); //NOI18N
644

645             LOG.log(Level.INFO, "Don't use 'test' mime type to access settings through the editor/settings/storage API!", new Throwable JavaDoc("Stacktrace"));
646             
647             return filtered;
648         } else {
649             return mimeTypes;
650         }
651     }
652 }
653
Popular Tags