本文整理汇总了Java中org.netbeans.api.editor.mimelookup.MimeLookup类的典型用法代码示例。如果您正苦于以下问题:Java MimeLookup类的具体用法?Java MimeLookup怎么用?Java MimeLookup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MimeLookup类属于org.netbeans.api.editor.mimelookup包,在下文中一共展示了MimeLookup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getCachePath
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private String getCachePath() {
String path = cachedPath;
if (path != null) {
return path;
}
CustomIndexerFactory jif = null;
final Iterable<? extends CustomIndexerFactory> factories = MimeLookup.getLookup(MIME_JAVA).lookupAll(CustomIndexerFactory.class);
for (CustomIndexerFactory fact : factories) {
if (JAVA_NAME.equals(fact.getIndexerName())) {
jif = fact;
break;
}
}
if (jif == null) {
return null;
}
synchronized (Factory.this) {
cachedPath = String.format(PATH_TEMPLATE, jif.getIndexerName(), jif.getIndexVersion()); //NOI18N
return cachedPath;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CopyResourcesIndexer.java
示例2: testColoringsForMimeType
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
public void testColoringsForMimeType() throws Exception {
final String mimeType = "text/x-orig";
Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimeType));
// Check the API class
Collection<? extends FontColorSettings> c = lookup.lookupAll(FontColorSettings.class);
assertEquals("Wrong number of fcs", 1, c.size());
FontColorSettings fcs = c.iterator().next();
assertNotNull("FCS should not be null", fcs);
assertTrue("Wrong fcs impl", fcs instanceof CompositeFCS);
CompositeFCS compositeFcs = (CompositeFCS) fcs;
assertEquals("CompositeFCS using wrong profile", EditorSettingsImpl.DEFAULT_PROFILE, compositeFcs.profile);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:CompositeFCSTest.java
示例3: XhtmlElHighlighting
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
XhtmlElHighlighting(Document document) {
this.document = document;
// load the background color for the embedding token
AttributeSet elAttribs = null;
String mimeType = (String) document.getProperty("mimeType"); //NOI18N
FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
if (fcs != null) {
Color elBC = getColoring(fcs, XhtmlElTokenId.EL.primaryCategory());
if (elBC != null) {
elAttribs = AttributesUtilities.createImmutable(
StyleConstants.Background, elBC,
ATTR_EXTENDS_EOL, Boolean.TRUE);
}
}
expressionLanguageBackground = elAttribs;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:XhtmlElHighlighting.java
示例4: getColoring
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private Coloring getColoring() {
if (attribs == null) {
if (fcsLookupResult == null) {
fcsLookupResult = MimeLookup.getLookup(org.netbeans.lib.editor.util.swing.DocumentUtilities.getMimeType(component))
.lookupResult(FontColorSettings.class);
fcsLookupResult.addLookupListener(WeakListeners.create(LookupListener.class, fcsTracker, fcsLookupResult));
}
FontColorSettings fcs = fcsLookupResult.allInstances().iterator().next();
AttributeSet attr = fcs.getFontColors(FontColorNames.CODE_FOLDING_BAR_COLORING);
specificAttrs = attr;
if (attr == null) {
attr = fcs.getFontColors(FontColorNames.DEFAULT_COLORING);
} else {
attr = AttributesUtilities.createComposite(
attr,
fcs.getFontColors(FontColorNames.DEFAULT_COLORING));
}
attribs = attr;
}
return Coloring.fromAttributeSet(attribs);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:CodeFoldingSideBar.java
示例5: prefs
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
Preferences prefs(String mime) {
synchronized (preferences) {
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();
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:FoldOptionsController.java
示例6: alterSettings
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private static Map<String, String> alterSettings(String... settings) throws Exception {
//XXX: hack, need to initialize the HintTest's lookup before setting the
//formatting preferences
HintTest.create();
Map<String, String> adjustPreferences = new HashMap<String, String>();
for (int i = 0; i < settings.length; i += 2) {
adjustPreferences.put(settings[i], settings[i + 1]);
}
Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
Map<String, String> origValues = new HashMap<String, String>();
for (String key : adjustPreferences.keySet()) {
origValues.put(key, preferences.get(key, null));
}
setValues(preferences, adjustPreferences);
return origValues;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:TinyTest.java
示例7: getAttribs
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private AttributeSet getAttribs(String coloringName, boolean extendsEol, boolean extendsEmptyLine) {
FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
AttributeSet attribs = fcs.getFontColors(coloringName);
if (attribs == null) {
attribs = SimpleAttributeSet.EMPTY;
} else if (extendsEol || extendsEmptyLine) {
attribs = AttributesUtilities.createImmutable(
attribs,
AttributesUtilities.createImmutable(
ATTR_EXTENDS_EOL, Boolean.valueOf(extendsEol),
ATTR_EXTENDS_EMPTY_LINE, Boolean.valueOf(extendsEmptyLine))
);
}
return attribs;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:GuardedBlockSuppressLayer.java
示例8: findLegacyNonTokenColoringNames
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private static List<String> findLegacyNonTokenColoringNames(MimePath mimePath) {
List<String> legacyNonTokenColoringNames = new ArrayList<String>();
Preferences prefs = MimeLookup.getLookup(mimePath).lookup(Preferences.class);
if (prefs != null) {
String namesList = prefs.get(EditorPreferencesKeys.COLORING_NAME_LIST, null); //NOI18N
if (namesList != null && namesList.length() > 0) {
for (StringTokenizer t = new StringTokenizer(namesList, ","); t.hasMoreTokens();) { //NOI18N
String coloringName = t.nextToken().trim();
legacyNonTokenColoringNames.add(coloringName);
}
}
}
return legacyNonTokenColoringNames;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ColoringMap.java
示例9: arePrefsChanged
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private boolean arePrefsChanged(String mimeType, PreferencesCustomizer c) {
boolean isChanged = false;
Preferences prefs = selector.getCustomizerPreferences(c);
Preferences savedPrefs = MimeLookup.getLookup(mimeType).lookup(Preferences.class);
HashSet<String> hashSet = new HashSet<String>();
try {
hashSet.addAll(Arrays.asList(prefs.keys()));
hashSet.addAll(Arrays.asList(savedPrefs.keys()));
} catch (BackingStoreException ex) {
return false;
}
for (String key : hashSet) {
if (key.equals(FormattingPanelController.OVERRIDE_GLOBAL_FORMATTING_OPTIONS)) {
continue;
}
isChanged |= (prefs.get(key, null) == null ? savedPrefs.get(key, null) != null : !prefs.get(key, null).equals(savedPrefs.get(key, null)))
|| (prefs.get(key, null) == null ? savedPrefs.get(key, null) != null : !prefs.get(key, null).equals(savedPrefs.get(key, null)));
}
return isChanged;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:FormattingPanelController.java
示例10: testChangesNotVisibleAfterRollBack
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
public void testChangesNotVisibleAfterRollBack() throws InterruptedException, IOException {
assertTrue(GlobalPathRegistry.getDefault().getPaths(FOO_SOURCES).isEmpty());
final RepositoryUpdaterTest.TestHandler handler = new RepositoryUpdaterTest.TestHandler();
final Logger logger = Logger.getLogger(RepositoryUpdater.class.getName()+".tests"); //NOI18N
logger.setLevel (Level.FINEST);
logger.addHandler(handler);
MimeLookup.getLookup(MimePath.get(FOO_MIME)).lookup(FooIndexerFactory.class).setCancelScanning(true);
globalPathRegistry_register(FOO_SOURCES,new ClassPath[]{cp1});
assertTrue (handler.await());
assertEquals(0, handler.getBinaries().size());
assertEquals(1, handler.getSources().size());
assertEquals(this.src1.toURL(), handler.getSources().get(0));
assertFalse(MimeLookup.getLookup(MimePath.get(FOO_MIME)).lookup(FooIndexerFactory.class).isSuccess());
QuerySupport qs = QuerySupport.forRoots(FooIndexerFactory.NAME, FooIndexerFactory.VERSION, src1);
final Collection<? extends IndexResult> res = qs.query("_sn", "", QuerySupport.Kind.PREFIX, (String[]) null); //NOI18N
assertEquals(0, res.size());
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:IndexingSupportACIDTest.java
示例11: getPopupMenuItem
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
JCheckBoxMenuItem item = new JCheckBoxMenuItem(
NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
toolbarVisible);
item.addItemListener( new ItemListener() {
public @Override void itemStateChanged(ItemEvent e) {
actionPerformed(null,null);
}
});
return item;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NbEditorKit.java
示例12: Highlighting
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
/** Creates a new instance of Highlighting */
public Highlighting(Document doc) {
AttributeSet firstLineFontColor = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class).getTokenFontColors("javadoc-first-sentence"); //NOI18N
AttributeSet commentFontColor = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class).getTokenFontColors("comment"); //NOI18N
if(firstLineFontColor != null && commentFontColor != null) {
Collection<Object> attrs = new LinkedList<Object>();
for (Enumeration<?> e = firstLineFontColor.getAttributeNames(); e.hasMoreElements(); ) {
Object key = e.nextElement();
Object value = firstLineFontColor.getAttribute(key);
if (!commentFontColor.containsAttribute(key, value)) {
attrs.add(key);
attrs.add(value);
}
}
fontColor = AttributesUtilities.createImmutable(attrs.toArray());
} else {
fontColor = AttributesUtilities.createImmutable();
LOG.warning("FontColorSettings for javadoc-first-sentence or comment are not available."); //NOI18N
}
this.document = doc;
hierarchy = TokenHierarchy.get(document);
if (hierarchy != null) {
hierarchy.addTokenHierarchyListener(WeakListeners.create(TokenHierarchyListener.class, this, hierarchy));
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:Highlighting.java
示例13: testAcceptBothFactories
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
/**
* Checks that the Provider accepts both new and old SideBars, and that they can be ordered
* at will using position FO attribute
*/
public void testAcceptBothFactories() throws Exception {
SideBarFactoriesProvider p = MimeLookup.getLookup("text/x-type-A").lookup(SideBarFactoriesProvider.class);
Map<SideBarPosition, List> c = p.getFactories();
assertEquals(3, c.size());
for (SideBarPosition pos : c.keySet()) {
List ll = c.get(pos);
if (SideBarPosition.WEST_NAME.equals(pos.getPositionName())) {
Object o = ll.get(0);
assertTrue(o instanceof SBF2);
o = ll.get(1);
assertTrue(o instanceof SBF1);
} else {
assertEquals(1, ll.size());
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SideBarFactoriesProviderTest.java
示例14: testWriting
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
public void testWriting() throws Exception {
{
Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
assertEquals("Wrong value for 'simple-value-setting-A'", "value-A", prefs.get("simple-value-setting-A", null));
prefs.put("simple-value-setting-A", "New-Written-Value");
assertEquals("Wrong value for 'simple-value-setting-A'", "New-Written-Value", prefs.get("simple-value-setting-A", null));
prefs.sync();
}
{
// read the settings right from the file
StorageImpl<String, TypedValue> storage = new StorageImpl<String, TypedValue>(new PreferencesStorage(), null);
Map<String, TypedValue> map = storage.load(MimePath.EMPTY, null, false);
assertEquals("Wrong value for 'simple-value-setting-A'", "New-Written-Value", map.get("simple-value-setting-A").getValue());
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PreferencesTest.java
示例15: EmbeddedSectionsHighlighting
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
EmbeddedSectionsHighlighting(Document document) {
this.document = document;
// load the background color for the embedding token
AttributeSet attribs = null;
String mimeType = (String) document.getProperty("mimeType"); //NOI18N
FontColorSettings fcs = MimeLookup.getLookup(mimeType).lookup(FontColorSettings.class);
if (fcs != null) {
Color jsBC = getColoring(fcs, YamlTokenId.RUBY.primaryCategory());
if (jsBC != null) {
attribs = AttributesUtilities.createImmutable(
StyleConstants.Background, jsBC,
ATTR_EXTENDS_EOL, Boolean.TRUE);
}
}
rubyBackground = attribs;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:EmbeddedSectionsHighlighting.java
示例16: testCommentBlockCompletionTwoComments
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
public void testCommentBlockCompletionTwoComments () {
Preferences prefs = MimeLookup.getLookup(JavaKit.JAVA_MIME_TYPE).lookup(Preferences.class);
try {
prefs.putBoolean("enableBlockCommentFormatting", true);
Context ctx = new Context(new JavaKit(),
"/*|\n" +
"/*\n" +
" */"
);
ctx.typeChar('\n');
ctx.assertDocumentTextEquals(
"/*\n" +
" * |\n" +
" */\n" +
"/*\n" +
" */"
);
} finally {
prefs.remove("enableBlockCommentFormatting");
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:TypingCompletionUnitTest.java
示例17: getLookup
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
/** This method is here to simulate that it is possible to get
* instance of the lookup without querying any of registered InstanceProvider.
* They could acquire AWT lock and that can cause deadlocks.
*/
private Lookup getLookup(final MimePath path) throws Exception {
class BlockAWTLock implements Runnable {
Lookup l;
public void run() {
l = MimeLookup.getLookup(path);
}
}
BlockAWTLock b = new BlockAWTLock();
synchronized (PopupActions.LOCK) {
SwingUtilities.invokeAndWait(b);
}
return b.l;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MimeLookupPopupItemsChangeTest.java
示例18: findAttribs
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private AttributeSet findAttribs(TokenItem tokenItem) {
synchronized (this) {
AttributeSet attribs = attribsCache.get(tokenItem.getTokenID());
if (attribs == null) {
FontColorSettings fcs = MimeLookup.getLookup(mimePath).lookup(FontColorSettings.class);
if (fcs != null) {
attribs = findFontAndColors(fcs, tokenItem);
if (attribs == null) {
attribs = SimpleAttributeSet.EMPTY;
}
attribsCache.put(tokenItem.getTokenID(), attribs);
} else {
LOG.warning("Can't find FCS for mime path: '" + mimePath.getPath() + "'"); //NOI18N
}
}
return attribs == null ? SimpleAttributeSet.EMPTY : attribs;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:NonLexerSyntaxHighlighting.java
示例19: prepareSettings
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
/** Prepares settings. */
private void prepareSettings() {
if (prepared) return;
prepared = true;
// Set listening on changes of settings.
fontsColors = MimeLookup.getLookup(PropertiesKit.PROPERTIES_MIME_TYPE).lookupResult(FontColorSettings.class);
fontsColors.addLookupListener(WeakListeners.create(LookupListener.class, fontsColorsTracker, fontsColors));
keybindings = MimeLookup.getLookup(PropertiesKit.PROPERTIES_MIME_TYPE).lookupResult(KeyBindingSettings.class);
keybindings.addLookupListener(WeakListeners.create(LookupListener.class, keybindingsTracker, keybindings));
// Init settings.
updateColors();
updateKeyStrokes();
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EditorSettingsCopy.java
示例20: findKeyBinding
import org.netbeans.api.editor.mimelookup.MimeLookup; //导入依赖的package包/类
private static String findKeyBinding(String actionName) {
KeyBindingSettings kbs = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(KeyBindingSettings.class); //NOI18N
for (MultiKeyBinding mkb : kbs.getKeyBindings()) {
if (actionName.equals(mkb.getActionName())) {
KeyStroke ks = mkb.getKeyStrokeCount() > 0 ? mkb.getKeyStroke(0) : null;
return ks != null ? KeyEvent.getKeyModifiersText(ks.getModifiers()) + '+' + KeyEvent.getKeyText(ks.getKeyCode()) : null;
}
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ComputeAnnotations.java
注:本文中的org.netbeans.api.editor.mimelookup.MimeLookup类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论