本文整理汇总了Java中org.openide.filesystems.FileChangeListener类的典型用法代码示例。如果您正苦于以下问题:Java FileChangeListener类的具体用法?Java FileChangeListener怎么用?Java FileChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FileChangeListener类属于org.openide.filesystems包,在下文中一共展示了FileChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCfgFileChangeListener
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public static void addCfgFileChangeListener(Project prj,
FileChangeListener l){
FileObject fo = getFOForBindingConfigFile(prj);
FileChangeListener fcl = null;
if (fo != null) {
fcl = FileUtil.weakFileChangeListener(l, fo);
fo.addFileChangeListener(fcl);
} else {
fo = getFOForNBProjectDir(prj);
if (fo != null) {
fcl = FileUtil.weakFileChangeListener(l, fo);
fo.addFileChangeListener(fcl);
}
}
}
示例2: testDeadlockWhileRefesh
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public void testDeadlockWhileRefesh() throws IOException {
clearWorkDir();
MockServices.setServices(Watcher.class, AnnotationProviderImpl.class);
final File root = new File(getWorkDir(), "root");
File f = new File(new File(new File(root, "x"), "y"), "z");
f.mkdirs();
final FileObject r = FileUtil.toFileObject(root);
r.refresh(true);
Set<FileObject> all = new HashSet<FileObject>();
Enumeration<? extends FileObject> en = r.getChildren(true);
while (en.hasMoreElements()) {
FileObject fileObject = en.nextElement();
all.add(fileObject);
}
assertEquals("Some files: " + all, 3, all.size());
FileChangeListener l = new FileChangeAdapter();
FileUtil.addRecursiveListener(l, root);
FileChangeListener l2 = new FileChangeAdapter();
FileUtil.addRecursiveListener(l2, root);
}
示例3: testRefresh69744
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public void testRefresh69744() throws Exception {
File thisTest = new File(getWorkDir(),"thisTest");
thisTest.createNewFile();
FileObject testf = FileBasedFileSystem.getFileObject(thisTest);
assertNotNull(testf);
assertGC("",new WeakReference<FileObject>(testf.getParent()));
modifyFileObject(testf, "abc");
FileSystem fs = testf.getFileSystem();
final List<FileEvent> l = new ArrayList<FileEvent>();
FileChangeListener fcl = new FileChangeAdapter() {
@Override
public void fileChanged(FileEvent fe) {
l.add(fe);
}
};
Thread.sleep(1500);
fs.addFileChangeListener(fcl);
try {
modifyFileObject(testf, "def");
assertFalse(l.isEmpty());
} finally {
fs.removeFileChangeListener(fcl);
}
}
示例4: ChangeSupport
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
ChangeSupport(
@NonNull final FileObject file,
@NonNull final Runnable resetAction) {
Parameters.notNull("file", file); //NOI18N
Parameters.notNull("resetAction", resetAction); //NOI18N
this.resetAction = resetAction;
this.file = file;
this.file.addFileChangeListener(WeakListeners.create(FileChangeListener.class, this, this.file));
EditorCookie.Observable cookie = null;
try {
final DataObject dobj = DataObject.find(file);
cookie = dobj.getLookup().lookup(EditorCookie.Observable.class);
} catch (DataObjectNotFoundException e) {
//pass
}
this.ec = cookie;
if (this.ec != null) {
this.ec.addPropertyChangeListener(WeakListeners.propertyChange(this, this.ec));
assignDocListener(this.ec);
}
}
示例5: acceptTemplate
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private boolean acceptTemplate (FileObject fo) {
if (fo.isFolder() &&
(TEMPLATES_FOLDER+"/Properties").equals(fo.getPath())) {
return false;
}
boolean attachListener;
synchronized (filesWeListenOn) {
attachListener = filesWeListenOn.add(fo);
}
if (attachListener) {
FileChangeListener fileChangeListener = FileUtil.weakFileChangeListener(this, fo);
fo.addFileChangeListener(fileChangeListener);
}
if (isTemplate (fo) || fo.isFolder()) {
Object o = fo.getAttribute ("simple"); // NOI18N
return o == null || Boolean.TRUE.equals (o);
} else {
return false;
}
}
示例6: safeAddRecursiveListener
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private void safeAddRecursiveListener(
@NonNull final FileChangeListener listener,
@NonNull final File path,
@NullAllowed final ClassPath.Entry entry) {
if (USE_RECURSIVE_LISTENERS) {
final FileFilter filter = entry == null?
null:
(pathname) -> {
try {
return entry.includes(BaseUtilities.toURI(pathname).toURL());
} catch (MalformedURLException ex) {
Exceptions.printStackTrace(ex);
return true;
}
};
performAsync(() -> {
FileUtil.addRecursiveListener(
listener,
path,
filter,
() -> !listens);
return null;
});
}
}
示例7: rebuild
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
* Create a new tracker for tracking mime types under the <code>basePath</code>
* folder.
*
* @param settingsType The type of settings to track mime types for. If not
* <code>null</code> the tracker will only list mime types that declare
* settings of this type.
* @param basePath The path on the system <code>FileSystem</code> where the
* mime types should be tracked.
*/
/* package */ MimeTypesTracker(SettingsType.Locator locator, String basePath) {
this.locator = locator;
this.basePath = basePath;
this.basePathElements = basePath.split("/"); //NOI18N
rebuild();
// Start listening
this.listener = new Listener();
FileSystem sfs = null;
try {
sfs = FileUtil.getConfigRoot().getFileSystem();
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
sfs.addFileChangeListener(WeakListeners.create(FileChangeListener.class,listener, sfs));
}
示例8: rebuild
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
* Creates a new instance of ProfilesTracker.
*
* @param type
* @param mimeTypes
* @param strict
*/
/* package */ProfilesTracker(Locator locator, MimeTypesTracker mimeTypes) {
this.locator = locator;
this.mimeTypes = mimeTypes;
rebuild();
// Start listening
this.listener = new Listener();
FileSystem sfs = null;
try {
sfs = FileUtil.getConfigRoot().getFileSystem();
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
this.systemFileSystem = sfs;
this.systemFileSystem.addFileChangeListener(WeakListeners.create(FileChangeListener.class, listener, this.systemFileSystem));
this.mimeTypes.addPropertyChangeListener(listener);
}
示例9: addFileSystemsListener
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
* Adds given listener to all FileSystems
* @param l listener to add
*/
public static void addFileSystemsListener(FileChangeListener l) {
FileSystem[] fileSystems = getFileSystems();
for (int i=0; i<fileSystems.length; i++) {
fileSystems[i].addFileChangeListener(l);
}
}
示例10: removeFileSystemsListener
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
* Removes given listener to all FileSystems
* @param l listener to remove
*/
public static void removeFileSystemsListener(FileChangeListener l) {
FileSystem[] fileSystems = getFileSystems();
for (int i=0; i<fileSystems.length; i++) {
fileSystems[i].removeFileChangeListener(l);
}
}
示例11: ensureListensOnFS
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private void ensureListensOnFS(FileObject f) {
try {
FileSystem fs = f.getFileSystem();
if (!system2RecursiveListener.containsKey(fs)) {
FileChangeListener l = new RootAddedDeletedListener();
system2RecursiveListener.put(fs, l);
fs.addFileChangeListener(l);
}
} catch (FileStateInvalidException ex) {
LOG.log(Level.FINE, null, ex);
}
}
示例12: checkFileStatus
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
private void checkFileStatus(FileObject fo) {
boolean update = false;
synchronized (this) {
if (lastFile == null || lastFile.get() != fo) {
lastFile = new WeakReference<FileObject>(fo);
update = true;
}
}
if (update) {
fo.addFileChangeListener(WeakListeners.create(FileChangeListener.class, this, fo));
boolean readOnly = !fo.canWrite(); // Access without monitor on this class and document's lock
updateFileReadOnly(readOnly);
}
}
示例13: create
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
* Creates new support for the given directory and file name(s).
* @param directory directory
* @param fileNames file name(s)
* @return new support
*/
public static ImportantFilesSupport create(FileObject directory, String... fileNames) {
Parameters.notNull("directory", directory); // NOI18N
Parameters.notNull("fileNames", fileNames); // NOI18N
ImportantFilesSupport support = new ImportantFilesSupport(directory, fileNames);
directory.addFileChangeListener(WeakListeners.create(FileChangeListener.class, support.fileChangeListener, directory));
return support;
}
示例14: removeModelListner
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
public static void removeModelListner(Project prj, FileChangeListener l){
// WeakChangeListener will return true for its proxy.
FileObject fo = getFOForBindingConfigFile(prj);
if (fo != null) {
fo.removeFileChangeListener(l);
}
fo = getFOForNBProjectDir(prj);
if (fo != null) {
fo.removeFileChangeListener(l);
}
}
示例15: DataObjectListener
import org.openide.filesystems.FileChangeListener; //导入依赖的package包/类
/**
* @param fo The file object to listen upon at DataObject level
* @param fcl The FileChangeListener to be called when the DataObject has been invalidated
*
* @throws org.openide.loaders.DataObjectNotFoundException
*/
public DataObjectListener(FileObject fo, FileChangeListener fcl) throws DataObjectNotFoundException {
this.fobj = fo;
this.flisten = fcl;
this.dobj = DataObject.find(fo);
wlistener = WeakListeners.propertyChange(this, dobj);
this.dobj.addPropertyChangeListener(wlistener);
}