本文整理汇总了Java中org.openide.filesystems.FileSystem.addFileStatusListener方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystem.addFileStatusListener方法的具体用法?Java FileSystem.addFileStatusListener怎么用?Java FileSystem.addFileStatusListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.filesystems.FileSystem
的用法示例。
在下文中一共展示了FileSystem.addFileStatusListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: PackageRootNode
import org.openide.filesystems.FileSystem; //导入方法依赖的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.FileSystem; //导入方法依赖的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.FileSystem; //导入方法依赖的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: attachStatusListener
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/**
*/
private void attachStatusListener() {
if (fsStatusListener != null) {
return; //already attached
}
FileSystem fs;
try {
fs = myEntry.getFile().getFileSystem();
} catch (FileStateInvalidException ex) {
ErrorManager.getDefault().notify(ErrorManager.ERROR, ex);
return;
}
fsStatusListener = new FsStatusListener();
fs.addFileStatusListener(
FileUtil.weakFileStatusListener(fsStatusListener, fs));
}
示例5: PropertiesLocaleNode
import org.openide.filesystems.FileSystem; //导入方法依赖的package包/类
/** Creates a new PropertiesLocaleNode for the given locale-specific file */
public PropertiesLocaleNode (PropertiesFileEntry fe) {
super(fe, fe.getChildren());
setDisplayName(Util.getLocaleLabel(fe));
setIconBaseWithExtension(LOCALE_ICON_BASE);
setShortDescription(messageToolTip());
// the node uses lookup based on CookieSet from PropertiesFileEntry
CookieSet cookieSet = fe.getCookieSet();
cookieSet.add(PropertiesOpen.class, this);
cookieSet.add(fe);
cookieSet.add(fe.getDataObject());
cookieSet.add(this);
fsStatusListener = new FSListener();
try {
FileSystem fs = fe.getFile().getFileSystem();
fs.addFileStatusListener(FileUtil.weakFileStatusListener(fsStatusListener, fs));
} catch (FileStateInvalidException ex) {
}
}
示例6: setFiles
import org.openide.filesystems.FileSystem; //导入方法依赖的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);
}
}
}