Java Code Examples for org.openide.filesystems.FileEvent#firedFrom()
The following examples show how to use
org.openide.filesystems.FileEvent#firedFrom() .
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: ProjectProperties.java From netbeans with Apache License 2.0 | 6 votes |
private void diskChange(FileEvent fe) { boolean writing = false; if (fe != null) { synchronized (saveActions) { for (AtomicAction a : saveActions) { if (fe.firedFrom(a)) { writing = true; break; } } } } if (!writing) { loaded = false; reloadedStackTrace = new Throwable("noticed disk change here"); } fireChange(); if (!writing) { helper.fireExternalChange(path); } }
Example 2
Source File: ModuleList.java From netbeans with Apache License 2.0 | 5 votes |
/** Check if a given file event in the Modules/ folder was a result * of our own manipulations, as opposed to some other code (or polled * refresh) manipulating one of these XML files. See #15573. */ private boolean isOurs(FileEvent ev) { for (FileSystem.AtomicAction action : myAtomicActions) { if (ev.firedFrom(action)) { return true; } } return false; }
Example 3
Source File: FsEventFromAtomicActionTest.java From netbeans with Apache License 2.0 | 5 votes |
private void testFileEvent(FileEvent event) { if (event.getFile().getNameExt().startsWith(FILE_PREFIX)) { events.incrementAndGet(); if (!event.firedFrom(atomicAction)) { notFromAtomicAction.add(event); // throw new RuntimeException(event.toString()); } } }
Example 4
Source File: DataEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** Called from the EnvListener * @param expected is the change expected * @param time of the change */ final void fileChanged (FileEvent fe) { ERR.fine("fileChanged: " + fe.isExpected() + " for " + fileObject); // NOI18N //#155680: We will ignore events generated from FileObject.refresh() in getTime(). if ((action != null) && fe.firedFrom(action)) { return; } if (fe.isExpected()) { // newValue = null means do not ask user whether to reload firePropertyChange (PROP_TIME, null, null); } else { firePropertyChange (PROP_TIME, null, new Date (fe.getTime())); } }
Example 5
Source File: DataEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** Fired when a file is changed. * @param fe the event describing context where action has taken place */ @Override public void fileChanged(FileEvent fe) { if (fe.firedFrom(SaveImpl.DEFAULT)) { return; } Env myEnv = this.env.get (); if (myEnv == null || myEnv.getFileImpl () == null) { // the Env change its file and we are not used // listener anymore => remove itself from the list of listeners removeFileChangeListener (fe.getFile ()); return; } if (myEnv.getFileImpl() != fe.getFile()) { return; } // #16403. Added handling for virtual property of the file. if(fe.getFile().isVirtual()) { // Remove file event coming as consequence of this change. fe.getFile().removeFileChangeListener(this); // File doesn't exist on disk -> simulate env is invalid, // even the fileObject could be valid, see VCS FS. myEnv.fileRemoved(true); fe.getFile().addFileChangeListener(this); } else { myEnv.fileChanged (fe); } }
Example 6
Source File: SerialDataConvertor.java From netbeans with Apache License 2.0 | 5 votes |
public void fileDeleted(FileEvent fe) { if (saver != null && fe.firedFrom(saver)) return; if (saver != null) { saver.removePropertyChangeListener(this); getScheduledRequest().cancel(); saver = null; } }
Example 7
Source File: LayerUtils.java From netbeans with Apache License 2.0 | 5 votes |
private void changed(FileEvent fe) { //System.err.println("changed on disk in " + Thread.currentThread().getName() + " for " + this); //Thread.dumpStack(); synchronized (this) { if (fe.firedFrom(this)) { //System.err.println("(my own change)"); return; } problem = null; dirty = false; root = null; } pcs.firePropertyChange(PROP_DOCUMENT_ROOT, null, null); }
Example 8
Source File: RemoteOperationFactory.java From netbeans with Apache License 2.0 | 5 votes |
@Override protected boolean isValid(FileEvent fileEvent) { boolean valid = !fileEvent.firedFrom(RemoteClient.DOWNLOAD_ATOMIC_ACTION); if (valid) { // #202673 LOGGER.log(Level.FINE, "FS event fired from thread: {0}", Thread.currentThread().getName()); } return valid; }
Example 9
Source File: AntProjectHelper.java From netbeans with Apache License 2.0 | 5 votes |
private void change(FileEvent fe) { synchronized (saveActions) { for (AtomicAction a : saveActions) { if (fe.firedFrom(a)) { return; } } } String path; File f = FileUtil.toFile(fe.getFile()); synchronized (modifiedMetadataPaths) { if (f.equals(resolveFile(PROJECT_XML_PATH))) { if (modifiedMetadataPaths.contains(PROJECT_XML_PATH)) { //#68872: don't do anything if the given file has non-saved changes: return ; } path = PROJECT_XML_PATH; projectXmlValid = false; } else if (f.equals(resolveFile(PRIVATE_XML_PATH))) { if (modifiedMetadataPaths.contains(PRIVATE_XML_PATH)) { //#68872: don't do anything if the given file has non-saved changes: return ; } path = PRIVATE_XML_PATH; privateXmlValid = false; } else { LOG.log(Level.WARNING, "#184132: unexpected file change in {0}; possibly deleted project?", f); return; } } fireExternalChange(path); }
Example 10
Source File: PropertiesEditorSupport.java From netbeans with Apache License 2.0 | 5 votes |
/** Fired when a file is changed. * @param fe the event describing context where action has taken place */ @Override public void fileChanged(FileEvent evt) { if (LOG.isLoggable(FINER)) { LOG.finer("EnviromentListener.fileChanged(...)"); //NOI18N LOG.finer(" - original file: " //NOI18N + FileUtil.getFileDisplayName(evt.getFile())); LOG.finer(" - current file: " //NOI18N + FileUtil.getFileDisplayName((FileObject) evt.getSource())); } //see #160338 if (evt.firedFrom(SaveImpl.DEFAULT)) { return; } Environment environment = reference.get(); if (environment != null) { if(!environment.getFileImpl().equals(evt.getFile()) ) { // If the FileObject was changed. // Remove old listener from old FileObject. evt.getFile().removeFileChangeListener(this); // Add new listener to new FileObject. environment.getFileImpl().addFileChangeListener(new EnvironmentListener(environment)); return; } // #16403. See DataEditorSupport.EnvListener. if(evt.getFile().isVirtual()) { environment.entry.getFile().removeFileChangeListener(this); // File doesn't exist on disk -> simulate env is invalid, // even the fileObject could be valid, see VCS FS. environment.fileRemoved(); environment.entry.getFile().addFileChangeListener(this); } else { environment.fileChanged(evt.isExpected(), evt.getTime()); } } }
Example 11
Source File: SerialDataConvertor.java From netbeans with Apache License 2.0 | 4 votes |
/** process events coming from the file object*/ public void fileChanged(FileEvent fe) { if (saver != null && fe.firedFrom(saver)) return; propertyChange(new PropertyChangeEvent(this, SaveSupport.PROP_FILE_CHANGED, null, null)); }
Example 12
Source File: StorageImpl.java From netbeans with Apache License 2.0 | 4 votes |
private boolean filterEvents(FileEvent event) { // filter out anything that does not match required file path pattern if (!controlledFilesPattern.matcher(event.getFile().getPath()).matches()) { if (LOG.isLoggable(Level.FINER)) { LOG.finer(event.getFile().getPath() + " does not match: " + controlledFilesPattern.pattern()); //NOI18N } return true; } // filter out our own events final FileSystem.AtomicAction aa = atomicAction; if (aa != null && event.firedFrom(aa)) { if (LOG.isLoggable(Level.FINER)) { LOG.finer("Filesystem event for " + event.getFile().getPath() + " caused by saving settings"); //NOI18N } return true; } // filter out duplicate events, maybe this does not have any effect synchronized (recentEvents) { for(Iterator<Reference<FileEvent>> i = recentEvents.iterator(); i.hasNext(); ) { Reference<FileEvent> ref = i.next(); FileEvent e = ref.get(); if (e == null) { i.remove(); } else { if (e == event) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Filtering out duplicate filesystem event (1): original=[" + printEvent(e) + "]" //NOI18N + ", duplicate=[" + printEvent(event) + "]"); //NOI18N } return true; } if (e.getTime() == event.getTime() && e.getFile().getPath().equals(event.getFile().getPath())) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Filtering out duplicate filesystem event (2): original=[" + printEvent(e) + "]" //NOI18N + ", duplicate=[" + printEvent(event) + "]"); //NOI18N } return true; } } } if (recentEvents.size() > 100) { recentEvents.remove(recentEvents.size() - 1); } recentEvents.add(0, new WeakReference<FileEvent>(event)); return false; } }