Java Code Examples for org.openide.util.lookup.Lookups#exclude()

The following examples show how to use org.openide.util.lookup.Lookups#exclude() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BootCPNodeFactory.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static Node jarNode(SourceGroup sg) {
    final Node delegate = PackageView.createPackageView(sg);
    final PathFinder pathFinder = PathFinders.createDelegatingPathFinder(delegate.getLookup().lookup(PathFinder.class));
    final Lookup lkp = new ProxyLookup(
            Lookups.exclude(delegate.getLookup(), PathFinder.class),
            Lookups.singleton(pathFinder));
    return new FilterNode(
            delegate,
            null,
            lkp) {
                @Override
                public Action[] getActions(boolean context) {
                    return new Action[0];
                }
    };

}
 
Example 2
Source File: JavacParserTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testMultiSourceVanilla() throws Exception {
    Lookup noSP = Lookups.exclude(Lookup.getDefault(), JavacParser.SequentialParsing.class);
    GlobalLookup.execute(noSP, () -> {
        try {
            FileObject f1 = createFile("test/Test1.java", "package test; class Test1");
            FileObject f2 = createFile("test/Test2.java", "package test; class Test2{}");
            FileObject f3 = createFile("test/Test3.java", "package test; class Test3{}");

            ClasspathInfo cpInfo = ClasspathInfo.create(f2);
            JavaSource js = JavaSource.create(cpInfo, f2, f3);

            SourceUtilsTestUtil.compileRecursively(sourceRoot);

            js.runUserActionTask(new Task<CompilationController>() {
                TypeElement storedJLObject;
                public void run(CompilationController parameter) throws Exception {
                    assertEquals(Phase.PARSED, parameter.toPhase(Phase.PARSED));
                    assertNotNull(parameter.getCompilationUnit());
                    TypeElement jlObject = parameter.getElements().getTypeElement("java.lang.Object");

                    if (storedJLObject == null) {
                        storedJLObject = jlObject;
                    } else {
                        assertFalse(Objects.equals(storedJLObject, jlObject));
                    }
                }
            }, true);
        } catch (Exception ex) {
            throw new AssertionError(ex);
        }
    });
}
 
Example 3
Source File: ActionFilterNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Lookup createLookup(final Node original, Object... toAdd) {
    final Lookup lookup = original.getLookup();
    final org.netbeans.spi.project.ui.PathFinder pathFinder =
            lookup.lookup(org.netbeans.spi.project.ui.PathFinder.class);
    final Lookup lkp = new ProxyLookup(
            Lookups.exclude(lookup, org.netbeans.spi.project.ui.PathFinder.class),
            Lookups.fixed (toAdd),
            Lookups.singleton(new PathFinder(pathFinder)));
    return lkp;
}
 
Example 4
Source File: EditorTestLookup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void setLookup(Object[] instances, ClassLoader cl, FileObject servicesFolder, Class [] exclude) {
    Lookup metaInfServices = Lookups.metaInfServices(cl);
    if (exclude != null && exclude.length > 0) {
        metaInfServices = Lookups.exclude(metaInfServices, exclude);
    }
    
    DEFAULT_LOOKUP.setLookups(new Lookup[] {
        Lookups.fixed(instances),
        metaInfServices,
        Lookups.singleton(cl),
    });
    
    if (servicesFolder != null) {
        // DataSystems need default repository, which is read from the default lookup.
        // That's why the lookup is set first without the services lookup and then again
        // here with the FolderLookup over the Services folder.
        Lookup services = new FolderLookup(DataFolder.findFolder(servicesFolder)).getLookup();
        if (exclude != null && exclude.length > 0) {
            services = Lookups.exclude(services, exclude);
        }
        
        DEFAULT_LOOKUP.setLookups(new Lookup[] {
            Lookups.fixed(instances),
            metaInfServices,
            Lookups.singleton(cl),
            services
        });
    }
}
 
Example 5
Source File: EditorTestLookup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void setLookup(Object[] instances, ClassLoader cl, FileObject servicesFolder, Class [] exclude) {
    Lookup metaInfServices = Lookups.metaInfServices(cl);
    if (exclude != null && exclude.length > 0) {
        metaInfServices = Lookups.exclude(metaInfServices, exclude);
    }
    
    DEFAULT_LOOKUP.setLookups(new Lookup[] {
        Lookups.fixed(instances),
        metaInfServices,
        Lookups.singleton(cl),
    });
    
    if (servicesFolder != null) {
        // DataSystems need default repository, which is read from the default lookup.
        // That's why the lookup is set first without the services lookup and then again
        // here with the FolderLookup over the Services folder.
        Lookup services = new FolderLookup(DataFolder.findFolder(servicesFolder)).getLookup();
        if (exclude != null && exclude.length > 0) {
            services = Lookups.exclude(services, exclude);
        }
        
        DEFAULT_LOOKUP.setLookups(new Lookup[] {
            Lookups.fixed(instances),
            metaInfServices,
            Lookups.singleton(cl),
            services
        });
    }
}