Java Code Examples for org.openide.filesystems.FileEvent#getFile()

The following examples show how to use org.openide.filesystems.FileEvent#getFile() . 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: ModuleList.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void fileChanged(FileEvent ev) {
    if (isOurs(ev)) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("ModuleList: got expected modification " + ev);
        }
        return;
    }
    FileObject fo = ev.getFile();
    String name = fo.getName();
    String ext = fo.getExt();
    if ("xml".equals(ext)) { // NOI18N
        // Changed module.
        String codenamebase = name.replace('-', '.');
        DiskStatus status = statuses.get(codenamebase);
        LOG.fine("ModuleList: outside file modification event for " + codenamebase + ": " + ev);
        if (status != null) {
            status.dirty = true;
        } else {
            // XXX should this ever happen?
        }
        runme();
    } else if ("ser".equals(ext)) { // NOI18N
        // XXX handle changes of installers?? or not
    } // else ignore
}
 
Example 2
Source File: WebAppParseSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void processFileChange(final FileEvent fe) {
    // check the file type/name/extension and then
    // check if the file belongs to this parse proxy
    FileObject fo = fe.getFile();
    if (fo.getExt().equals("tld") // NOI18N
            || fo.getNameExt().equals("web.xml") // NOI18N
            || determineIsTagFile(fo)) { // #109478
        if ((wmRoot != null && FileUtil.isParentOf(wmRoot, fo))
                || (webInf != null && FileUtil.isParentOf(webInf, fo))) {
            LOG.log(Level.FINE, "File {0} has changed, reinitCaches() called", fo); // NOI18N
            // our file => process caches
            // #133702
            if (fo.getNameExt().equals("web.xml")) { // NOI18N
                // clear JspConfig cache as well
                cpCurrent.incrementAndGet();
            }
            reinitCachesTask.schedule(REINIT_CACHES_DELAY);
        }
    }
}
 
Example 3
Source File: PhpProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileDataCreated(FileEvent fe) {
    FileObject file = fe.getFile();
    if (!isVisible(file)) {
        return;
    }
    frameworksReset(file);
    browserReload(file);
    processChange(file);
}
 
Example 4
Source File: AbstractFilesListener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileChanged(FileEvent e) {
    FileObject fo = e.getFile();
    if (isTarget(fo)) {
        fo.refresh(true);
        targetChanged(fo);
    }
}
 
Example 5
Source File: AbstractFilesListener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDataCreated(FileEvent e) {
    FileObject fo = e.getFile();
    if (isTarget(fo)) {
        synchronized(fileListeners) {
            addFileListenerTo(fo);
        }
        targetCreated(fo);
    }
}
 
Example 6
Source File: AbstractFilesListener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDeleted(FileEvent e) {
    FileObject fo = e.getFile();
    if (isTarget(fo)) {
        synchronized(fileListeners) {
            removeFileListenerFrom(fo);
        }
        targetDeleted(fo);
    }
    startListening();
}
 
Example 7
Source File: FolderListener.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDataCreated(FileEvent fe) {
    FileObject fo = fe.getFile();
    for(String target: targets) {
        if(target.equals(fo.getNameExt())) {
            PayaraConfiguration config = PayaraConfiguration.getConfiguration(configKey);
            if(config != null) {
                config.addDescriptorListener(fo);
            }
        }
    }
}
 
Example 8
Source File: LibrariesStorage.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileChanged(FileEvent fe) {
    FileObject definitionFile = fe.getFile();
    String fileName = definitionFile.getPath();
    final Libs data = this.initStorage(false);
    final LibraryImplementation impl = data.get(fileName);
    if (impl != null) {
        try {
            readLibrary (definitionFile, impl);
            LibraryTypeProvider provider = ltRegistry.getLibraryTypeProvider (impl.getType());
            if (provider == null) {
                LOG.warning("LibrariesStorage: Can not invoke LibraryTypeProvider.libraryCreated(), the library type provider is unknown.");  //NOI18N
            }
            try {
                //TODO: LibraryTypeProvider should be extended by libraryUpdated method
                provider.libraryCreated (impl);
                updateTimeStamp(definitionFile);
                saveTimeStamps();
            } catch (RuntimeException e) {
                String message = NbBundle.getMessage(LibrariesStorage.class,"MSG_libraryCreatedError");
                Exceptions.printStackTrace(Exceptions.attachMessage(e,message));
            }
        } catch (SAXException se) {
            //The library is broken, probably edited by user, log as warning
            logBrokenLibraryDescripor(definitionFile, se);
        } catch (ParserConfigurationException pce) {
            Exceptions.printStackTrace(pce);
        } catch (IOException ioe) {
            Exceptions.printStackTrace(ioe);
        }
    }
}
 
Example 9
Source File: PhpProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileDeleted(FileEvent fe) {
    FileObject file = fe.getFile();
    if (!isVisible(file)) {
        return;
    }
    frameworksReset(file);
    browserReload(file);
    processChange(file);
}
 
