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


Java Lookup.lookupAll方法代码示例

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


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

示例1: canFindUsages

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
public boolean canFindUsages(Lookup lookup) {
    Collection<? extends Node> nodes = new HashSet<Node>(lookup.lookupAll(Node.class));
    if (nodes.size() != 1) {
        return false;
    }
    Node n = nodes.iterator().next();
    TreePathHandle handle;
    if ((handle = n.getLookup().lookup(TreePathHandle.class)) != null && handle.getFileObject() != null) {
        return true;
    }
    DataObject dob = n.getLookup().lookup(DataObject.class);
    if ((dob!=null) && RefactoringUtils.isJavaFile(dob.getPrimaryFile()) && !"package-info".equals(dob.getName())) { //NOI18N
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RefactoringActionsProvider.java

示例2: checkRemovingMimeDataProvider

import org.openide.util.Lookup; //导入方法依赖的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

示例3: testHierarchyInheritance

import org.openide.util.Lookup; //导入方法依赖的package包/类
public void testHierarchyInheritance() throws Exception {
    // Create the mime path folders and add some instance
    TestUtilities.createFile(getWorkDir(), "Editors/text/x-java/org-netbeans-modules-editor-mimelookup-impl-DummySettingImpl.instance");
    TestUtilities.createFile(getWorkDir(), "Editors/text/x-jsp/text/x-java/");
    TestUtilities.sleepForWhile();

    {
        Lookup javaLookup = new SwitchLookup(MimePath.parse("text/x-java"));
        Collection javaInstances = javaLookup.lookupAll(DummySetting.class);
        assertEquals("Wrong number of instances", 1, javaInstances.size());
        assertEquals("Wrong instance", DummySettingImpl.class, javaInstances.iterator().next().getClass());
    }
    
    {
        Lookup jspJavaLookup = new SwitchLookup(MimePath.parse("text/x-jsp/text/x-java"));
        Collection jspJavaInstances = jspJavaLookup.lookupAll(DummySetting.class);
        assertEquals("Wrong number of instances", 1, jspJavaInstances.size());
        assertEquals("Wrong instance", DummySettingImpl.class, jspJavaInstances.iterator().next().getClass());
}
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:SwitchLookupTest.java

示例4: testOrdering

import org.openide.util.Lookup; //导入方法依赖的package包/类
public void testOrdering() throws Exception {
    Lookup l = getTestedLookup(c1);
    Class<?> xface = c1.loadClass("java.util.Comparator");
    List<?> results = new ArrayList<Object>(l.lookupAll(xface));
    assertEquals(1, results.size());

    l = getTestedLookup(c2);
    xface = c2.loadClass("java.util.Comparator");
    results = new ArrayList<Object>(l.lookupAll(xface));
    assertEquals(2, results.size());
    // Test order:
    assertEquals("org.bar.Comparator2", results.get(0).getClass().getName());
    assertEquals("org.foo.impl.Comparator1", results.get(1).getClass().getName());

    // test that items without position are always at the end
    l = getTestedLookup(c2);
    xface = c2.loadClass("java.util.Iterator");
    results = new ArrayList<Object>(l.lookupAll(xface));
    assertEquals(2, results.size());
    // Test order:
    assertEquals("org.bar.Iterator2", results.get(0).getClass().getName());
    assertEquals("org.foo.impl.Iterator1", results.get(1).getClass().getName());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:MetaInfServicesLookupTest.java

示例5: testWhiteListLookup

import org.openide.util.Lookup; //导入方法依赖的package包/类
public void testWhiteListLookup() throws Exception {
    createWhiteListsFolder(Query1.class, Query2.class);
    final FileObject home = FileUtil.toFileObject(getWorkDir());
    final Project p = new MockProject(home);
    Lookup lkp = WhiteListLookupProvider.getEnabledUserSelectableWhiteLists(p);
    assertNotNull(lkp);
    assertTrue(lkp.lookupAll(WhiteListQueryImplementation.class).isEmpty());
    WhiteListLookupProvider.enableWhiteListInProject(p, Query1.class.getSimpleName(), true);
    Collection<? extends WhiteListQueryImplementation> items = lkp.lookupAll(WhiteListQueryImplementation.class);
    assertEquals(1,items.size());
    assertEquals(Query1.class,items.iterator().next().getClass());
    final Reference<Lookup> wr = new WeakReference<Lookup>(lkp);
    lkp = null;
    assertGC("Lookup gced", wr);    //NOI18N
    lkp = WhiteListLookupProvider.getEnabledUserSelectableWhiteLists(p);
    assertNotNull(lkp);
    items = lkp.lookupAll(WhiteListQueryImplementation.UserSelectable.class);
    assertEquals(1,items.size());
    assertEquals(Query1.class,items.iterator().next().getClass());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:WhiteListCategoryPanelTest.java

示例6: createContextAwareInstance

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
public Action createContextAwareInstance(Lookup actionContext) {
    if (!ProfilingPointsManager.getDefault().isProfilingSessionInProgress()) {
        Collection<? extends CodeProfilingPoint.Annotation> anns = actionContext.lookupAll(CodeProfilingPoint.Annotation.class);
        if (anns.size() == 1) {
            final CodeProfilingPoint pp = anns.iterator().next().profilingPoint();
            return new AbstractAction(getName()) {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    pp.customize(false, true);
                }
            };
        }
    }
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CustomizeProfilingPointAction.java

示例7: createContextAwareInstance

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
public Action createContextAwareInstance(Lookup actionContext) {
    if (!ProfilingPointsManager.getDefault().isProfilingSessionInProgress()) {
        Collection<? extends CodeProfilingPoint.Annotation> anns = actionContext.lookupAll(CodeProfilingPoint.Annotation.class);
        if (anns.size() == 1) {
            final CodeProfilingPoint pp = anns.iterator().next().profilingPoint();
            return new AbstractAction(getName()) {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    ProfilingPointsManager.getDefault().removeProfilingPoint(pp);
                }
            };
        }
    }
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:DeleteProfilingPointAction.java

示例8: testBasicUsage

import org.openide.util.Lookup; //导入方法依赖的package包/类
public void testBasicUsage() throws Exception {
    Lookup l = getTestedLookup(c2);
    Class<?> xface = c1.loadClass("org.foo.Interface");
    NoChange nc = new NoChange(l, xface);
    LOG.log(Level.INFO, "tested lookup: {0}", l);
    LOG.log(Level.INFO, "search for {0}", xface);
    List<?> results = new ArrayList<Object>(l.lookupAll(xface));
    LOG.log(Level.INFO, "results: {0}", results);
    assertEquals("Two items in result: " + results, 2, results.size());
    // Note that they have to be in order:
    assertEquals("org.foo.impl.Implementation1", results.get(0).getClass().getName());
    assertEquals("org.bar.Implementation2", results.get(1).getClass().getName());
    // Make sure it does not gratuitously replace items:
    List<?> results2 = new ArrayList<Object>(l.lookupAll(xface));
    assertEquals(results, results2);
    nc.waitNoChange();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MetaInfServicesLookupTest.java

示例9: canRefactor

import org.openide.util.Lookup; //导入方法依赖的package包/类
private static boolean canRefactor(Lookup lookup) {
    Collection<? extends Node> nodes = lookup.lookupAll(Node.class);
    if (nodes.size() != 1) {
        return false;
    }
    Node node = nodes.iterator().next();

    //can refactor only in less/sass files
    FileObject file = getFileObjectFromNode(node);
    if (file != null) {
        String mimeType = file.getMIMEType();
        if (LessLanguage.getLanguageInstance().mimeType().equals(mimeType) || ScssLanguage.getLanguageInstance().mimeType().equals(mimeType)) {
            return isRefactorableEditorElement(node);
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:CPActionsImplementationProvider.java

示例10: ContextAction

import org.openide.util.Lookup; //导入方法依赖的package包/类
public ContextAction(Lookup lkp) {
    super(Bundle.LBL_run_targets_action());
    Collection<? extends AntProjectCookie> apcs = lkp.lookupAll(AntProjectCookie.class);
    AntProjectCookie _project = null;
    if (apcs.size() == 1) {
        _project = apcs.iterator().next();
        if (_project.getParseException() != null) {
            _project = null;
        }
    }
    project = _project;
    super.setEnabled(project != null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:RunTargetsAction.java

示例11: canCopy

import org.openide.util.Lookup; //导入方法依赖的package包/类
/**
 * returns true if there is at least one java file in the selection
 * and all java files are refactorable
 */
@Override
public boolean canCopy(Lookup lookup) {
    Collection<? extends Node> nodes = new HashSet<Node>(lookup.lookupAll(Node.class));
    FileObject fo = getTarget(lookup);
    if (fo != null) {
        if (!fo.isFolder()) {
            return false;
        }
        if (!JavaRefactoringUtils.isOnSourceClasspath(fo)) {
            return false;
        }
    }
    boolean result = true;
    boolean hasJava = false;
    for (Node n:nodes) {
        DataObject dob = n.getLookup().lookup(DataObject.class);
        if (dob == null || dob.getPrimaryFile().isFolder()) {
            result = false;
            break;
        }
        if (RefactoringUtils.isJavaFile(dob.getPrimaryFile())) {
            hasJava = true;
            if(ClassPath.getClassPath(dob.getPrimaryFile(), ClassPath.SOURCE) == null) {
                result = false;
                break;
            }
        }
    }
    return result && hasJava;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:RefactoringActionsProvider.java

示例12: checkCopy

import org.openide.util.Lookup; //导入方法依赖的package包/类
private boolean checkCopy(Lookup object) {
    Collection<? extends FileObject> fileObjects = object.lookupAll(FileObject.class);
    for (FileObject f : fileObjects) {
        if (f != null && RefactoringUtils.isJavaFile(f)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:JavaRefactoringsFactory.java

示例13: doFindUsages

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
public void doFindUsages(final Lookup lookup) {
    if(canFindUsages(lookup)){
        if(canRename(lookup)) {
        Runnable task = new NodeToFileObjectTask(lookup.lookupAll(Node.class)) {

            @Override
            protected RefactoringUI createRefactoringUI(FileObject[] fileObjects) {
                return new HibernateMappingWhereUsedQueryUI(fileObjects[0]);
            }
        };
        task.run();
    }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:HibernateMappingRefactoringActionsProvider.java

示例14: getProjectDirectories

import org.openide.util.Lookup; //导入方法依赖的package包/类
public FileObject[] getProjectDirectories(Lookup lookup) {
    Collection<? extends Project> projects = lookup.lookupAll(Project.class);
    if(projects == null) {
        return null;
    }
    List<FileObject> ret = new ArrayList<FileObject>();
    for (Project project : projects) {
        ret.add(project.getProjectDirectory());
    }
    return ret.toArray(new FileObject[ret.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ProjectServicesImpl.java

示例15: createContextAwareInstance

import org.openide.util.Lookup; //导入方法依赖的package包/类
@Override
public Action createContextAwareInstance(Lookup actionContext) {
    if (!ProfilingPointsManager.getDefault().isProfilingSessionInProgress()) {
        Collection<? extends CodeProfilingPoint.Annotation> anns = actionContext.lookupAll(CodeProfilingPoint.Annotation.class);
        final InvocationLocationDescriptor desc = getCurrentLocationDescriptor(anns);
        if (desc != null) {
            String name = desc.isStartLocation() ? 
                Bundle.ShowOppositeProfilingPointAction_EndActionName() : 
                    Bundle.ShowOppositeProfilingPointAction_StartActionName();

            return new AbstractAction(name) {

                @Override
                public void actionPerformed(ActionEvent ae) {
                    CodeProfilingPoint.Location oppositeLocation = desc.getOppositeLocation();

                    if (oppositeLocation != null) {
                        Utils.openLocation(oppositeLocation);
                    } else {
                        ProfilerDialogs.displayWarning(
                                Bundle.ShowOppositeProfilingPointAction_NoEndDefinedMsg());
                    }
                }
            };
        }
    }
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:ShowOppositeProfilingPointAction.java


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