ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / plugins / maven / src / main / java / org / jetbrains / idea / maven / utils / FileFinder.java
blob0e968753e55e9f01ea0dadeddf23141a56bba597
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.maven.utils;
18 import com.intellij.openapi.application.ApplicationManager;
19 import com.intellij.openapi.progress.ProgressIndicator;
20 import com.intellij.openapi.util.Computable;
21 import com.intellij.openapi.vfs.LocalFileSystem;
22 import com.intellij.openapi.vfs.VirtualFile;
23 import org.jetbrains.idea.maven.utils.MavenConstants;
25 import java.util.List;
27 /**
28 * @author Vladislav.Kaznacheev
30 public class FileFinder {
31 public static List<VirtualFile> findPomFiles(VirtualFile[] roots,
32 boolean lookForNested,
33 ProgressIndicator indicator,
34 List<VirtualFile> result) {
35 for (VirtualFile f : roots) {
36 if (indicator.isCanceled()) break;
37 indicator.setText2(f.getPath());
39 if (f.isDirectory()) {
40 if (lookForNested) {
41 findPomFiles(f.getChildren(), lookForNested, indicator, result);
44 else {
45 if (f.getName().equalsIgnoreCase(MavenConstants.POM_XML)) {
46 result.add(f);
51 return result;
54 public static VirtualFile refreshRecursively(final String path) {
55 return ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
56 @SuppressWarnings({"ConstantConditions"})
57 public VirtualFile compute() {
58 final VirtualFile dir = LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
59 if (dir != null) {
60 dir.refresh(false, true);
62 return dir;
64 });