Lines 67-72
Link Here
|
67 |
import java.util.Stack; |
67 |
import java.util.Stack; |
68 |
import java.util.StringTokenizer; |
68 |
import java.util.StringTokenizer; |
69 |
import java.util.WeakHashMap; |
69 |
import java.util.WeakHashMap; |
|
|
70 |
import java.util.concurrent.Callable; |
70 |
import java.util.jar.JarEntry; |
71 |
import java.util.jar.JarEntry; |
71 |
import java.util.jar.JarInputStream; |
72 |
import java.util.jar.JarInputStream; |
72 |
import java.util.logging.Level; |
73 |
import java.util.logging.Level; |
Lines 333-339
Link Here
|
333 |
* @since org.openide.filesystems 7.28 |
334 |
* @since org.openide.filesystems 7.28 |
334 |
*/ |
335 |
*/ |
335 |
public static void addRecursiveListener(FileChangeListener listener, File path) { |
336 |
public static void addRecursiveListener(FileChangeListener listener, File path) { |
336 |
addFileChangeListener(new DeepListener(listener, path), path); |
337 |
addFileChangeListener(new DeepListener(listener, path, null), path); |
|
|
338 |
} |
339 |
|
340 |
/** |
341 |
* Adds a listener to changes under given path. It permits you to listen to a file |
342 |
* which does not yet exist, or continue listening to it after it is deleted and recreated, etc. |
343 |
* <br/> |
344 |
* When given path represents a file ({@code path.isDirectory() == false}), this |
345 |
* code behaves exectly like {@link #addFileChangeListener(org.openide.filesystems.FileChangeListener, java.io.File)}. |
346 |
* Usually the path shall represent a folder ({@code path.isDirectory() == true}) |
347 |
* <ul> |
348 |
* <li>fileFolderCreated event is fired when the folder is created or a child folder created</li> |
349 |
* <li>fileDataCreated event is fired when a child file is created</li> |
350 |
* <li>fileDeleted event is fired when the folder is deleted or a child file/folder removed</li> |
351 |
* <li>fileChanged event is fired when a child file is modified</li> |
352 |
* <li>fileRenamed event is fired when the folder is renamed or a child file/folder is renamed</li> |
353 |
* <li>fileAttributeChanged is fired when FileObject's attribute is changed</li> |
354 |
*</ul> |
355 |
* The above events are delivered for changes in all subdirectories (recursively). |
356 |
* It is guaranteed that with each change at least one event is generated. |
357 |
* For example adding a folder does not notify about content of the folder, |
358 |
* hence one event is delivered. |
359 |
* |
360 |
* Can only add a given [listener, path] pair once. However a listener can |
361 |
* listen to any number of paths. Note that listeners are always held weakly |
362 |
* - if the listener is collected, it is quietly removed. |
363 |
* |
364 |
* <div class="nonnormative"> |
365 |
* As registering of the listener can take a long time, especially on deep |
366 |
* hierarchies, it is possible provide a callback <code>stop</code>. |
367 |
* This stop object is guaranteed to be called once per every folder on the |
368 |
* default (when masterfs module is included) implemention. If the call |
369 |
* to <code>stop.call()</code> returns true, then the registration of |
370 |
* next recursive items is interrupted. The listener may or may not get |
371 |
* some events from already registered folders. |
372 |
* </div> |
373 |
* |
374 |
* @param listener FileChangeListener to listen to changes in path |
375 |
* @param path File path to listen to (even not existing) |
376 |
* @param stop an interface to interrupt the process of registering |
377 |
* the listener. If the <code>call</code> returns true, the process |
378 |
* of registering the listener is immediately interrupted |
379 |
* |
380 |
* @see FileObject#addRecursiveListener |
381 |
* @since org.openide.filesystems 7.37 |
382 |
*/ |
383 |
public static void addRecursiveListener(FileChangeListener listener, File path, Callable<Boolean> stop) { |
384 |
addFileChangeListener(new DeepListener(listener, path, stop), path); |
337 |
} |
385 |
} |
338 |
|
386 |
|
339 |
/** |
387 |
/** |
Lines 346-352
Link Here
|
346 |
* @since org.openide.filesystems 7.28 |
394 |
* @since org.openide.filesystems 7.28 |
347 |
*/ |
395 |
*/ |
348 |
public static void removeRecursiveListener(FileChangeListener listener, File path) { |
396 |
public static void removeRecursiveListener(FileChangeListener listener, File path) { |
349 |
DeepListener dl = (DeepListener)removeFileChangeListenerImpl(new DeepListener(listener, path), path); |
397 |
DeepListener dl = (DeepListener)removeFileChangeListenerImpl(new DeepListener(listener, path, null), path); |
350 |
dl.run(); |
398 |
dl.run(); |
351 |
} |
399 |
} |
352 |
|
400 |
|