IDEADEV-41062 (Map help button of "Import into Subversion" dialog box)
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / IgnoredFileInfo.java
blob9438ed566c38dbb1baf5992b5671a1eb909ae5d5
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.svn;
18 import com.intellij.openapi.diagnostic.Logger;
19 import org.tmatesoft.svn.core.SVNDepth;
20 import org.tmatesoft.svn.core.SVNException;
21 import org.tmatesoft.svn.core.internal.wc.DefaultSVNOptions;
22 import org.tmatesoft.svn.core.wc.ISVNStatusHandler;
23 import org.tmatesoft.svn.core.wc.SVNRevision;
24 import org.tmatesoft.svn.core.wc.SVNStatus;
25 import org.tmatesoft.svn.core.wc.SVNStatusType;
27 import java.io.File;
28 import java.util.*;
30 public class IgnoredFileInfo {
31 private static final Logger LOG = Logger.getInstance("#org.jetbrains.idea.svn.IgnoredFileInfo");
33 // directory for which properties are collected
34 private final File myFile;
35 private final List<String> myPatterns;
36 private final Set<String> myFileNames;
37 private final Set<String> myOldPatterns;
39 public IgnoredFileInfo(final File file, final Set<String> oldPatterns) {
40 myFile = file;
41 myPatterns = new ArrayList<String>();
42 myFileNames = new HashSet<String>();
43 myOldPatterns = oldPatterns;
46 public void addFileName(final String name) {
47 myFileNames.add(name);
50 public void addPattern(final String value) {
51 myPatterns.add(value);
54 public void calculatePatterns(final SvnVcs vcs) {
55 final List<String> names = new ArrayList<String>();
56 try {
57 vcs.createStatusClient().doStatus(myFile, SVNRevision.WORKING, SVNDepth.IMMEDIATES, false, true, true, false, new ISVNStatusHandler() {
58 public void handleStatus(SVNStatus status) throws SVNException {
59 if (SVNStatusType.STATUS_IGNORED == status.getContentsStatus()) {
60 final String name = status.getFile().getName();
61 if (! myFileNames.contains(name)) {
62 names.add(name);
66 }, null);
68 catch (SVNException e) {
69 LOG.info(e);
72 for (String pattern : myOldPatterns) {
73 boolean usedSomewhereElse = false;
74 for (String name : names) {
75 if (DefaultSVNOptions.matches(pattern, name)) {
76 usedSomewhereElse = true;
77 break;
81 if (! usedSomewhereElse) {
82 for (String name : myFileNames) {
83 if (DefaultSVNOptions.matches(pattern, name)) {
84 myPatterns.add(pattern);
85 break;
92 public File getFile() {
93 return myFile;
96 public List<String> getPatterns() {
97 return myPatterns;
100 public Set<String> getFileNames() {
101 return myFileNames;
104 public Set<String> getOldPatterns() {
105 return myOldPatterns;