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

The following examples show how to use org.openide.filesystems.FileRenameEvent#getExt() . 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: NpmProblemsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    String oldName = fe.getName() + (StringUtils.hasText(fe.getExt()) ? "." + fe.getExt() : ""); // NOI18N
    processFileChange(fe.getFile().getNameExt());
    processFileChange(oldName);
    processFolderChange(fe.getFile().getNameExt());
    processFolderChange(oldName);
}
 
Example 3
Source File: BowerProblemsProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    String oldName = fe.getName() + (StringUtils.hasText(fe.getExt()) ? "." + fe.getExt() : ""); // NOI18N
    processFileChange(fe.getFile().getNameExt());
    processFileChange(oldName);
    processFolderChange(fe.getFile().getNameExt());
    processFolderChange(oldName);
}
 
Example 4
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 5
Source File: JspSourcePathImplementation.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String getOldFileName(FileRenameEvent fe) {
    String result = fe.getName();
    if (!(fe.getExt()).equals("")) { // NOI18N
        result = result + "." + fe.getExt(); // NOI18N
    }
    return result;
}
 
Example 6
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 7
Source File: ServerResourceNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private String getOldFileName(FileRenameEvent fe) {
    String result = fe.getName();
    if (fe.getExt() != "") // NOI18N
        result = result + "." + fe.getExt(); // NOI18N

    return result;
}
 
Example 8
Source File: CopySupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(FileRenameEvent fe) {
    FileObject source = getValidProjectSource(fe);
    if (source == null) {
        return;
    }
    LOGGER.log(Level.FINE, "Processing event FILE RENAMED for project {0}", project.getName());
    String originalName = fe.getName();
    String ext = fe.getExt();
    if (StringUtils.hasText(ext)) {
        originalName += "." + ext; // NOI18N
    }
    prepareOperation(proxyOperationFactory.createRenameHandler(source, originalName, fe));
}
 
Example 9
Source File: NativeExecutionBaseTestCase.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void register(String eventKind, FileEvent fe) {
    String src = stripPrefix(((FileObject) fe.getSource()).getPath());
    String obj = stripPrefix(fe.getFile().getPath());
    String exp = checkExpected ? ("exp=" + Boolean.toString(fe.isExpected())) : "";
    String extra = "";
    if (fe instanceof FileRenameEvent) {
        FileRenameEvent fre = (FileRenameEvent) fe;
        extra = "oldName="+fre.getName()+" oldExt="+fre.getExt();
    }
    out.printf("%-20s: %-20s SRC %-20s OBJ %-20s %s %s\n", listenerName, eventKind, src, obj, exp, extra);
}
 
Example 10
Source File: FileChangeSupport.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void fileRenamed(final FileRenameEvent fe) {
    final String oldExt = fe.getExt();
    final String newExt = fe.getFile().getExt();
    sourceControl.sourceChanged(!Objects.equals(oldExt, newExt));
    sourceControl.revalidate(SourceEnvironment.getReparseDelay(false));
}