SVN auth
[fedora-idea.git] / plugins / svn4idea / src / org / jetbrains / idea / svn / SvnCompatibilityChecker.java
blob509a3b71914ae05a284130f2e7d04a8ca54d10c2
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.application.Application;
19 import com.intellij.openapi.application.ApplicationManager;
20 import com.intellij.openapi.application.ModalityState;
21 import com.intellij.openapi.project.Project;
22 import com.intellij.openapi.ui.MessageType;
23 import com.intellij.openapi.vcs.changes.ui.ChangesViewBalloonProblemNotifier;
24 import com.intellij.openapi.vfs.VirtualFile;
26 import java.util.ArrayList;
27 import java.util.List;
29 public class SvnCompatibilityChecker {
30 private final Project myProject;
31 private final static long ourFrequency = 10;
32 private final static long ourInvocationMax = 10;
33 private final static long ourInitCounter = 3;
35 private long myCounter;
36 private long myDownStartCounter;
37 private long myInvocationCounter;
39 private final Object myLock = new Object();
41 public SvnCompatibilityChecker(Project project) {
42 myProject = project;
43 myCounter= 0;
44 myDownStartCounter = ourInitCounter;
45 myInvocationCounter = 0;
48 public void reportNoRoots(final List<VirtualFile> result) {
49 synchronized (myLock) {
50 if (myInvocationCounter >= ourInvocationMax) return;
51 ++ myCounter;
52 -- myDownStartCounter;
53 if ((myCounter > ourFrequency) || (myDownStartCounter >= 0)) {
54 myCounter = 0;
55 ++ myInvocationCounter;
56 final Application application = ApplicationManager.getApplication();
57 application.executeOnPooledThread(new Runnable() {
58 public void run() {
59 final List<VirtualFile> suspicious = new ArrayList<VirtualFile>();
60 for (VirtualFile vf : result) {
61 if (SvnUtil.seemsLikeVersionedDir(vf)) {
62 suspicious.add(vf);
65 if (! suspicious.isEmpty()) {
66 final String message = (suspicious.size() == 1) ?
67 "Root '" + suspicious.get(0).getPresentableName() + "' is likely to be of unsupported Subversion format" :
68 "Some roots are likely to be of unsupported Subversion format";
69 application.invokeLater(new Runnable() {
70 public void run() {
71 new ChangesViewBalloonProblemNotifier(myProject, message, MessageType.WARNING).run();
73 }, ModalityState.NON_MODAL);
76 });