當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。