本文整理匯總了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);
}
}
}