当前位置: 首页>>代码示例>>Java>>正文


Java MimeLookup.lookup方法代码示例

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


在下文中一共展示了MimeLookup.lookup方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPopupItems

import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
private void testPopupItems(MimeLookup lookup, Class[] layerObjects){
    PopupActions actions = (PopupActions) lookup.lookup(PopupActions.class);
    assertTrue("PopupActions should be found", actions != null);
    if (actions != null){
        List popupActions = actions.getPopupActions();
        int popupSize = popupActions.size();
        assertTrue("popupActions count is not the same as etalon action count" +
                "Expecting:"+layerObjects.length+" Found:"+popupSize,
                popupSize == layerObjects.length);
        
        for (int i = 0; i<layerObjects.length; i++){
            Object obj = popupActions.get(i);
            assertTrue("Incorrect sorting or item is missing in the popup menu." +
                    "Expecting:"+layerObjects[i]+" Found:"+obj.getClass(),
                    layerObjects[i].isAssignableFrom(obj.getClass()));
        }   
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:Depr_MimeLookupInheritanceTest.java

示例2: testForChangeInLayer

import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
/** 
 * Issues of changes in layer
 */
public void testForChangeInLayer() throws IOException{
    
    // issue #63338
    // http://www.netbeans.org/issues/show_bug.cgi?id=63338
    // Subj: deadlock during showing annotations
    // fix: deadlock occured in after inproper firing of lookup changed event.
    //      event was fired even in cases, the lookup listener should be quiet.
    MimeLookup lookup = MimeLookup.getMimeLookup("text/jsp"); //NOI18N
    Result result = lookup.lookup(new Template(TestLookupObject.class));
    result.allInstances().size(); // remove this line if issue #60010 is fixed
    LookupListener listener = new LookupListener(){
        public void resultChanged(LookupEvent ev){
            resultChangedCount[0]++;
        }
    };
    result.addLookupListener(listener);
    
    //simulate module installation, new file will be added
    createFile("Editors/text/jsp/testLookup/org-openide-actions-PasteAction.instance"); //NOI18N        

    checkResultChange(0);
    
    TestUtilities.deleteFile(getWorkDir(),
            "Editors/text/jsp/testLookup/org-netbeans-modules-editor-mimelookup-impl-TestLookupObject.instance");

    checkResultChange(1);
    
    result.removeLookupListener(listener);
    resultChangedCount[0] = 0;
    // end of issue #63338 ------------------------------------------------
    
    
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:38,代码来源:IssuesTest.java

示例3: testDoubleItems

import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
/** Issue #72873 
 *  MimeLookup duplicates objects from default mimetype folder
 */
public void testDoubleItems(){
    MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java"); //NOI18N
    Result result = lookup.lookup(new Template(TestLookupObjectTwo.class));
    Collection col = result.allInstances();
    assertTrue(col.size() == 1);
    
    lookup = MimeLookup.getMimeLookup(""); //NOI18N
    result = lookup.lookup(new Template(TestLookupObjectTwo.class));
    col = result.allInstances();
    assertTrue(col.size() == 1);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:IssuesTest.java

示例4: testDynamicChangeInPopupFolders

import org.netbeans.api.editor.mimelookup.MimeLookup; //导入方法依赖的package包/类
/** Testing Base level popup items lookup and sorting */
@RandomlyFails // NB-Core-Build #3718
public void testDynamicChangeInPopupFolders() throws IOException{
    final int resultChangedCount[] = new int[1];
    resultChangedCount[0] = 0;

    MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java").childLookup("text/xml"). //NOI18N
            childLookup("text/html"); //NOI18N
    Lookup.Result result = lookup.lookup(new Template(PopupActions.class));
    result.allInstances(); // remove this line if issue #60010 is fixed
    LookupListener listener = new LookupListener(){
        public void resultChanged(LookupEvent ev){
            resultChangedCount[0]++;
        }
    };
    result.addLookupListener(listener);
    PopupActions actions = (PopupActions) lookup.lookup(PopupActions.class);
    assertTrue("PopupActions should be found", actions != null);
    List popupActions = actions.getPopupActions();
    int size = popupActions.size();
    assertTrue("Number of PopupActions found:"+size+" and should be:"+fsstruct.length, size == fsstruct.length);

    //delete RenameAction
    TestUtilities.deleteFile(getWorkDir(),
            "Editors/text/html/Popup/org-openide-actions-RenameAction.instance");
    checkPopupItemPresence(lookup, RenameAction.class, false);

    // check firing the change
    assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
    resultChangedCount[0] = 0;
    
    //delete base CutAction
    TestUtilities.deleteFile(getWorkDir(),
            "Editors/Popup/org-openide-actions-CutAction.instance");

    checkPopupItemPresence(lookup, CutAction.class, false);

    // check firing the change
    assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
    resultChangedCount[0] = 0;
    
    //simulate module installation, new action will be added
    TestUtilities.createFile(getWorkDir(), 
            "Editors/Popup/org-openide-actions-FindAction.instance"); //NOI18N      

    checkPopupItemPresence(lookup, FindAction.class, true);

    // check firing the change
    assertTrue(("resultChangedCount is:"+resultChangedCount[0]+" instead of 1"),resultChangedCount[0] == 1);
    resultChangedCount[0] = 0;
    
    //simulate module installation, new action will be added
    TestUtilities.createFile(getWorkDir(), 
            "Editors/text/x-java/text/xml/text/html/Popup/org-openide-actions-ReplaceAction.instance"); //NOI18N      

    checkPopupItemPresence(lookup, ReplaceAction.class, true);
    
    //ReplaceAction was created in the uppermost folder
    // let's try it is missing in the lower lookup
    lookup = MimeLookup.getMimeLookup("text/x-java").childLookup("text/xml"); //NOI18N
    checkPopupItemPresence(lookup, ReplaceAction.class, false);        
    checkPopupItemPresence(lookup, FindAction.class, true);
    
    // lookup for ReplaceAction in the folder that doesn't exist
    lookup = MimeLookup.getMimeLookup("text/html"); //NOI18N
    checkPopupItemPresence(lookup, ReplaceAction.class, false); 
    // create folder with ReplaceAction
    TestUtilities.createFile(getWorkDir(), 
            "Editors/text/html/Popup/org-openide-actions-ReplaceAction.instance"); //NOI18N

    checkPopupItemPresence(lookup, ReplaceAction.class, true);
    
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:74,代码来源:Depr_MimeLookupPopupItemsChangeTest.java


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