Java Code Examples for org.openide.filesystems.FileUtil#refreshAll()
The following examples show how to use
org.openide.filesystems.FileUtil#refreshAll() .
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: JavaDataLoaderTest.java From netbeans with Apache License 2.0 | 6 votes |
public void testMimeTypeBasedRecognition180478() throws Exception { clearWorkDir(); FileUtil.refreshAll(); MockServices.setServices(JavaDataLoader.class); FileUtil.setMIMEType("bbb", "text/x-java"); File wd = getWorkDir(); new FileOutputStream(new File(wd, "Test.java")).close(); new FileOutputStream(new File(wd, "Test.bbb")).close(); FileUtil.refreshAll(); FileObject f = FileUtil.toFileObject(wd); DataFolder df = DataFolder.findFolder(f); DataObject[] children = df.getChildren(); assertEquals(2, children.length); assertEquals(JavaDataObject.class, children[0].getClass()); assertEquals(JavaDataObject.class, children[1].getClass()); }
Example 2
Source File: JavaDataLoaderTest.java From netbeans with Apache License 2.0 | 6 votes |
private void recognize(int count) throws IOException { clearWorkDir(); FileUtil.refreshAll(); File wd = getWorkDir(); while (count-- > 0) { new FileOutputStream(new File(wd, "f" + count + ".java")).close(); new FileOutputStream(new File(wd, "f" + count + ".bbb")).close(); } long s = System.currentTimeMillis(); FileUtil.refreshAll(); FileObject f = FileUtil.toFileObject(wd); DataFolder df = DataFolder.findFolder(f); System.err.println("preparation took: " + (System.currentTimeMillis() - s)); System.err.println(df.getChildren().length); System.err.println("recognition took:" + (System.currentTimeMillis() - s)); }
Example 3
Source File: DeployOnSaveManager.java From netbeans with Apache License 2.0 | 6 votes |
public void resumeListening(final J2eeModuleProvider provider) { boolean resume = false; synchronized (this) { resume = suspended.containsKey(provider); } // don't do resume unless it is really needed if (resume) { FileObject fo = ((ConfigSupportImpl) provider.getConfigSupport()).getProjectDirectory(); FileUtil.refreshAll(); try { FileSystem fs = (fo != null) ? fo.getFileSystem() : FileUtil.getConfigRoot().getFileSystem(); fs.runAtomicAction(new FileSystem.AtomicAction() { @Override public void run() throws IOException { clearSuspended(provider); } }); } catch (IOException ex) { LOGGER.log(Level.INFO, null, ex); clearSuspended(provider); } } }
Example 4
Source File: PHPNavTestBase.java From netbeans with Apache License 2.0 | 6 votes |
protected void performTest(String[] code, final UserTask task, boolean waitFinished) throws Exception { FileUtil.refreshAll(); FileObject workDir = FileUtil.toFileObject(getWorkDir()); FileObject folder = workDir.createFolder("src"); int index = -1; for (String c : code) { FileObject f = FileUtil.createData(folder, computeFileName(index)); TestUtilities.copyStringToFile(f, c); index++; } final FileObject test = folder.getFileObject("test.php"); Source testSource = getTestSource(test); if (waitFinished) { Future<Void> parseWhenScanFinished = ParserManager.parseWhenScanFinished(Collections.singleton(testSource), task); parseWhenScanFinished.get(); } else { ParserManager.parse(Collections.singleton(testSource), task); } }
Example 5
Source File: AuxiliaryConfigBasedPreferencesProviderTest.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected void setUp() throws Exception { MockLookup.setInstances(TestUtil.testProjectFactory()); clearWorkDir(); File wd = getWorkDir(); FileUtil.refreshAll(); File f = new File(new File(wd, "test"), "testproject"); FileObject testprojectFO = FileUtil.createFolder(f); assertNotNull(testprojectFO); fo = testprojectFO.getParent(); TestUtil.LOOKUP = lookup = new TestLookup(); p = ProjectManager.getDefault().findProject(fo); assertNotNull(p); }
Example 6
Source File: BridgeImpl.java From netbeans with Apache License 2.0 | 4 votes |
public @Override void run() { LOG.log(Level.FINE, "Refreshing filesystems"); FileUtil.refreshAll(); }
Example 7
Source File: ElementHeadersTest.java From netbeans with Apache License 2.0 | 3 votes |
private void prepareTest(String fileName, String code) throws Exception { clearWorkDir(); FileUtil.refreshAll(); FileObject workFO = FileUtil.toFileObject(getWorkDir()); assertNotNull(workFO); sourceRoot = workFO.createFolder("src"); FileObject buildRoot = workFO.createFolder("build"); FileObject cache = workFO.createFolder("cache"); FileObject data = FileUtil.createData(sourceRoot, fileName); File dataFile = FileUtil.toFile(data); assertNotNull(dataFile); TestUtilities.copyStringToFile(dataFile, code); SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cache); DataObject od = DataObject.find(data); EditorCookie ec = od.getCookie(EditorCookie.class); assertNotNull(ec); doc = ec.openDocument(); doc.putProperty(Language.class, JavaTokenId.language()); JavaSource js = JavaSource.forFileObject(data); assertNotNull(js); info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED); assertNotNull(info); }
Example 8
Source File: ComputeImportsTest.java From netbeans with Apache License 2.0 | 3 votes |
private void prepareTest(String capitalizedName, String sourceLevel, Iterable<FileData> files) throws Exception { FileObject workFO = FileUtil.toFileObject(getWorkDir()); assertNotNull(workFO); FileObject sourceRoot = workFO.createFolder("src"); FileObject buildRoot = workFO.createFolder("build"); // FileObject cache = workFO.createFolder("cache"); SourceUtilsTestUtil.prepareTest(sourceRoot, buildRoot, cacheFO); for (FileData fd : files) { FileObject target = FileUtil.createData(sourceRoot, fd.fileName); try (OutputStream out = target.getOutputStream(); Writer w = new OutputStreamWriter(out, StandardCharsets.UTF_8)) { w.write(fd.content); } } FileUtil.refreshAll(); SourceUtilsTestUtil.compileRecursively(sourceRoot); testSource = sourceRoot.getFileObject(capitalizedName + ".java"); assertNotNull(testSource); SourceUtilsTestUtil.setSourceLevel(testSource, sourceLevel); js = JavaSource.forFileObject(testSource); assertNotNull(js); info = SourceUtilsTestUtil.getCompilationInfo(js, Phase.RESOLVED); assertNotNull(info); }