Merge branch 'master' of git.labs.intellij.net:idea/community
[idea/community.git] / plugins / hg4idea / testSrc / org / zmlx / hg4idea / test / HgMockVcsHelper.java
1 /*
2  * Copyright 2000-2010 JetBrains s.r.o.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 package org.zmlx.hg4idea.test;
17
18 import com.intellij.ide.errorTreeView.HotfixData;
19 import com.intellij.openapi.vcs.*;
20 import com.intellij.openapi.vcs.annotate.AnnotationProvider;
21 import com.intellij.openapi.vcs.annotate.FileAnnotation;
22 import com.intellij.openapi.vcs.changes.Change;
23 import com.intellij.openapi.vcs.history.VcsFileRevision;
24 import com.intellij.openapi.vcs.history.VcsHistoryProvider;
25 import com.intellij.openapi.vcs.merge.MergeProvider;
26 import com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings;
27 import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
28 import com.intellij.openapi.vfs.VirtualFile;
29 import gnu.trove.THashSet;
30 import org.jetbrains.annotations.Nls;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
33
34 import java.awt.*;
35 import java.io.File;
36 import java.util.Collection;
37 import java.util.List;
38 import java.util.Map;
39
40 /**
41  * Substitutes AbstractVcsHelperImpl for tests, where dialogs need to be tested.
42  * Currently it's just a stub implementation notifying listeners about action invoked (which would mean than a dialog would have been
43  * shown during normal execution).
44  * @author Kirill Likhodedov
45  */
46 public class HgMockVcsHelper extends AbstractVcsHelper {
47
48   private Collection<VcsHelperListener> myListeners = new THashSet<VcsHelperListener>();
49
50   @Override
51   public void showErrors(List<VcsException> abstractVcsExceptions, @NotNull String tabDisplayName) {
52   }
53
54   @Override
55   public void showErrors(Map<HotfixData, List<VcsException>> exceptionGroups, @NotNull String tabDisplayName) {
56   }
57
58   @Override
59   public List<VcsException> runTransactionRunnable(AbstractVcs vcs, TransactionRunnable runnable, Object vcsParameters) {
60     return null;
61   }
62
63   @Override
64   public void showAnnotation(FileAnnotation annotation, VirtualFile file, AbstractVcs vcs) {
65   }
66
67   @Override
68   public void showDifferences(VcsFileRevision cvsVersionOn, VcsFileRevision cvsVersionOn1, File file) {
69   }
70
71   @Override
72   public void showChangesListBrowser(CommittedChangeList changelist, @Nls String title) {
73   }
74
75   @Override
76   public void showChangesBrowser(List<CommittedChangeList> changelists) {
77   }
78
79   @Override
80   public void showChangesBrowser(List<CommittedChangeList> changelists, @Nls String title) {
81   }
82
83   @Override
84   public void showChangesBrowser(CommittedChangesProvider provider,
85                                  RepositoryLocation location,
86                                  @Nls String title,
87                                  @Nullable Component parent) {
88   }
89
90   @Override
91   public void showWhatDiffersBrowser(@Nullable Component parent, Collection<Change> changes, @Nls String title) {
92   }
93
94   @Override
95   public <T extends CommittedChangeList, U extends ChangeBrowserSettings> T chooseCommittedChangeList(CommittedChangesProvider<T, U> provider,
96                                                                                                       RepositoryLocation location) {
97     return null;
98   }
99
100   @Override
101   public void openCommittedChangesTab(AbstractVcs vcs, VirtualFile root, ChangeBrowserSettings settings, int maxCount, String title) {
102   }
103
104   @Override
105   public void openCommittedChangesTab(CommittedChangesProvider provider,
106                                       RepositoryLocation location,
107                                       ChangeBrowserSettings settings,
108                                       int maxCount,
109                                       String title) {
110   }
111
112   @NotNull
113   @Override
114   public List<VirtualFile> showMergeDialog(List<VirtualFile> files, MergeProvider provider) {
115     return null;
116   }
117
118   @NotNull
119   @Override
120   public List<VirtualFile> showMergeDialog(List<VirtualFile> files) {
121     return null;
122   }
123
124   @Override
125   public void showFileHistory(VcsHistoryProvider vcsHistoryProvider, FilePath path, AbstractVcs vcs, String repositoryPath) {
126   }
127
128   @Override
129   public void showFileHistory(VcsHistoryProvider vcsHistoryProvider,
130                               AnnotationProvider annotationProvider,
131                               FilePath path,
132                               String repositoryPath,
133                               AbstractVcs vcs) {
134   }
135
136   @Override
137   public void showRollbackChangesDialog(List<Change> changes) {
138   }
139
140   @Nullable
141   @Override
142   public Collection<VirtualFile> selectFilesToProcess(List<VirtualFile> files,
143                                                       String title,
144                                                       @Nullable String prompt,
145                                                       String singleFileTitle,
146                                                       String singleFilePromptTemplate,
147                                                       VcsShowConfirmationOption confirmationOption) {
148     notifyListeners();
149     return null;
150   }
151   
152   @Nullable
153   @Override
154   public Collection<FilePath> selectFilePathsToProcess(List<FilePath> files,
155                                                        String title,
156                                                        @Nullable String prompt,
157                                                        String singleFileTitle,
158                                                        String singleFilePromptTemplate,
159                                                        VcsShowConfirmationOption confirmationOption) {
160     notifyListeners();
161     return null;
162   }
163
164   public void addListener(VcsHelperListener listener) {
165     myListeners.add(listener);
166   }
167
168   private void notifyListeners() {
169     for (VcsHelperListener listener : myListeners) {
170       listener.dialogInvoked();
171     }
172   }
173
174 }