/** * Registers <code>listener</code> so that it will receive * <code>FileEvent</code>s from <code>FileSystem</code>s providing instances * of <code>FileObject</code> convertible to <code>java.io.File</code>. * @param fcl * @see #toFileObject * @since 7.7 */ public static void addFileChangeListener(FileChangeListener fcl) { FileSystem fs = getDiskFileSystem(); if (fs == null) {fs = getDiskFileSystemFor(File.listRoots());} if (fs != null) { fs.addFileChangeListener(fcl); } }
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.getConfigRoot().getFileSystem(); } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } this.weakL = FileUtil.weakFileChangeListener(this, fs); fs.addFileChangeListener(weakL); }
getFileSystem().addFileChangeListener(new RecursiveListener(this, fcl, allowsExternalChanges)); } catch (FileStateInvalidException ex) { ExternalUtil.LOG.log(Level.FINE, "Cannot remove listener from " + this, ex);
public BadgingSupport(FileSystem fs) { this.fs = fs; fileChangeListener = FileUtil.weakFileChangeListener(this, null); fs.addFileChangeListener(fileChangeListener); }
public FsTracker(FileSystem fs) { this.fs = fs; if (this.fs != null) { this.fs.addFileChangeListener(FileUtil.weakFileChangeListener(this, this.fs)); } }
private void startFSListener () { try { FileSystem fs = projectDir.getFileSystem(); fs.addFileChangeListener(FileUtil.weakFileChangeListener(this, fs)); } catch (FileStateInvalidException x) { Exceptions.printStackTrace(x); } }
private void checkMavenProjectRoots() { roots = MavenFileOwnerQueryImpl.getInstance().getOpenedProjectRoots(); Set<FileSystem> newfs = new HashSet<FileSystem>(); Set<FileSystem> olds = new HashSet<FileSystem>(); olds.addAll(filesystems); for (FileObject fo : roots) { try { FileSystem fs = fo.getFileSystem(); newfs.add(fs); if (!filesystems.contains(fs)) { filesystems.add(fs); fs.addFileChangeListener(listener); } } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } } olds.removeAll(newfs); for (FileSystem fs : olds) { fs.removeFileChangeListener(listener); } }
void startFSListener() { //Listener has to be started when the project's lookup is initialized try { FileSystem fs = project.getProjectDirectory().getFileSystem(); // XXX would be more efficient to only listen while DO_DEPEND=false (though this is the default) fs.addFileChangeListener(FileUtil.weakFileChangeListener(modificationListener, fs)); } catch (FileStateInvalidException x) { Exceptions.printStackTrace(x); } }
private void attachListeners() { try { if (fclWeak == null) { FileSystem fs = project.getProjectDirectory().getFileSystem(); fclWeak = FileUtil.weakFileChangeListener(fclStrong, fs); fs.addFileChangeListener(fclWeak); } } catch (FileStateInvalidException e) { assert false : e; } }
private void attachListener() { FileObject sourcesDirectory = ProjectPropertiesSupport.getSourcesDirectory(project); if (sourcesDirectory == null) { // broken project return; } try { FileSystem fileSystem = sourcesDirectory.getFileSystem(); fileSystem.addFileChangeListener(FileUtil.weakFileChangeListener(fileChangeListener, fileSystem)); } catch (FileStateInvalidException exc) { LOGGER.log(Level.WARNING, exc.getMessage(), exc); } }
public synchronized void registerListeners() { if (isListenerRegistered.get()) { return; } if (pcl == null && configModel != null) { pcl = new FacesModelPropertyChangeListener(this); configModel.addPropertyChangeListener(pcl); isListenerRegistered.set(true); } else { return; } FileObject myWebFolder = getWebFolder(); if (fcl == null) { fcl = new WebFolderListener(this); if (myWebFolder != null) { try { FileSystem fileSystem = myWebFolder.getFileSystem(); fileSystem.addFileChangeListener(fcl); } catch (FileStateInvalidException ex) { Exceptions.printStackTrace(ex); } } } }
aFileSystem = project.getProjectDirectory().getFileSystem(); if (!fileChangeListenerAddedTo.contains(aFileSystem)) { aFileSystem.addFileChangeListener(folderStructureFileChangeListener); fileChangeListenerAddedTo.add(aFileSystem);
fileSystem = getSources().getFileSystem(); fileChangeListener = FileUtil.weakFileChangeListener(this, fileSystem); fileSystem.addFileChangeListener(fileChangeListener); LOGGER.log(Level.FINE, "\t-> NON-RECURSIVE listener registered for project {0}", project.getName()); } catch (FileStateInvalidException ex) {
fileSystem.addFileChangeListener(this);
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 ); }
FileSystem fileSystem = project.getProjectDirectory().getFileSystem(); fileSystem.addFileChangeListener(WeakListeners.create(FileChangeListener.class, this, fileSystem));
synchronized (knownFileSystems) { if (! knownFileSystems.contains(fs)) { fs.addFileChangeListener (new FSListener()); knownFileSystems.add(fs);
public void initialize() throws FileStateInvalidException { EjbJarProject.this.evaluator().addPropertyChangeListener(this); if (!isCopyOnSaveEnabled()) { return; } metaBase = getEjbModule().getMetaInf(); metaBaseValue = evaluator().getProperty(EjbJarProjectProperties.META_INF); if (resources != null) { FileUtil.removeFileChangeListener(this, resources); } resources = getEjbModule().getResourceDirectory(); buildClasses = evaluator().getProperty(ProjectProperties.BUILD_CLASSES_DIR); if (metaBase != null) { metaBase.getFileSystem().addFileChangeListener(this); } if (resources != null) { FileUtil.addFileChangeListener(this, resources); } LOGGER.log(Level.FINE, "Meta directory is {0}", metaBaseValue); }