本文整理汇总了Java中org.openide.filesystems.FileSystem.addFileChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.addFileChangeListener方法的具体用法?Java FileSystem.addFileChangeListener怎么用?Java FileSystem.addFileChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileSystem
的用法示例。
在下文中一共展示了FileSystem.addFileChangeListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testExternalFileChangesRefired
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
@RandomlyFails // NB-Core-Build #4187
public void testExternalFileChangesRefired() throws Exception {
Layer l = new Layer("");
FileSystem fs = l.read();
FileObject foo = fs.getRoot().createData("foo");
TestUtil.dump(foo, "foo text");
long start = foo.lastModified().getTime();
assertEquals(start, l.externalLastModified("foo"));
Thread.sleep(1000L); // make sure the timestamp actually changed
Listener fcl = new Listener();
fs.addFileChangeListener(fcl);
l.editExternal("foo", "new text");
long end = foo.lastModified().getTime();
assertEquals(end, l.externalLastModified("foo"));
assertTrue("foo was touched", end > start);
assertEquals("expected things fired",
Collections.singleton("foo"),
fcl.changes());
}
示例2: 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);
}
}
示例3: setUp
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/**
* Sets up the testing environment by creating testing folders
* on the system file system.
*/
@Override
protected void setUp() throws Exception {
clearWorkDir();
MockLookup.setInstances(
new Repository(TestUtilHid.createLocalFileSystem(getWorkDir(), new String[0])),
new Pool());
MyDL loader = MyDL.getLoader(MyDL.class);
FileSystem dfs = FileUtil.getConfigRoot().getFileSystem();
dfs.refresh (true);
FileObject fo = FileUtil.createData (dfs.getRoot (), "a.txt");
obj = DataObject.find (fo);
assertEquals ("The correct loader", loader, obj.getLoader ());
node = obj.getNodeDelegate ();
sfs = new PCL ();
dfs.addFileChangeListener (sfs);
}
示例4: setUp
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/**
* Sets up the testing environment by creating testing folders
* on the system file system.
*/
@Override
protected void setUp() throws Exception {
clearWorkDir();
MockLookup.setInstances(new Repository(TestUtilHid.createLocalFileSystem(getWorkDir(), new String[0])),
new Pool());
MyDL1 loader1 = MyDL1.getLoader(MyDL1.class);
MyDL2 loader2 = MyDL2.getLoader(MyDL2.class);
FileSystem dfs = FileUtil.getConfigRoot().getFileSystem();
dfs.refresh (true);
FileObject fo = FileUtil.createData (dfs.getRoot (), "a.ext1");
obj1 = DataObject.find (fo);
assertEquals ("The correct loader", loader1, obj1.getLoader ());
fo = FileUtil.createData (dfs.getRoot (), "b.ext2");
obj2 = DataObject.find (fo);
assertEquals ("The correct loader", loader2, obj2.getLoader ());
sfs = new PCL ();
dfs.addFileChangeListener (sfs);
}
示例5: rebuild
import org.openide.filesystems.FileSystem; //导入方法依赖的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));
}
示例6: run
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void run() {
computeKeys();
refreshKeys();
try {
FileSystem fs = root.getFileSystem();
wfcl = FileUtil.weakFileChangeListener(this, fs);
fs.addFileChangeListener( wfcl );
}
catch ( FileStateInvalidException e ) {
Exceptions.printStackTrace(e);
}
wvqcl = WeakListeners.change( this, VisibilityQuery.getDefault() );
VisibilityQuery.getDefault().addChangeListener( wvqcl );
}
示例7: testStructuralModificationsFired
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public void testStructuralModificationsFired() throws Exception {
Layer l = new Layer("<folder name='f'/><file name='x'/>");
FileSystem fs = l.read();
Listener fcl = new Listener();
fs.addFileChangeListener(fcl);
FileUtil.createData(fs.getRoot(), "a");
FileUtil.createData(fs.getRoot(), "f/b");
fs.findResource("x").delete();
assertEquals("expected things fired",
new HashSet<String>(Arrays.asList("a", "f/b", "x")),
fcl.changes());
}
示例8: testTextualModificationsFired
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
@RandomlyFails // issue #237349
public void testTextualModificationsFired() throws Exception {
Layer l = new Layer("<folder name='f'><file name='x'/></folder><file name='y'/>");
FileSystem fs = l.read();
Listener fcl = new Listener();
fs.addFileChangeListener(fcl);
l.edit("<folder name='f'/><file name='y'/><file name='z'/>");
Thread.sleep(1000L); // make sure editing is propagated
Set<String> changes = fcl.changes();
//System.err.println("changes=" + changes);
/* XXX does not work; fires too much... why?
assertEquals("expected things fired",
new HashSet(Arrays.asList(new String[] {"f/x", "z"})),
changes);
*/
assertTrue("something fired", !changes.isEmpty());
assertNull(fs.findResource("f/x"));
assertNotNull(fs.findResource("z"));
l.edit("<folder name='f'><file name='x2'/></folder><file name='y'/><file name='z'/>");
Thread.sleep(1000L); // make sure editing is propagated
/* XXX fails just on JDK 1.4... why?
changes = fcl.changes();
//System.err.println("changes=" + changes);
assertTrue("something fired #2", !changes.isEmpty());
*/
assertNotNull(fs.findResource("f/x2"));
assertNotNull(fs.findResource("z"));
}
示例9: ensureListensOnFS
import org.openide.filesystems.FileSystem; //导入方法依赖的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);
}
}
示例10: init
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
void init() {
Set filesystems = getRootFilesystems();
for (Iterator i = filesystems.iterator(); i.hasNext();) {
FileSystem fileSystem = (FileSystem) i.next();
fileSystem.addFileChangeListener(interceptor);
}
events.clear();
}
示例11: start
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
void start() {
try {
final FileSystem fs = project.getProjectDirectory().getFileSystem();
// XXX would be more efficient to only listen while TRACK_FILE_CHANGES is set,
// but it needs adding and removing of listeners depending on PropertyEvaluator events,
// the file event handling is cheap when TRACK_FILE_CHANGES is disabled.
fs.addFileChangeListener(FileUtil.weakFileChangeListener(modificationListener, fs));
} catch (FileStateInvalidException x) {
Exceptions.printStackTrace(x);
}
}
示例12: 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);
}
}
示例13: 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);
}
}
示例14: OverFiles
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
private OverFiles(String path, List<FOItem> items, AbstractLookup lkp, AbstractLookup.Content cnt) {
super(computeDelegates(path, items, lkp));
this.path = path;
this.lkp = lkp;
this.content = cnt;
this.content.setPairs(order(items));
FileSystem fs = null;
try {
fs = FileUtil.getSystemConfigRoot().getFileSystem();
} catch (FileStateInvalidException ex) {
Exceptions.printStackTrace(ex);
}
this.weakL = FileUtil.weakFileChangeListener(this, fs);
fs.addFileChangeListener(weakL);
}
示例15: BadgingSupport
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
public BadgingSupport(FileSystem fs) {
this.fs = fs;
fileChangeListener = FileUtil.weakFileChangeListener(this, null);
fs.addFileChangeListener(fileChangeListener);
}