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

The following examples show how to use org.openide.filesystems.FileRenameEvent#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: CopyResourcesOnSave.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void fileRenamedImpl(final FileRenameEvent fe) {
    try {
        FileObject fo = fe.getFile();
        Project owning = getOwningMavenProject(fo);
        if (owning == null) {
            return;
        }
        Tuple base = findAppropriateResourceRoots(fo, owning);
        if (base != null) {
            handleCopyFileToDestDir(base, fo, owning);
            FileObject parent = fo.getParent();
            String path;
            if (FileUtil.isParentOf(base.root, parent)) {
                path = FileUtil.getRelativePath(base.root, fo.getParent()) +
                        "/" + fe.getName() + "." + fe.getExt(); //NOI18N
            } else {
                path = fe.getName() + "." + fe.getExt(); //NOI18N
            }
            handleDeleteFileInDestDir(fo, path, base, owning);
        }
    } catch (IOException e) {
        LOG.log(Level.INFO, null, e);
    }
}
 
Example 2
Source File: ProfilingPointsManager.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void fileRenamed(final FileRenameEvent fe) {
    Runnable worker = new Runnable() {
        public void run() { 
            FileObject renamedFileO = fe.getFile();
            File renamedFile = FileUtil.toFile(renamedFileO);
            if (renamedFile != null && renamedFile.exists() && renamedFile.isFile()) {
                updateProfilingPointsFile(file, renamedFile);
            } else {
                deleteProfilingPointsForFile(file);
            }
        }
    };
    
    if (SwingUtilities.isEventDispatchThread()) {
        processor().post(worker);
    } else {
        worker.run();
    }
}
 
Example 3
Source File: WebFolderListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    // XXX #131525 PageFlowController could be destroyed already. Revise.
    if (pfc.getView() == null) {
        return;
    }

    if( !pfc.getView().isShowing() ) {
        pfc.setFilesDirty();
        return;
    }
    /* fileRenamed should not modify the faces-config because it should
     * be up to refactoring to do this. If that is the case, FacesModelPropertyChangeListener
     * should reload it.
     */
    final FileObject fileObj = fe.getFile();
    final FileRenameEvent event = fe;
    EventQueue.invokeLater(new Runnable() {

        public void run() {
            fileRenamedEventHandler(fileObj, event.getName(), event.getExt());
        }
    });
}
 
Example 4
Source File: AbstractFilesListener.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void fileRenamed(FileRenameEvent e) {
    FileObject fo = e.getFile();
    if (isTarget(fo)) {
        synchronized(fileListeners) {
            if (!fileListeners.containsKey(fo)) {
                addFileListenerTo(fo);
            }
        }
        targetCreated(fo);
    } else {
        if (isTarget(e.getName() + "." + e.getExt())) {
            synchronized(fileListeners) {
                removeFileListenerFrom(fo);
            }
            targetDeleted(fo);
        }
    }
    startListening();
}
 
Example 5
Source File: ModuleList.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileRenamed(FileRenameEvent ev) {
    if (isOurs(ev)) {
        throw new IllegalStateException("I don't rename anything! " + ev); // NOI18N
    }
    FileObject fo = ev.getFile();
    fileDeleted0(ev.getName(), ev.getExt()/*, ev.getTime()*/);
    fileCreated0(fo.getName(), fo.getExt()/*, ev.getTime()*/);
}
 
Example 6
Source File: FileObjectKeeper.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    Collection<FileChangeListener> arr = listeners;
    if (arr == null) {
        return;
    }
    final FileObject f = fe.getFile();
    if (f.isFolder() && fe.getSource() == f && f != root) {
        // there will be another event for parent folder
        return;
    }
    for (FileChangeListener l : arr) {
        l.fileRenamed(fe);
    }
}
 
Example 7
Source File: EjbJarProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    try {
        if (handleResource(fe)) {
            return;
        }

        FileObject fo = fe.getFile();
        FileObject metaBase = getEjbModule().resolveMetaInf(metaBaseValue);
        if (metaBase != null && FileUtil.isParentOf(metaBase, fo)) {
            // inside docbase
            handleCopyFileToDestDir(fo);
            FileObject parent = fo.getParent();
            String path;
            if (FileUtil.isParentOf(metaBase, parent)) {
                path = META_INF_FOLDER + "/" + FileUtil.getRelativePath(metaBase, fo.getParent()) +
                    "/" + fe.getName() + "." + fe.getExt();
            } else {
                path = META_INF_FOLDER + "/" + fe.getName() + "." + fe.getExt();
            }
            if (!isSynchronizationAppropriate(path)) {
                return;
            }
            handleDeleteFileInDestDir(path);
        }
    } catch (IOException e) {
        LOGGER.log(Level.INFO, null, e);
    }
}
 