Example 10
Source File: PhpProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileChanged(FileEvent fe) {
    FileObject file = fe.getFile();
    if (!isVisible(file)) {
        return;
    }
    browserReload(file);
    processChange(file);
}
 
Example 11
Source File: EjbJarMultiViewDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDataCreated(FileEvent fileEvent) {
    FileObject fo = fileEvent.getFile();
    String resourceName = getPackageName(fo);
    if (resourceName != null) {
        elementCreated(resourceName);
    }
}
 
Example 12
Source File: EditorSettingsImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void fileFolderCreated(FileEvent fe) {
    FileObject f = fe.getFile();
    if (keymapFolder == null && KEYMAPS_FOLDER.equals(f.getNameExt()) && f.getParent() == FileUtil.getConfigRoot()) {
        // keymap folder is created -> start listening on it
        keymapFolder = f;
        f.addFileChangeListener(this);
    }
}
 
Example 13
Source File: ServiceModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Fired when a file is changed.
* @param fe the event describing context where action has taken place
*/
@Override
public void fileChanged(final FileEvent fe) {
    
    Runnable runnable = new Runnable() {
        
        @Override
        public void run() {
            FileObject implClass = fe.getFile();
            ServiceModel newModel = new ServiceModel(implClass,true);
            ServiceModel.this.mergeModel(newModel);
        }
    };
    FILE_CHANGE_RP.post(runnable);
}
 
Example 14
Source File: FileChangeListener.java    From editorconfig-netbeans with MIT License 5 votes vote down vote up
private boolean isCandidateForProcessing(FileEvent event) {
  FileObject file = event.getFile();

  boolean applyRules = false;
  boolean isntFolder = !file.isFolder();
  boolean isUnexpected = !event.isExpected();
  boolean isntSkipped = !SmartSkip.skipDirectory(file);

  if (isUnexpected && isntFolder && isntSkipped) {
    applyRules = true;
  }

  return applyRules;
}
 
Example 15
Source File: FileChangeListener.java    From editorconfig-netbeans with MIT License 5 votes vote down vote up
/**
 * Method is triggered when content has changed and it's possible to display
 * content in NetBeans. Method is also triggered when project will be opened.
 *
 * @param event Event for listening on filesystem changes
 */
@Override
public void fileDataCreated(FileEvent event) {
  super.fileDataCreated(event);
  FileObject primaryFile = event.getFile();
  LOG.log(Level.FINE, "[EC for {0}] Added new file to project: {1} (MIME type: {2})",
          new Object[]{editorConfigFileObject.getPath(), primaryFile.getPath(), primaryFile.getMIMEType()});
}
 
Example 16
Source File: ModuleList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDataCreated(FileEvent ev) {
    if (isOurs(ev)) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("ModuleList: got expected creation " + ev);
        }
        return;
    }
    FileObject fo = ev.getFile();
    fileCreated0(fo.getName(), fo.getExt()/*, ev.getTime()*/);
}
 
Example 17
Source File: ModuleList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDeleted(FileEvent ev) {
    if (isOurs(ev)) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("ModuleList: got expected deletion " + ev);
        }
        return;
    }
    FileObject fo = ev.getFile();
    fileDeleted0(fo.getName(), fo.getExt()/*, ev.getTime()*/);
}
 
Example 18
Source File: PackageViewChildren.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileDataCreated( final FileEvent fe ) {
    FileObject fo = fe.getFile();
    if ( FileUtil.isParentOf( root, fo ) && isVisible( root, fo ) ) {
        if (ProjectManager.mutex().isReadAccess() || ProjectManager.mutex().isWriteAccess()) {
            PackageRootNode.PKG_VIEW_RP.post(new Runnable() {
                public void run() {
                    fileDataCreated(fe);
                }
            });
            return;
        }

        FileObject parent = fo.getParent();
        if (!parent.isFolder()) {
            throw new IllegalStateException(FileUtil.getFileDisplayName(parent) + " is not a folder!"); //NOI18N
        }
        // XXX consider using group.contains() here
        if ( !VisibilityQuery.getDefault().isVisible( parent ) ) {
            return; // Adding file into ignored directory
        }
        PackageNode n = get( parent );
        if ( n == null && !contains( parent ) ) {                
            add(parent, false, true);
            refreshKeysAsync();
        }
        else if ( n != null ) {
            n.updateChildren();
        }
    }
}
 
Example 19
Source File: SourceMapsScanner.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void fileDeleted(FileEvent fe) {
    FileObject fo = fe.getFile();
    unregisterSourceMap(fo);
}
 
Example 20
Source File: SourceMapsScanner.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void fileChanged(FileEvent fe) {
    FileObject fo = fe.getFile();
    unregisterSourceMap(fo);
    registerIfSourceMap(fo);
}