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


Java FileUtil.refreshFor方法代码示例

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


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

示例1: testExecuteCPOnClassesDir

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testExecuteCPOnClassesDir() throws Exception {
    InstalledFileLocatorImpl.registerDestDir(destDirF);
    TestAntLogger.getDefault().setEnabled(true);
    NbModuleProject prj = TestBase.generateStandaloneModule(getWorkDir(), "testing");
    prj.open();

    FileObject buildScript = prj.getProjectDirectory().getFileObject(GeneratedFilesHelper.BUILD_XML_PATH);
    assertNotNull(buildScript);
    ExecutorTask et = ActionUtils.runTarget(buildScript, new String[]{"compile"}, null);
    et.waitFinished();
    assertEquals("Error during ant ...",0,et.result());
    TestAntLogger.getDefault().setEnabled(false);
    File classesF = prj.getClassesDirectory();
    assertTrue("Classes dir of testing project should exist", classesF.exists());
    FileUtil.refreshFor(classesF); // XXX seems necessary occasionally on deadlock - why?
    FileObject classes = FileUtil.toFileObject(classesF);
    assertNotNull(classes);
    ClassPath cp = ClassPath.getClassPath(classes, ClassPath.EXECUTE);
    assertNotNull("have exec CP for " + classes, cp);
    Set<String> expectedRoots = new TreeSet<String>();
    expectedRoots.add(FileUtil.urlForArchiveOrDir(classesF).toExternalForm());
    assertEquals("right compiled EXECUTE classpath", expectedRoots, urlsOfCp(cp));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ClassPathProviderImplTest.java

示例2: removeRecord

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void removeRecord (List<String> list, String patchName, boolean removePatchFile) {
    for (ListIterator<String> it = list.listIterator(); it.hasNext(); ) {
        String savedPatch = it.next();
        if (savedPatch.startsWith(patchName + SEP)) {
            it.remove();
            if (removePatchFile) {
                Patch patch = Patch.unpack(savedPatch);
                if (patch != null) {
                    File f = patch.getPatchFile();
                    f.delete();
                    FileUtil.refreshFor(f);
                }
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:PatchStorage.java

示例3: persistUser

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public static void persistUser (File root, GitUser author) throws GitException {
    Repository repository = getRepository(root);
    if (repository != null) {
        try {
            StoredConfig config = repository.getConfig();
            config.setString("user", null, "name", author.getName()); //NOI18N
            config.setString("user", null, "email", author.getEmailAddress()); //NOI18N
            try {
                config.save();
                FileUtil.refreshFor(new File(GitUtils.getGitFolderForRoot(root), "config"));
            } catch (IOException ex) {
                throw new GitException(ex);
            }
        } finally {
            repository.close();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:JGitUtils.java

示例4: testRefreshForExternalWithNotExistingParent

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testRefreshForExternalWithNotExistingParent() throws Exception {
    EventsEvaluator fdc = new EventsEvaluator();                        
    try {
        File workDir = getWorkDir();
        File external = new File(workDir, "externalFile");        
        assertFalse(external.exists());
        assertTrue(external.createNewFile());
        fdc.assertDataCreated(0);
        FileUtil.refreshFor(external);        
        fdc.assertDataCreated(0);
    } finally {
        fdc.cleanUp();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:FileObjectFactoryTest.java

示例5: testRefreshForNotExisting

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testRefreshForNotExisting() throws Exception {
    EventsEvaluator fdc = new EventsEvaluator();                                
    try {
        File workDir = getWorkDir();
        File external = new File(workDir, "externalFile");        
        assertFalse(external.exists());
        fdc.assertDataCreated(0);                
        FileUtil.refreshFor(external);                
        fdc.assertDataCreated(0);
    } finally {
        fdc.cleanUp();        
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:FileObjectFactoryTest.java

示例6: testExternalCommandLoggedChanges

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testExternalCommandLoggedChanges () throws Exception {
    Mercurial.getInstance().getMercurialInterceptor().pingRepositoryRootFor(workdir);
    FileChangeAdapter fca = new FileChangeAdapter();
    workdirFO.addRecursiveListener(fca);
    File toAdd = new File(modifiedFile.getParentFile(), "toAdd");
    File toDelete = new File(modifiedFile.getParentFile(), "toDelete");
    toDelete.createNewFile();
    FileUtil.refreshFor(workdir);
    Thread.sleep(11000); // some time for initial scans to finish and event logger to settle down
    File hgFolder = new File(workdir, ".hg");
    final File lockFile = new File(hgFolder, "wlock");
    Logger GESTURES_LOG = Logger.getLogger("org.netbeans.ui.vcs");
    ExternalCommandUsageHandler h = new ExternalCommandUsageHandler();
    GESTURES_LOG.addHandler(h);
    createLockFile(lockFile);
    FileUtil.refreshFor(workdir);
    // modification
    write(modifiedFile, "testExternalCommandLoggedChanges");
    // delete
    toDelete.delete();
    // create
    toAdd.createNewFile();
    FileUtil.refreshFor(workdir);
    pause();        
    lockFile.delete();
    FileUtil.refreshFor(workdir);
    
    h.waitForEvent();
    assertNotNull(h.event);
    assertEquals(1, h.numberOfEvents);
    assertTrue(h.event.time > 0);
    assertEquals("HG", h.event.vcs);
    assertEquals("UNKNOWN", h.event.command);
    assertTrue(h.event.external);
    assertEquals(Long.valueOf(3), h.event.modifications);
    GESTURES_LOG.removeHandler(h);
    workdirFO.removeRecursiveListener(fca);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:ExternalChangesTest.java

示例7: testInvalidClassName

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testInvalidClassName() throws IOException {
    assertNotNull(fm);
    final JavaFileObject fobj = fm.getJavaFileForOutput(StandardLocation.CLASS_OUTPUT, "org.netbeans.java.<any>", JavaFileObject.Kind.CLASS, null);
    assertNotNull(fobj);
    try (OutputStream out = fobj.openOutputStream()) {
        out.write(new byte[]{(byte)0xca,(byte)0xfe,(byte)0xba, (byte) 0xbe});
    }
    wbTx.commit();
    FileUtil.refreshFor(FileUtil.toFile(outCp.getRoots()[0]));
    assertNull(outCp.findResource("org/netbeans/java/<any>.sig"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:OutputFileManagerTest.java

示例8: waitForRefresh

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void waitForRefresh () throws Exception {
    InterceptorRefreshHandler handler = new InterceptorRefreshHandler();
    Mercurial.STATUS_LOG.addHandler(handler);
    FileUtil.refreshFor(workdir);
    for (int i=0; i<20; ++i) {
        Thread.sleep(1000);
        if (handler.refreshed) {
            break;
        }
    }
    if (!handler.refreshed) {
        fail("cache not refresh");
    }
    Mercurial.STATUS_LOG.removeHandler(handler);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ExternalChangesTest.java

示例9: outputLineAction

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@Override
public void outputLineAction(OutputEvent arg0) {
     File javadoc = FileUtil.normalizeFile(new File(root));
     FileUtil.refreshFor(javadoc);
     FileObject fo = FileUtil.toFileObject(javadoc);
     if (fo != null) {
         FileObject index = fo.getFileObject("index.html"); //NOI18N
         if (index != null) {
             URL link = URLMapper.findURL(index, URLMapper.EXTERNAL);
             HtmlBrowser.URLDisplayer.getDefault().showURL(link);
         }
     }
 }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:JavadocOutputProcessor.java

示例10: verifyContent

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
protected void verifyContent(FileObject sourceRoot, File... files) throws Exception {
    List<FileObject> todo = new LinkedList<FileObject>();

    todo.add(sourceRoot);

    Map<String, String> content = new HashMap<String, String>();

    FileUtil.refreshFor(FileUtil.toFile(sourceRoot));

    while (!todo.isEmpty()) {
        FileObject file = todo.remove(0);

        if (file.isData()) {
            content.put(FileUtil.getRelativePath(sourceRoot, file), copyFileToString(FileUtil.toFile(file)));
        } else {
            todo.addAll(Arrays.asList(file.getChildren()));
        }
    }

    for (File f : files) {
        String fileContent = content.remove(f.filename);

        assertNotNull(f);
        assertNotNull(f.content);
        assertNotNull("Cannot find " + f.filename + " in map " + content, fileContent);
        assertEquals(getName() ,f.content.replaceAll("[ \t\r\n\n]+", " "), fileContent.replaceAll("[ \t\r\n\n]+", " "));
    }

    assertTrue(content.toString(), content.isEmpty());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:RefactoringTestBase.java

示例11: testLogExtCmdChanges

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
@RandomlyFails
public void testLogExtCmdChanges () throws Exception {
    waitForInitialScan();
    FileChangeAdapter fca = new FileChangeAdapter();
    workdirFO.addRecursiveListener(fca);
    final File toAdd = new File(modifiedFile.getParentFile(), "toAdd");
    File toDelete = new File(modifiedFile.getParentFile(), "toDelete");
    toDelete.createNewFile();
    FileUtil.refreshFor(repositoryLocation);
    Thread.sleep(11000); // some time for initial scans to finish and event logger to settle down
    File gitFolder = new File(repositoryLocation, ".git");
    final File lockFile = new File(gitFolder, "index.lock");
    
    Logger.getLogger(FilesystemInterceptor.class.getName()).setLevel(Level.ALL);
    ConsoleHandler ch = new ConsoleHandler();
    ch.setLevel(Level.ALL);
    Logger.getLogger(FilesystemInterceptor.class.getName()).addHandler(ch);
    
    assertTrue(lockFile.createNewFile());
    FileUtil.refreshFor(repositoryLocation);
    pause();
    Thread.sleep(1100);
    assertTrue(lockFile.delete());
    FileUtil.refreshFor(repositoryLocation);
    Thread.sleep(1100);
    
    Logger GESTURES_LOG = Logger.getLogger("org.netbeans.ui.vcs");
    ExternalCommandUsageHandler h = new ExternalCommandUsageHandler();
    GESTURES_LOG.addHandler(h);
    assertTrue(lockFile.createNewFile());
    FileUtil.refreshFor(repositoryLocation);
    // modification
    write(modifiedFile, "testExternalCommandLoggedChanges");
    // delete
    toDelete.delete();
    // create
    toAdd.createNewFile();
    FileUtil.refreshFor(repositoryLocation);
    pause();
    Thread.sleep(1100);
    assertTrue(lockFile.delete());
    FileUtil.refreshFor(repositoryLocation);
    
    h.waitForEvent();
    assertNotNull(h.event);
    assertEquals(1, h.numberOfEvents);
    assertTrue(h.event.time > 0);
    assertEquals("GIT", h.event.vcs);
    assertEquals("UNKNOWN", h.event.command);
    assertTrue(h.event.external);
    assertEquals(Long.valueOf(3), h.event.modifications);
    GESTURES_LOG.removeHandler(h);
    workdirFO.removeRecursiveListener(fca);
    Logger.getLogger(FilesystemInterceptor.class.getName()).removeHandler(ch);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:ExternalChangesTest.java

示例12: waitForRefresh

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void waitForRefresh () throws Exception {
    InterceptorRefreshHandler handler = new InterceptorRefreshHandler();
    Git.STATUS_LOG.addHandler(handler);
    FileUtil.refreshFor(repositoryLocation);
    for (int i=0; i<20; ++i) {
        Thread.sleep(1000);
        if (handler.refreshed) {
            break;
        }
    }
    if (!handler.refreshed) {
        fail("cache not refreshed");
    }
    Git.STATUS_LOG.removeHandler(handler);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:ExternalChangesTest.java

示例13: performEnabledTest

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void performEnabledTest(String test, final boolean onlyHeader, final boolean golden) throws Exception {
    clearWorkDir();

    String[] parts = test.split(Pattern.quote("|"));
    final int start, end;

    if (parts.length == 2) {
        start = end = parts[0].length();
        test = parts[0] + parts[1];
    } else {
        start = parts[0].length();
        end   = start + parts[1].length();
        test = parts[0] + parts[1] + parts[2];
    }

    FileUtil.refreshFor(getWorkDir());

    FileObject wd = FileUtil.toFileObject(getWorkDir());
    FileObject src = FileUtil.createFolder(wd, "src");
    FileObject build = FileUtil.createFolder(wd, "build");
    FileObject cache = FileUtil.createFolder(wd, "cache");

    SourceUtilsTestUtil.prepareTest(src, build, cache);

    FileObject testFile = FileUtil.createData(src, "Test.java");

    TestUtilities.copyStringToFile(testFile, test);

    JavaSource testSource = JavaSource.forFileObject(testFile);
    Task task = new Task<WorkingCopy>() {
        public void run(WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);

            assertEquals(golden, ConvertAnonymousToInner.computeFix(workingCopy, start, end, onlyHeader) != null);
        }

    };
    testSource.runModificationTask(task).commit();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:40,代码来源:ConvertAnonymousToInnerTest.java

示例14: testInternalCommandLoggedChanges

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testInternalCommandLoggedChanges () throws Exception {
    Mercurial.getInstance().getMercurialInterceptor().pingRepositoryRootFor(workdir);
    FileChangeAdapter fca = new FileChangeAdapter();
    workdirFO.addRecursiveListener(fca);
    final File toAdd = new File(modifiedFile.getParentFile(), "toAdd");
    final File toDelete = new File(modifiedFile.getParentFile(), "toDelete");
    toDelete.createNewFile();
    FileUtil.refreshFor(workdir);
    Thread.sleep(11000); // some time for initial scans to finish and event logger to settle down
    File hgFolder = new File(workdir, ".hg");
    final File lockFile = new File(hgFolder, "wlock");
    Logger GESTURES_LOG = Logger.getLogger("org.netbeans.ui.vcs");
    ExternalCommandUsageHandler h = new ExternalCommandUsageHandler();
    GESTURES_LOG.addHandler(h);
    Mercurial.getInstance().runWithoutExternalEvents(workdir, "MY_COMMAND", new Callable<Void>() {
        @Override
        public Void call () throws Exception {
            createLockFile(lockFile);
            FileUtil.refreshFor(workdir);
            // modification
            write(modifiedFile, "testExternalCommandLoggedChanges");
            // delete
            toDelete.delete();
            // create
            toAdd.createNewFile();
            FileUtil.refreshFor(workdir);
            pause();
            lockFile.delete();
            FileUtil.refreshFor(workdir);
            return null;
        }
    });
    h.waitForEvent();
    assertNotNull(h.event);
    assertEquals(1, h.numberOfEvents);
    assertTrue(h.event.time > 0);
    assertEquals("HG", h.event.vcs);
    assertFalse(h.event.external);
    assertEquals("MY_COMMAND", h.event.command);
    assertEquals(Long.valueOf(3), h.event.modifications);
    GESTURES_LOG.removeHandler(h);
    workdirFO.removeRecursiveListener(fca);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:ExternalChangesTest.java

示例15: testLogIntCmd

import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
public void testLogIntCmd () throws Exception {
    waitForInitialScan();
    FileChangeAdapter fca = new FileChangeAdapter();
    workdirFO.addRecursiveListener(fca);
    final File toAdd = new File(modifiedFile.getParentFile(), "toAdd");
    final File toDelete = new File(modifiedFile.getParentFile(), "toDelete");
    toDelete.createNewFile();
    FileUtil.refreshFor(repositoryLocation);
    Thread.sleep(11000); // some time for initial scans to finish and event logger to settle down
    File gitFolder = new File(repositoryLocation, ".git");
    final File lockFile = new File(gitFolder, "index.lock");
    Logger GESTURES_LOG = Logger.getLogger("org.netbeans.ui.vcs");
    ExternalCommandUsageHandler h = new ExternalCommandUsageHandler();
    GESTURES_LOG.addHandler(h);
    Git.getInstance().runWithoutExternalEvents(repositoryLocation, "MY_COMMAND", new Callable<Void>() {
        @Override
        public Void call () throws Exception {
            lockFile.createNewFile();
            FileUtil.refreshFor(repositoryLocation);
            // modification
            write(modifiedFile, "testExternalCommandLoggedChanges");
            // delete
            toDelete.delete();
            // create
            toAdd.createNewFile();
            FileUtil.refreshFor(repositoryLocation);
            pause();
            lockFile.delete();
            FileUtil.refreshFor(repositoryLocation);
            return null;
        }
    });
    h.waitForEvent();
    assertNotNull(h.event);
    assertEquals(1, h.numberOfEvents);
    assertTrue(h.event.time > 0);
    assertEquals("GIT", h.event.vcs);
    assertFalse(h.event.external);
    assertEquals("MY_COMMAND", h.event.command);
    assertEquals(Long.valueOf(3), h.event.modifications);
    GESTURES_LOG.removeHandler(h);
    workdirFO.removeRecursiveListener(fca);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:ExternalChangesTest.java


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