protected @Override void flushSpi() throws BackingStoreException { // This should normally be true when invoked from flushTask, but // clients can generally get this node and call flush() on it without // changing anything. if (local != null) { try { storage.save(MimePath.parse(mimePath), null, false, local); } catch (IOException ioe) { LOG.log(Level.WARNING, "Can't save editor preferences for '" + mimePath + "'", ioe); //NOI18N } } }
private Map<String, TypedValue> getLocal() { if (local == null) { try { local = new HashMap<String, TypedValue>(storage.load(MimePath.parse(mimePath), null, false)); } catch (IOException ioe) { LOG.log(Level.WARNING, "Can't load editor preferences for '" + mimePath + "'", ioe); //NOI18N local = new HashMap<String, TypedValue>(); } } return local; }
private Preferences getInherited() { if (inherited == null && mimePath.length() > 0) { String type = MimePath.parse(mimePath).getInheritedType(); if (type != null) { inherited = factory.createPreferences(MimePath.parse(type)); } else { inherited = factory.createPreferences(MimePath.EMPTY); } inherited.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, inherited)); } return inherited; }
private MimePath languagePathToMimePathHack(LanguagePath languagePath) { String mimeType = getMimeType(component); if (languagePath.size() == 1) { return MimePath.parse(mimeType); } else if (languagePath.size() > 1) { return MimePath.parse(mimeType + "/" + languagePath.subPath(1).mimePath()); //NOI18N } else { throw new IllegalStateException("LanguagePath should not be empty."); //NOI18N } }
private static Iterable<? extends JavaIndexerPlugin> createPlugins( @NonNull final URL root, @NonNull final FileObject cacheFolder) { final List<JavaIndexerPlugin> plugins = new ArrayList<JavaIndexerPlugin>(); for (JavaIndexerPlugin.Factory factory : MimeLookup.getLookup( MimePath.parse(JavacParser.MIME_TYPE)).lookupAll(JavaIndexerPlugin.Factory.class)) { final JavaIndexerPlugin plugin = factory.create(root, cacheFolder); if (plugin != null) { plugins.add(plugin); } } return plugins; }
/** * Creates new form DefaultFoldingOptions */ public DefaultFoldingOptions(String mime, Preferences preferences) { initComponents(); VerticalFlowLayout vfl = new VerticalFlowLayout(); localSwitchboard.setLayout(vfl); vfl = new VerticalFlowLayout(); localSwitchboard.setLayout(vfl); this.mimeType = mime; this.preferences = preferences; String parentMime = MimePath.parse(mime).getInheritedType(); if (parentMime != null) { parentFoldTypes = new HashSet<String>(13); for (FoldType ft : FoldUtilities.getFoldTypes(parentMime).values()) { parentFoldTypes.add(ft.code()); } } else { parentFoldTypes = Collections.emptyList(); } }
EditorKit kit = MimeLookup.getLookup(MimePath.parse("text/xhtml")).lookup(EditorKit.class); //NOI18N Document doc = kit.createDefaultDocument(); doc.insertString(0, selectedText, null);
Preferences prefs(String mime) { MemoryPreferences cached = preferences.get(mime); if (cached != null) { return cached.getPreferences(); } MimePath path = MimePath.parse(mime); Preferences result = MimeLookup.getLookup(mime).lookup(Preferences.class); if (!mime.equals("")) { // NOI18N String parentMime = path.getInheritedType(); /* result = new InheritedPreferences( prefs(parentMime), result); */ cached = MemoryPreferences.getWithInherited(this, prefs(parentMime), result); } else { cached = MemoryPreferences.get(this, result); } cached.getPreferences().addPreferenceChangeListener(weakChangeL); preferences.put(mime, cached); return cached.getPreferences(); }
MimePath linkedMimePath = MimePath.parse(linkTarget.getPath().substring(baseFolder.getPath().length() + 1)); assert linkedMimePath != mimePath : "linkedMimePath should not be the same as the original one"; //NOI18N
String parentMime = MimePath.parse(mime).getInheritedType(); if (parentMime != null) { parentPrefs = ctrl.prefs(parentMime);
Language<?> language, String mimeType, boolean addPre) { MimePath mimePath = MimePath.parse(mimeType); Lookup lookup = MimeLookup.getLookup(mimePath); FontColorSettings fcs = lookup.lookup(FontColorSettings.class); if (embedded != null) { String embeddedMimeType = MimePath.parse(embedded.languagePath().mimePath()).getPath(); Color bg = null; Color fg = null;
private synchronized Formatter getFormatter() { if(formatter == null) { // XXX: Carefull here, generally context.mimePath() != mimeType. This // task's factory was created for a top level language (mimeType), but the task // itself can be used for an embedded language. // If the task is used for the document itself (not an embedded // section) Context.mimePath() == mimeType. // However, if it is used for an embedded section the Context.mimePath() gives // the mime path (languege path) of that section. Which is generally // something like 'application/x-httpd-eruby/text/x-ruby'. While the // task was registered for 'text/x-ruby'. // Therefore with the __current__ implementation of MimeLookupInitializerImpl // we can simply take the last component of Context.mimePath(). MimePath mimePath = MimePath.parse(context.mimePath()); String mimeType = mimePath.size() > 1 ? mimePath.getMimeType(mimePath.size() - 1) : mimePath.getPath(); Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType); formatter = language.getFormatter(); } return formatter; } }
private synchronized Formatter getFormatter() { if (formatter == null) { // XXX: Carefull here, generally context.mimePath() != mimeType. This // task's factory was created for a top level language (mimeType), but the task // itself can be used for an embedded language. // If the task is used for the document itself (not an embedded // section) Context.mimePath() == mimeType. // However, if it is used for an embedded section the Context.mimePath() gives // the mime path (languege path) of that section. Which is generally // something like 'application/x-httpd-eruby/text/x-ruby'. While the // task was registered for 'text/x-ruby'. // Therefore with the __current__ implementation of MimeLookupInitializerImpl // we can simply take the last component of Context.mimePath(). MimePath mimePath = MimePath.parse(context.mimePath()); String mimeType = mimePath.size() > 1 ? mimePath.getMimeType(mimePath.size() - 1) : mimePath.getPath(); Language language = LanguageRegistry.getInstance().getLanguageByMimeType(mimeType); formatter = language.getFormatter(); } return formatter; }
MimePath mimePath = MimePath.parse (context.mimePath ()); String mimeType = mimePath.getMimeType (mimePath.size () - 1); Language l = LanguagesManager.getDefault ().getLanguage (mimeType);