Example 8
Source File: EjbJarMultiViewDataObject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void fileRenamed(FileRenameEvent fileRenameEvent) {
    FileObject fo = fileRenameEvent.getFile();
    String resourceName = getPackageName(fo);
    if (resourceName != null) {
        int index = resourceName.lastIndexOf("."); //NOI18N
        String oldName = fileRenameEvent.getName();
        String oldResourceName = (index >= 0 ? resourceName.substring(0, index + 1) : "") + oldName;
        EjbJar ejbJar = getEjbJar();
        if (ejbJar.getStatus() == EjbJar.STATE_VALID) {
            fireEvent(oldResourceName, resourceName, DDChangeEvent.EJB_CHANGED);
        }
    }
}
 
Example 9
Source File: WebCopyOnSave.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(final FileRenameEvent fe) {
    if (SwingUtilities.isEventDispatchThread()) {//#167740
        RP.post(new Runnable() {
            @Override
            public void run() {
                fileRenamed(fe);
            }
        });
        return;
    }
    try {
        checkPreprocessors(fe.getFile(), fe.getName(), fe.getExt());

        if (isInPlace()) {
            return;
        }

        FileObject fo = fe.getFile();
        FileObject base = findWebDocRoot(fo);
        if (base != null) {
            handleFileCopying(fo);
            FileObject parent = fo.getParent();
            String path;
            if (FileUtil.isParentOf(base, parent)) {
                path = FileUtil.getRelativePath(base, fo.getParent()) +
                        "/" + fe.getName() + "." + fe.getExt(); //NOI18N
            } else {
                path = fe.getName() + "." + fe.getExt(); //NOI18N
            }
            if (!isSynchronizationAppropriate(path)) {
                return;
            }
            handleFileDeletion(fo, path);
        }
    } catch (IOException e) {
        logIOException(fe.getFile(), e);
    }
}
 
Example 10
Source File: PhpProject.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    FileObject file = fe.getFile();
    if (!isVisible(file)) {
        return;
    }
    frameworksReset(file);
    processChange(file, fe.getName(), fe.getExt());
}
 
Example 11
Source File: JSLineBreakpoint.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    FileObject renamedFo = fe.getFile();
    int oldLineNumber = line.getLineNumber();
    EditorLineHandler newLine = EditorLineHandlerFactory.getHandler(renamedFo, oldLineNumber);
    int newLineNumber = newLine.getLineNumber();
    JSLineBreakpoint.this.line = newLine;
    firePropertyChange(PROP_LINE_NUMBER, oldLineNumber, newLineNumber);
    firePropertyChange(PROP_FILE, fe.getName(), renamedFo.getName());
}
 
Example 12
Source File: FolderObjTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testRename() throws Exception {
   File f = testFile;

   final List<FileEvent> l = new ArrayList<FileEvent>();
   FileChangeListener fcl = new FileChangeAdapter () {
       @Override
        public void fileRenamed(FileRenameEvent fe) {
            FileObject fold = fe.getFile();
            final FileObject[] ch = fold.getChildren();
            assertTrue("There should be some children in " + fold, ch.length > 0);
            l.add(fe);
        }
   };
   
   FileObject fo = FileBasedFileSystem.getFileObject(f);
   assertNotNull(fo);
   FileObject folder =fo.createFolder("testRename");
   assertNotNull(folder);
   
   FileObject file =folder.createData("test.txt");
   assertNotNull(file);
   folder.addFileChangeListener(fcl);
   assertTrue(folder.getChildren().length > 0);
   FileLock lock = folder.lock();
   try {
       folder.rename(lock,"renfolder","");            
       assertTrue(folder.getChildren().length > 0);
       assertTrue(!l.isEmpty());            
       
       l.clear();
       
       folder.rename(lock,"testRename","");            
       assertTrue(folder.getChildren().length > 0);
       assertTrue(!l.isEmpty());            
       
   } finally {
       lock.releaseLock();
   }
   
   
}
 
Example 13
Source File: EjbJarProject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void fileRenamed (FileRenameEvent fe) {
    FileObject fo = fe.getFile ();
    checkLibraryFolder (fo);
}
 
Example 14
Source File: AppClientProject.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void fileRenamed (FileRenameEvent fe) {
    FileObject fo = fe.getFile ();
    checkLibraryFolder (fo);
}
 
Example 15
Source File: LineBreakpoint.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    FileObject renamedFo = fe.getFile();
    firePropertyChange(PROP_URL, myFileUrl, renamedFo.toURL().toString());
}
 
Example 16
Source File: SingleDiffPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    if (fe.getFile() == base || fe.getFile() == modified) {
        refreshFiles();
    }
}