本文整理汇总了Java中org.openide.filesystems.FileUtil.weakFileStatusListener方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtil.weakFileStatusListener方法的具体用法?Java FileUtil.weakFileStatusListener怎么用?Java FileUtil.weakFileStatusListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileUtil
的用法示例。
在下文中一共展示了FileUtil.weakFileStatusListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PackageRootNode
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private PackageRootNode( SourceGroup group, Children ch) {
super(ch, new ProxyLookup(createLookup(group), Lookups.singleton(
SearchInfoDefinitionFactory.createSearchInfoBySubnodes(ch))));
this.group = group;
file = group.getRootFolder();
files = Collections.singleton(file);
try {
FileSystem fs = file.getFileSystem();
fileSystemListener = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fileSystemListener);
} catch (FileStateInvalidException e) {
Exceptions.printStackTrace(Exceptions.attachMessage(e,"Can not get " + file + " filesystem, ignoring...")); //NOI18N
}
setName( group.getName() );
setDisplayName( group.getDisplayName() );
// setIconBase("org/netbeans/modules/java/j2seproject/ui/resources/packageRoot");
}
示例2: setFiles
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
protected final void setFiles(Set<FileObject> files) {
if (fileSystemListeners != null) {
for (Map.Entry<FileSystem, FileStatusListener> entry : fileSystemListeners.entrySet()) {
entry.getKey().removeFileStatusListener(entry.getValue());
}
}
fileSystemListeners = new HashMap<FileSystem, FileStatusListener>();
this.files = files;
Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
for (FileObject fo : files) {
try {
FileSystem fs = fo.getFileSystem();
if (hookedFileSystems.contains(fs)) {
continue;
}
hookedFileSystems.add(fs);
FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fsl);
fileSystemListeners.put(fs, fsl);
} catch (FileStateInvalidException e) {
LOG.log(Level.INFO, "Cannot get " + fo + " filesystem, ignoring...", e); // NOI18N
}
}
}
示例3: updateFileStatusListeners
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
private void updateFileStatusListeners() {
final Collection<FileSystem> fileSystems = new HashSet<>();
for (FileObject fo : getFileObjects()) {
try {
fileSystems.add(fo.getFileSystem());
} catch (FileStateInvalidException e) {
LOG.log(
Level.WARNING,
"Ignoring invalid file: {0}", //NOI18N
FileUtil.getFileDisplayName(fo));
}
}
synchronized (this) {
for (Pair<FileSystem,FileStatusListener> p : fsListensOn) {
p.first().removeFileStatusListener(p.second());
}
final List<Pair<FileSystem,FileStatusListener>> newFsListensOn = new ArrayList<>();
for (FileSystem fs : fileSystems) {
FileStatusListener l = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(l);
newFsListensOn.add(Pair.of(fs,l));
}
fsListensOn = newFsListensOn;
}
}
示例4: setFiles
import org.openide.filesystems.FileUtil; //导入方法依赖的package包/类
protected final void setFiles(final Set<FileObject> files) {
fileSystemListeners = new HashSet<FileStatusListener>();
this.files = files;
if (files == null) {
return;
}
Set<FileSystem> hookedFileSystems = new HashSet<FileSystem>();
for (FileObject fo : files) {
try {
FileSystem fs = fo.getFileSystem();
if (hookedFileSystems.contains(fs)) {
continue;
}
hookedFileSystems.add(fs);
FileStatusListener fsl = FileUtil.weakFileStatusListener(this, fs);
fs.addFileStatusListener(fsl);
fileSystemListeners.add(fsl);
} catch (FileStateInvalidException e) {
ErrorManager err = ErrorManager.getDefault();
err.annotate(e, "Cannot get " + fo + " filesystem, ignoring..."); // NOI18N
err.notify(ErrorManager.INFORMATIONAL, e);
}
}
}