Java Code Examples for org.openide.filesystems.FileObject.addRecursiveListener()

The following are Jave code examples for showing how to use addRecursiveListener() of the org.openide.filesystems.FileObject class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: SourceMapsScanner.java   View Source Code Vote up 6 votes
void init(Project p) {
    Sources sources = ProjectUtils.getSources(p);
    sources.addChangeListener(this);
    SourceGroup[] groups = sources.getSourceGroups(Sources.TYPE_GENERIC);
    roots = new FileObject[groups.length];
    for (int i = 0; i < groups.length; i++) {
        SourceGroup group = groups[i];
        FileObject rootFolder = group.getRootFolder();
        roots[i] = rootFolder;
        rootFolder.addRecursiveListener(this);
        //scan(rootFolder);
        rootsToScan.add(rootFolder);
    }
    scanningTask = RP.post(this);
    DependencyProjectProvider prov = p.getLookup().lookup(DependencyProjectProvider.class);
    if (prov != null) {
        projectDependencyManager = new ProjectDependencyManager(prov);
    }
}
 
Example 2
Project: incubator-netbeans   File: VCSInterceptorTest.java   View Source Code Vote up 5 votes
public void testRefreshRecursively() throws IOException {
    File f = new File(dataRootDir, "workdir/root-test-versioned");
    f.mkdirs();
    FileObject fo = FileUtil.toFileObject(f);
    fo = fo.createFolder("folder");
    fo.addRecursiveListener(new FileChangeAdapter());
    assertTrue(inteceptor.getRefreshRecursivelyFiles().contains(FileUtil.toFile(fo)));     
}
 
Example 3
Project: incubator-netbeans   File: FileUtilAddRecursiveListenerTest.java   View Source Code Vote up 5 votes
public void testProvideExtensionsRefreshRecursively() throws Exception {
    File root = new File(getWorkDir(), "root");
    final File sub = new File(root, "sub");
    final File subsub = new File(sub, "subsub");
    File subsubdir = new File(subsub, "dir");
    subsubdir.mkdirs();
    File subfile = new File(sub, "file");
    subfile.createNewFile();
    File deepfile = new File(subsubdir, "deep");
    deepfile.createNewFile();

    ProvidedExtensionsTest.ProvidedExtensionsImpl.nextRefreshCall(
        sub,
        Long.MAX_VALUE - 10,
        subfile
    );


    TestFileChangeListener fcl = new TestFileChangeListener();
    FileObject rf = FileUtil.toFileObject(root);
    rf.addRecursiveListener(fcl);

    BaseFileObj noFO = FileObjectFactory.getInstance(root).getCachedOnly(subsubdir);
    assertNull("subsub directory has been skipped", noFO);

    assertEquals("No events", 0, fcl.checkAll());
    LOG.log(Level.INFO, "Touching subfile: {0}", deepfile);
    TestFileUtils.touch(deepfile, null);
    LOG.log(Level.INFO, "Will do refresh, lastModified: {0}", deepfile.lastModified());
    FileUtil.refreshFor(root);
    LOG.info("Refresh done");
    fcl.check(EventType.ATTRIBUTE_CHANGED); // ignore if any

    fcl.printAll(LOG);
    assertEquals("No other events", 0, fcl.checkAll());
}
 
Example 4
Project: incubator-netbeans   File: VCSInterceptorTestCase.java   View Source Code Vote up 5 votes
public void testRefreshRecursively() throws IOException {
    FileObject fo = getVersionedFolder();
    fo = fo.createFolder("folder");
    VCSFileProxy proxy = VCSFileProxy.createFileProxy(fo);
    logHandler.clear();
    
    fo.addRecursiveListener(new FileChangeAdapter()); 
    assertTrue(inteceptor.getRefreshRecursivelyFiles().contains(VCSFileProxy.createFileProxy(fo)));     
    
    // XXX listFiles called twice on adding the listener. is this realy necessary
    assertInterceptedCalls(
        1, 2, 
        f(listFilesFormat, proxy)
    );            
}