• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MimePath类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.netbeans.api.editor.mimelookup.MimePath的典型用法代码示例。如果您正苦于以下问题:Java MimePath类的具体用法?Java MimePath怎么用?Java MimePath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MimePath类属于org.netbeans.api.editor.mimelookup包,在下文中一共展示了MimePath类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: callFactory

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public static Object callFactory(String factoryRef, MimePath mimePath) {
    int lastDot = factoryRef.lastIndexOf('.'); //NOI18N
    assert lastDot != -1 : "Need fully qualified name of class with the setting factory method."; //NOI18N

    String classFqn = factoryRef.substring(0, lastDot);
    String methodName = factoryRef.substring(lastDot + 1);

    ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class);
    try {
        Class factoryClass = loader.loadClass(classFqn);
        Method factoryMethod = factoryClass.getDeclaredMethod(methodName, MimePath.class);

        return factoryMethod.invoke(null, mimePath);
    } catch (Exception e) {
        LOG.log(Level.WARNING, null, e);
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:SettingsConversions.java


示例2: checkAddingMimeDataProvider2

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
private <T> void checkAddingMimeDataProvider2(String instanceFile, Class<T> markerClass) throws Exception {
    MimePath path = MimePath.get("text/x-java");
    
    Lookup.Result result = MimeLookup.getLookup(path).lookupResult(markerClass);
    Collection markers = result.allInstances();
    assertEquals("There should be no markers", 0, markers.size());

    L listener = new L();
    result.addLookupListener(listener);
    assertEquals("There should be no changes received", 0, listener.resultChangedCnt);
    
    // Add the data provider
    TestUtilities.createFile(getWorkDir(), instanceFile);
    TestUtilities.sleepForWhile();
    
    assertEquals("No changes received", 1, listener.resultChangedCnt);
    markers = result.allInstances();
    assertEquals("No markers found", 1, markers.size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:MimePathLookupTest.java


示例3: checkRemovingMimeDataProvider

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
private <T> void checkRemovingMimeDataProvider(String instanceFile, Class<T> markerClass) throws Exception {
    TestUtilities.createFile(getWorkDir(), instanceFile);
    TestUtilities.sleepForWhile();

    MimePath path = MimePath.get("text/x-java");
    Lookup lookup = MimeLookup.getLookup(path);
    
    Collection markers = lookup.lookupAll(markerClass);
    assertEquals("No markers found", 1, markers.size());

    TestUtilities.deleteFile(getWorkDir(), instanceFile);
    TestUtilities.sleepForWhile();
    
    markers = lookup.lookupAll(markerClass);
    assertEquals("There should be no markers", 0, markers.size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:MimePathLookupTest.java


示例4: setUp

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    clearWorkDir();
    MockMimeLookup.setInstances(MimePath.get(MIME), new TestParser.Factory());
    final FileObject wd = FileUtil.toFileObject(getWorkDir());
    final FileObject testFile = FileUtil.createData(
        wd,
        String.format("file.%s",    //NOI18N
            EXTENSION));
    FileUtil.setMIMEType(EXTENSION,MIME);
    src = Source.create(testFile);
    cache = SourceAccessor.getINSTANCE().getCache(src);
    task = new TestTask();
    cancelTask = new CancelTask();
    tpLogger = Logger.getLogger(TaskProcessor.class.getName());
    tpLevel = tpLogger.getLevel();
    tpLogger.setLevel(Level.FINE);
    tpHandler = new TestHandler();
    tpLogger.addHandler(tpHandler);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:CancelSupportTest.java


示例5: afterLoad

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
@Override
public void afterLoad(Map<Collection<KeyStroke>, MultiKeyBinding> map, MimePath mimePath, String profile, boolean defaults) {
    Map<String, MacroDescription> macros = new HashMap<String, MacroDescription>();
    if (!collectMacroActions(mimePath, macros)) {
        return;
    }
    
    for(MacroDescription macro : macros.values()) {
        List<? extends MultiKeyBinding> shortcuts = macro.getShortcuts();
        for(MultiKeyBinding shortcut : shortcuts) {
            Collection<KeyStroke> keys = shortcut.getKeyStrokeList();

            // A macro shortcut never replaces shortcuts for ordinary editor actions
            if (!map.containsKey(keys)) {
                map.put(keys, shortcut);
                if (LOG.isLoggable(Level.FINE)) {
                    LOG.fine("afterLoad: injecting " + keys + " for macro '" //NOI18N
                        + macro.getName() + "'; mimePath='" + mimePath.getPath() + "'"); //NOI18N
                }
            } else {
                LOG.warning("Shortcut " + keys + " is bound to '" + map.get(keys).getActionName() //NOI18N
                    + "' for '" + mimePath.getPath() + "' and will not be assigned to '" + macro.getName() + "' macro!"); //NOI18N
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:MacroShortcutsInjector.java


示例6: getCustomActions

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
protected Action[] getCustomActions() {
    MimePath mimePath = MimePath.parse(getContentType());
    Preferences prefs = MimeLookup.getLookup(mimePath).lookup(Preferences.class);
    
    @SuppressWarnings("unchecked")
    List<? extends Action> customActions = (List<? extends Action>) SettingsConversions.callFactory(
            prefs, mimePath, EditorPreferencesKeys.CUSTOM_ACTION_LIST, null); //NOI18N
    
    if (LOG.isLoggable(Level.FINE)) {
        LOG.fine(EditorPreferencesKeys.CUSTOM_ACTION_LIST + " for '" + getContentType() + "' {"); //NOI18N
        if (customActions != null) {
            for(Action a : customActions) {
                LOG.fine("    " + a); //NOI18N
            }
        }
        LOG.fine("} End of " + EditorPreferencesKeys.CUSTOM_ACTION_LIST + " for '" + getContentType() + "'"); //NOI18N
    }
    
    return customActions == null ? null : customActions.toArray(new Action[customActions.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:BaseKit.java


示例7: createMacro

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public Macro createMacro(MimePath mimeType, String name) {
    Macro macro = new Macro(this, mimeType, name, "", Collections.<MultiKeyBinding>emptyList());
    
    Map<String, Macro> map = mimeType2Macros.get(mimeType);
    if (map == null) {
        map = new HashMap<String, Macro>();
        mimeType2Macros.put(mimeType, map);
    }
    
    if (map.containsKey(name)) {
        throw new IllegalArgumentException("Can't create macro, the name is already used: '" + name + "'"); //NOI18N
    }
    
    map.put(name, macro);
    allMacrosList.add(macro);
    
    tableModel.fireTableRowsInserted(allMacrosList.size() - 1, allMacrosList.size() - 1);
    fireChanged();
    
    return macro;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MacrosModel.java


示例8: findKeyBinding

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的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


示例9: Snapshot

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
private Snapshot (
    CharSequence        text,
    int []              lineStartOffsets,
    Source              source,
    MimePath            mimePath,
    int[][]             currentToOriginal,
    int[][]             originalToCurrent
) {
    this.text =         text;
    this.lineStartOffsets = lineStartOffsets;
    this.source =       source;
    this.mimePath =     mimePath;
    this.currentToOriginal =    
                        currentToOriginal;
    this.originalToCurrent = 
                        originalToCurrent;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:Snapshot.java


示例10: testRemoveAll

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public void testRemoveAll() throws IOException {
    MimePath mimePath = MimePath.parse("text/x-type-A");
    CodeTemplateSettingsImpl ctsi = CodeTemplateSettingsImpl.get(mimePath);
    Map<String, CodeTemplateDescription> map = ctsi.getCodeTemplates();
    
    assertNotNull("CodeTemplates map should not be null", map);
    assertTrue("Code templates map should not be empty", map.size() > 0);
    
    // Remove all code templates
    ctsi.setCodeTemplates(Collections.<String, CodeTemplateDescription>emptyMap());
    
    // Force loading from the files
    //Map<String, CodeTemplateDescription> loadedMap = CodeTemplatesStorage.load(mimePath, false);
    StorageImpl<String, CodeTemplateDescription> storage = new StorageImpl<String, CodeTemplateDescription>(new CodeTemplatesStorage(), null);
    Map<String, CodeTemplateDescription> loadedMap = storage.load(mimePath, null, false);
    
    assertNotNull("Can't load the map", loadedMap);
    assertEquals("Some template were not removed", 0, loadedMap.size());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CodeTemplateSettingsImplTest.java


示例11: setUp

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
/**
 * We need our own data loader to use guarded blocks.
 */
@Override
protected void setUp() throws Exception {
    SourceUtilsTestUtil.prepareTest(new String[0], new Object[0]); //to initialize the correct lookup instance
    FileUtil.setMIMEType("java", "text/x-java");
    MockMimeLookup.setInstances(
            MimePath.parse("text/x-java"),
            new JavaGuardedSectionsFactory(),
            new org.netbeans.modules.editor.NbEditorKit());
    MockMimeLookup mml = new MockMimeLookup();
    ClassPathProvider cpp = new ClassPathProvider() {
        public ClassPath findClassPath(FileObject file, String type) {
            if (type.equals(ClassPath.SOURCE))
                return ClassPathSupport.createClassPath(new FileObject[] {FileUtil.toFileObject(getDataDir())});
                if (type.equals(ClassPath.COMPILE))
                    return ClassPathSupport.createClassPath(new FileObject[0]);
                if (type.equals(ClassPath.BOOT))
                    return createClassPath(System.getProperty("sun.boot.class.path"));
                return null;
        }
    };
    SourceUtilsTestUtil.prepareTest(new String[0], new Object[] {mml, new GuardedDataLoader(), cpp});
    File cacheFolder = new File(getWorkDir(), "var/cache/index");
    cacheFolder.mkdirs();
    IndexUtil.setCacheFolder(cacheFolder);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:GuardedBlockTest.java


示例12: testColoringsForMimeType

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的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


示例13: mimePathsToString

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
private static String mimePathsToString(MimePath... mimePaths) {
    if (mimePaths == null) {
        return "null";
    } else {
        StringBuilder sb = new StringBuilder();
        
        sb.append('{'); //NOI18N
        for(MimePath mp : mimePaths) {
            sb.append('\'').append(mp.getPath()).append('\''); //NOI18N
            sb.append(","); //NOI81N
        }
        sb.append('}'); //NOI18N
        
        return sb.toString();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:HighlightingManager.java


示例14: testChangesVisibleAfterCommit

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public void testChangesVisibleAfterCommit() 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);

        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));
        assertTrue(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(1, res.size());
        assertEquals(file1, res.iterator().next().getFile());
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:IndexingSupportACIDTest.java


示例15: testRegisteredTemplatesLookup

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
/** 
 * Lookuping the template that has registered subfolder via Class2LayerFolder
 */
public void testRegisteredTemplatesLookup() throws IOException{
    createFile("Editors/text/x-java/text/x-properties/testLookupTwo/" +
            "org-netbeans-modules-editor-mimelookup-impl-TestLookupObjectTwo.instance");
    
    MimePath mp = MimePath.parse("text/x-java/text/x-properties"); //NOI18N
    Lookup lookup = MimeLookup.getLookup(mp);
    checkLookupTemplate(lookup, TestLookupObject.class, 0);
    checkLookupTemplate(lookup, TestLookupObjectTwo.class, 1);
    
    mp = MimePath.parse("text/xml/text/jsp"); //NOI18N
    lookup = MimeLookup.getLookup(mp);
    checkLookupTemplate(lookup, TestLookupObject.class, 1);
    checkLookupTemplate(lookup, TestLookupObjectTwo.class, 0);

    // testing issue #58941
    TestUtilities.deleteFile(getWorkDir(),
            "Editors/text/jsp/testLookup/org-netbeans-modules-editor-mimelookup-impl-TestLookupObject.instance");
    checkLookupTemplate(lookup, TestLookupObject.class, 0);
    checkLookupTemplate(lookup, TestLookupObjectTwo.class, 0);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MimeLookupTest.java


示例16: getFullMimePath

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
private static MimePath getFullMimePath(Document document, int offset) {
    String langPath = null;

    if (document instanceof AbstractDocument) {
        AbstractDocument adoc = (AbstractDocument)document;
        adoc.readLock();
        try {
            List<TokenSequence<?>> list = TokenHierarchy.get(document).embeddedTokenSequences(offset, true);
            if (list.size() > 1) {
                langPath = list.get(list.size() - 1).languagePath().mimePath();
            }
        } finally {
            adoc.readUnlock();
        }
    }

    if (langPath == null) {
        langPath = NbEditorUtilities.getMimeType(document);
    }

    if (langPath != null) {
        return MimePath.parse(langPath);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:NbGenerateCodeAction.java


示例17: testEvents1

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public void testEvents1() throws Exception {
    Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    L listenerA = new L();
    prefsA.addPreferenceChangeListener(listenerA);

    Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
    L listenerB = new L();
    prefsB.addPreferenceChangeListener(listenerB);
    
    assertNotNull("'simple-value-setting-A' should not be null", prefsA.get("simple-value-setting-A", null));
    assertNotNull("'simple-value-setting-A' should not be null", prefsB.get("simple-value-setting-A", null));
    assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefsB.get("testA-1-setting-1", null));

    assertEquals("There should be no A events", 0, listenerA.count);
    assertEquals("There should be no B events", 0, listenerB.count);
    
    prefsA.put("simple-value-setting-A", "new-value");
    assertEquals("Wrong value for 'simple-value-setting-A'", "new-value", prefsA.get("simple-value-setting-A", null));
    assertEquals("The value for 'simple-value-setting-A' was not propagated", "new-value", prefsB.get("simple-value-setting-A", null));
    
    Thread.sleep(500);
    
    assertEquals("Wrong number of A events", 1, listenerA.count);
    assertEquals("Wrong setting name in the A event", "simple-value-setting-A", listenerA.lastEvent.getKey());
    assertEquals("Wrong setting value in the A event", "new-value", listenerA.lastEvent.getNewValue());
    assertSame("Wrong Preferences instance in the A event", prefsA, listenerA.lastEvent.getNode());
    assertEquals("Wrong number of B events", 1, listenerB.count);
    assertEquals("Wrong setting name in the B event", "simple-value-setting-A", listenerB.lastEvent.getKey());
    assertEquals("Wrong setting value in the B event", "new-value", listenerB.lastEvent.getNewValue());
    assertSame("Wrong Preferences instance in the B event", prefsB, listenerB.lastEvent.getNode());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:PreferencesTest.java


示例18: getTemplateFilters

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public static Collection<? extends CodeTemplateFilter> getTemplateFilters(JTextComponent component, int offset) {
    MimePath mimeType = getFullMimePath(component.getDocument(), offset);
    Collection<? extends CodeTemplateFilter.Factory> filterFactories = 
        MimeLookup.getLookup(mimeType).lookupAll(CodeTemplateFilter.Factory.class);
    
    List<CodeTemplateFilter> result = new ArrayList<CodeTemplateFilter>(filterFactories.size());
    for (CodeTemplateFilter.Factory factory : filterFactories) {
        result.add(factory.createFilter(component, offset));
    }
    return result;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:CodeTemplateManagerOperation.java


示例19: get

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
public static synchronized CodeTemplateManagerOperation get(Document document, int offset) {
    MimePath mimePath = getFullMimePath(document, offset);
    if (mimePath != null) {
        return CodeTemplateManagerOperation.get(mimePath);
    } else {
        return null;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:CodeTemplateManagerOperation.java


示例20: testNotRegisteredClassLookup

import org.netbeans.api.editor.mimelookup.MimePath; //导入依赖的package包/类
/** 
 * Looking up the class that has NOT registered subfolder via Class2LayerFolder.
 * It should be found appropriate mime-type specific folder
 */
public void testNotRegisteredClassLookup() throws IOException {
    MimePath mp = MimePath.get(MimePath.get("text/xml"), "text/html"); //NOI18N
    Lookup lookup = MimeLookup.getLookup(mp);
    checkLookupObject(lookup, StringBuffer.class, true);
    TestUtilities.deleteFile(getWorkDir(),
            "Editors/text/xml/text/html/java-lang-StringBuffer.instance");
    checkLookupObject(lookup, StringBuffer.class, false);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MimeLookupTest.java



注:本文中的org.netbeans.api.editor.mimelookup.MimePath类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EncryptedKeyVersion类代码示例发布时间:2022-05-23
下一篇:
Java VersionMessage类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap