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
;
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()) {
41 findPomFiles(f
.getChildren(), lookForNested
, indicator
, result
);
45 if (f
.getName().equalsIgnoreCase(MavenConstants
.POM_XML
)) {
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
);
60 dir
.refresh(false, true);