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
.svn
.actions
;
18 import com
.intellij
.openapi
.project
.Project
;
19 import com
.intellij
.openapi
.vcs
.changes
.ChangeListManager
;
20 import com
.intellij
.openapi
.vcs
.impl
.ExcludedFileIndex
;
21 import com
.intellij
.openapi
.vfs
.VirtualFile
;
22 import org
.tmatesoft
.svn
.core
.SVNDepth
;
23 import org
.tmatesoft
.svn
.core
.SVNException
;
25 public class SvnExcludingIgnoredOperation
{
26 private final Operation myImportAction
;
27 private final SVNDepth myDepth
;
28 private final Filter myFilter
;
30 public SvnExcludingIgnoredOperation(final Project project
, final Operation importAction
, final SVNDepth depth
) {
31 myImportAction
= importAction
;
34 myFilter
= new Filter(project
);
37 public static class Filter
{
38 private final Project myProject
;
39 private final ExcludedFileIndex myIndex
;
40 private final ChangeListManager myClManager
;
42 public Filter(final Project project
) {
45 if (! project
.isDefault()) {
46 myIndex
= ExcludedFileIndex
.getInstance(project
);
47 myClManager
= ChangeListManager
.getInstance(project
);
54 public boolean accept(final VirtualFile file
) {
55 if (! myProject
.isDefault()) {
56 if (myIndex
.isExcludedFile(file
)) {
59 if (myClManager
.isIgnoredFile(file
)) {
67 private boolean operation(final VirtualFile file
) throws SVNException
{
68 if (! myFilter
.accept(file
)) return false;
70 myImportAction
.doOperation(file
);
74 private void executeDown(final VirtualFile file
) throws SVNException
{
75 if (! operation(file
)) {
79 for (VirtualFile child
: file
.getChildren()) {
84 public void execute(final VirtualFile file
) throws SVNException
{
85 if (SVNDepth
.INFINITY
.equals(myDepth
)) {
90 if (! operation(file
)) {
94 if (SVNDepth
.EMPTY
.equals(myDepth
)) {
98 for (VirtualFile child
: file
.getChildren()) {
99 if (SVNDepth
.FILES
.equals(myDepth
) && child
.isDirectory()) {
106 public interface Operation
{
107 void doOperation(final VirtualFile file
) throws SVNException
;