Search in sources :

Example 1 with NonRecursiveFolder

use of org.netbeans.api.fileinfo.NonRecursiveFolder in project netbeans-mmd-plugin by raydac.

the class AbstractPlugin method findFileObjectInLookup.

private Collection<? extends FileObject> findFileObjectInLookup(final Lookup lookup) {
    final Collection<? extends FileObject> files = lookup.lookupAll(FileObject.class);
    final Collection<? extends NonRecursiveFolder> folders = lookup.lookupAll(NonRecursiveFolder.class);
    final Set<FileObject> result = new HashSet<FileObject>();
    for (final NonRecursiveFolder f : folders) {
        result.add(f.getFolder());
    }
    result.addAll(files);
    final Collection<? extends TreePathHandle> treePaths = lookup.lookupAll(TreePathHandle.class);
    for (final TreePathHandle h : treePaths) {
        result.add(h.getFileObject());
    }
    return result;
}
Also used : TreePathHandle(org.netbeans.api.java.source.TreePathHandle) NonRecursiveFolder(org.netbeans.api.fileinfo.NonRecursiveFolder) FileObject(org.openide.filesystems.FileObject)

Example 2 with NonRecursiveFolder

use of org.netbeans.api.fileinfo.NonRecursiveFolder in project netbeans-mmd-plugin by raydac.

the class AbstractPlugin method allMapsInProject.

protected Collection<FileObject> allMapsInProject(final Project project) {
    final Collection<? extends Scope> scopes = this.refactoring.getRefactoringSource().lookupAll(Scope.class);
    if (!scopes.isEmpty()) {
        final Collection<FileObject> mindMaps = new HashSet<FileObject>();
        for (final Scope s : scopes) {
            for (final NonRecursiveFolder f : s.getFolders()) {
                synchronized (this.cache) {
                    Collection<FileObject> found = this.cache.get(f.getFolder());
                    if (found == null) {
                        found = RefactoringUtils.findAllMindMapsInFolder(f, this);
                        this.cache.put(f.getFolder(), found);
                    }
                    mindMaps.addAll(found);
                }
            }
        }
        return mindMaps;
    } else {
        if (project == null) {
            return Collections.<FileObject>emptyList();
        }
        final FileObject projectFolder = project.getProjectDirectory();
        synchronized (this.cache) {
            Collection<FileObject> result = this.cache.get(projectFolder);
            if (result == null) {
                result = RefactoringUtils.findAllMindMapsInProject(project, this);
                this.cache.put(projectFolder, result);
            }
            return result;
        }
    }
}
Also used : Scope(org.netbeans.modules.refactoring.api.Scope) NonRecursiveFolder(org.netbeans.api.fileinfo.NonRecursiveFolder) FileObject(org.openide.filesystems.FileObject)

Aggregations

NonRecursiveFolder (org.netbeans.api.fileinfo.NonRecursiveFolder)2 FileObject (org.openide.filesystems.FileObject)2 TreePathHandle (org.netbeans.api.java.source.TreePathHandle)1 Scope (org.netbeans.modules.refactoring.api.Scope)1