Java Code Examples for org.openide.filesystems.FileUtil#weakFileStatusListener()
The following examples show how to use
org.openide.filesystems.FileUtil#weakFileStatusListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PackageRootNode.java From netbeans with Apache License 2.0 | 6 votes |
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"); }
Example 2
Source File: MultiModuleNodeFactory.java From netbeans with Apache License 2.0 | 6 votes |
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; } }
Example 3
Source File: ProjectsRootNode.java From netbeans with Apache License 2.0 | 6 votes |
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 } } }
Example 4
Source File: AnnotatedNode.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
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); } } }