diff -r a9a11cf8e0d9 -r 9a7e19e453c2 openide.filesystems/apichanges.xml
--- a/openide.filesystems/apichanges.xml Mon Feb 25 12:50:57 2008 +0100
+++ b/openide.filesystems/apichanges.xml Mon Feb 25 15:34:15 2008 +0100
@@ -46,6 +46,29 @@ made subject to such option by the copyr
Filesystems API
+
+
+ Add methods: addFileChangesListener, removeFileChangesListener, refreshAll
+
+
+
+
+
+ Added utility methods:
+
+ public static FileObject addFileChangeListener (final FileChangeListeners fcl)
to receive
+ FileEvents
from FileSystems
providing instances
+ of FileObject
convertible to java.io.File
+ public static FileObject removeFileChangeListener (final FileChangeListeners fcl)
to no longer receive
+ FileEvents
from FileSystems
providing instances
+ of FileObject
convertible to java.io.File
+ public static FileObject refreshAll ()
to refreshes all FileObject
that represent files File.listRoots()
+ and their children recursively.
+
+
+
+
+
Add method FileUtil.refreshFor(File... files)
diff -r a9a11cf8e0d9 -r 9a7e19e453c2 openide.filesystems/manifest.mf
--- a/openide.filesystems/manifest.mf Mon Feb 25 12:50:57 2008 +0100
+++ b/openide.filesystems/manifest.mf Mon Feb 25 15:34:15 2008 +0100
@@ -1,5 +1,5 @@ Manifest-Version: 1.0
Manifest-Version: 1.0
OpenIDE-Module: org.openide.filesystems
-OpenIDE-Module-Specification-Version: 7.6
+OpenIDE-Module-Specification-Version: 7.7
OpenIDE-Module-Localizing-Bundle: org/openide/filesystems/Bundle.properties
diff -r a9a11cf8e0d9 -r 9a7e19e453c2 openide.filesystems/src/org/openide/filesystems/FileUtil.java
--- a/openide.filesystems/src/org/openide/filesystems/FileUtil.java Mon Feb 25 12:50:57 2008 +0100
+++ b/openide.filesystems/src/org/openide/filesystems/FileUtil.java Mon Feb 25 15:34:15 2008 +0100
@@ -123,6 +123,20 @@ public final class FileUtil extends Obje
private static final Map archiveFileCache = new WeakHashMap();
private static FileSystem diskFileSystem;
+ private static FileSystem getDiskFileSystem(File... files) {
+ FileSystem fs = getDiskFileSystem();
+ if (fs == null) {
+ for (File file : files) {
+ FileObject fo = toFileObject(file);
+ fs = getDiskFileSystem();
+ if (fs != null) {
+ break;
+ }
+ }
+ }
+ return fs;
+ }
+
private FileUtil() {
}
@@ -133,16 +147,7 @@ public final class FileUtil extends Obje
* @since 7.6
*/
public static void refreshFor(File... files) {
- FileSystem fs = getDiskFileSystem();
- if (fs == null) {
- for (File file : files) {
- FileObject fo = toFileObject(file);
- fs = getDiskFileSystem();
- if (fs != null) {
- break;
- }
- }
- }
+ FileSystem fs = getDiskFileSystem(files);
if (fs != null) {
try {
fs.getRoot().setAttribute("request_for_refreshing_files_be_aware_this_is_not_public_api", files);
@@ -151,6 +156,48 @@ public final class FileUtil extends Obje
}
}
}
+
+ /**
+ * Refreshes all FileObject
that represent files File.listRoots()
+ * and their children recursively.
+ * @since 7.7
+ */
+ public static void refreshAll() {
+ refreshFor(File.listRoots());
+ }
+
+ /**
+ * Registers listener
so that it will receive
+ * FileEvents
from FileSystems
providing instances
+ * of FileObject
convertible to java.io.File
.
+ * @param fcl
+ * @see #toFileObject
+ * @since 7.7
+ */
+ public static void addFileChangeListener(FileChangeListener fcl) {
+ FileSystem fs = getDiskFileSystem();
+ if (fs == null) {fs = getDiskFileSystem(File.listRoots());}
+ if (fs != null) {
+ fs.addFileChangeListener(fcl);
+ }
+ }
+
+ /**
+ * Unregisters listener
so that it will no longer receive
+ * FileEvents
from FileSystems
providing instances
+ * of FileObject
convertible to java.io.File
+ * @param fcl
+ * @see #toFileObject
+ * @since 7.7
+ */
+ public static void removeFileChangeListener(FileChangeListener fcl) {
+ FileSystem fs = getDiskFileSystem();
+ if (fs == null) {fs = getDiskFileSystem(File.listRoots());}
+ if (fs != null) {
+ fs.addFileChangeListener(fcl);
+ }
+ }
+
/**
* Executes atomic action. For more info see {@link FileSystem#runAtomicAction}.