本文整理汇总了Java中org.openide.filesystems.FileSystem.removeFileChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.removeFileChangeListener方法的具体用法?Java FileSystem.removeFileChangeListener怎么用?Java FileSystem.removeFileChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileSystem
的用法示例。
在下文中一共展示了FileSystem.removeFileChangeListener方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRefresh69744
import org.openide.filesystems.FileSystem; //导入方法依赖的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);
}
}
示例2: reset
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
void reset() {
Set filesystems = getRootFilesystems();
for (Iterator i = filesystems.iterator(); i.hasNext();) {
FileSystem fileSystem = (FileSystem) i.next();
fileSystem.removeFileChangeListener(interceptor);
}
events.clear();
}
示例3: testRefresh109490
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testRefresh109490() throws Exception {
final File wDir = getWorkDir();
final FileObject wDirFo = FileBasedFileSystem.getFileObject(wDir);
final List<FileEvent> fileEvents = new ArrayList<FileEvent>();
FileSystem fs = wDirFo.getFileSystem();
FileChangeListener fListener = new FileChangeAdapter() {
@Override
public void fileDataCreated(FileEvent fe) {
super.fileDataCreated(fe);
fileEvents.add(fe);
}
};
try {
fs.addFileChangeListener(fListener);
File file = new File(wDir, "testao.f");
File file2 = new File(wDir, "testc1.f");
assertEquals(file.hashCode(), file2.hashCode());
wDirFo.getChildren();
assertTrue(file.createNewFile());
assertTrue(file2.createNewFile());
assertEquals(0, fileEvents.size());
fs.refresh(true);
assertEquals(2, fileEvents.size());
assertEquals(Arrays.asList(wDirFo.getChildren()).toString(), 2,wDirFo.getChildren().length);
assertTrue(Arrays.asList(wDirFo.getChildren()).toString().indexOf(file.getName()) != -1);
assertTrue(Arrays.asList(wDirFo.getChildren()).toString().indexOf(file2.getName()) != -1);
} finally {
fs.removeFileChangeListener(fListener);
}
}
示例4: testRefresh109490
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testRefresh109490() throws Exception {
final File wDir = new File(getWorkDir(), getName());
wDir.mkdir();
final FileObject wDirFo = FileUtil.toFileObject(wDir);
final List<FileEvent> fileEvents = new ArrayList<FileEvent>();
FileSystem fs = wDirFo.getFileSystem();
FileChangeListener fListener = new FileChangeAdapter(){
@Override
public void fileDataCreated(FileEvent fe) {
super.fileDataCreated(fe);
fileEvents.add(fe);
}
};
try {
fs.refresh(true); // catch and skip changes made in VCS metadata, they are not part of this test
fs.addFileChangeListener(fListener);
File file = new File(wDir, "testao.f");
File file2 = new File(wDir, "testc1.f");
assertEquals(file.hashCode(), file2.hashCode());
wDirFo.getChildren();
assertTrue(file.createNewFile());
assertTrue(file2.createNewFile());
assertEquals(0, fileEvents.size());
fs.refresh(true);
assertEquals(2, fileEvents.size());
assertEquals(Arrays.asList(wDirFo.getChildren()).toString(), 2,wDirFo.getChildren().length);
assertTrue(Arrays.asList(wDirFo.getChildren()).toString().indexOf(file.getName()) != -1);
assertTrue(Arrays.asList(wDirFo.getChildren()).toString().indexOf(file2.getName()) != -1);
} finally {
fs.removeFileChangeListener(fListener);
}
}
示例5: testRefreshDoesNotMultiplyFileObjects_89059
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testRefreshDoesNotMultiplyFileObjects_89059 () throws Exception {
FileObject fo = FileBasedFileSystem.getFileObject(testFile);
fo.getChildren();
FileSystem fs = fo.getFileSystem();
FileChangeListener fcl = new FileChangeAdapter();
OutputStream os = null;
fs.addFileChangeListener(fcl);
fo.addFileChangeListener(fcl);
try {
//no change
int foInstancesInCache = Statistics.fileObjects();
fs.refresh(false);
assertTrue(foInstancesInCache >= Statistics.fileObjects());
//internal change
File ff = new File(testFile,"a/b/c/d/aa.txt");//NOI18N
FileUtil.createData(ff);
foInstancesInCache = Statistics.fileObjects();
fs.refresh(false);
assertTrue(foInstancesInCache >= Statistics.fileObjects());
//external change
FileObject ffObject = FileBasedFileSystem.getFileObject(ff);
foInstancesInCache = Statistics.fileObjects();
os = new java.io.FileOutputStream(ff);
os.write("dsdopsdsd".getBytes());//NOI18N
os.close();
fs.refresh(false);
assertTrue(foInstancesInCache >= Statistics.fileObjects());
assertTrue(new File(testFile,"nfile").createNewFile());//NOI18N
fs.refresh(false);
fo.refresh(false);
assertTrue(foInstancesInCache+1 >= Statistics.fileObjects());
foInstancesInCache = Statistics.fileObjects();
assertTrue(new File(testFile,"aa/bb/cc").mkdirs());//NOI18N
fs.refresh(false);
fo.refresh(false);
assertTrue(foInstancesInCache+3 >= Statistics.fileObjects());
} finally {
if (os != null) {
os.close();
}
fs.removeFileChangeListener(fcl);
fo.removeFileChangeListener(fcl);
}
}