vcs: Removed unused "VcsEventsListenerManager"
[idea/community.git] / platform / vcs-api / src / com / intellij / openapi / vcs / ProjectLevelVcsManager.java
1 /*
2  * Copyright 2000-2013 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 com.intellij.openapi.vcs;
17
18 import com.intellij.execution.ui.ConsoleViewContentType;
19 import com.intellij.lifecycle.PeriodicalTasksCloser;
20 import com.intellij.openapi.application.ApplicationManager;
21 import com.intellij.openapi.editor.markup.TextAttributes;
22 import com.intellij.openapi.progress.ProcessCanceledException;
23 import com.intellij.openapi.project.Project;
24 import com.intellij.openapi.util.Computable;
25 import com.intellij.openapi.vcs.changes.VcsAnnotationLocalChangesListener;
26 import com.intellij.openapi.vcs.history.VcsHistoryCache;
27 import com.intellij.openapi.vcs.impl.ContentRevisionCache;
28 import com.intellij.openapi.vcs.impl.VcsDescriptor;
29 import com.intellij.openapi.vcs.update.UpdatedFiles;
30 import com.intellij.openapi.vfs.VirtualFile;
31 import com.intellij.util.Processor;
32 import com.intellij.util.messages.Topic;
33 import org.jetbrains.annotations.NonNls;
34 import org.jetbrains.annotations.NotNull;
35 import org.jetbrains.annotations.Nullable;
36
37 import java.util.List;
38
39 /**
40  * Manages the version control systems used by a specific project.
41  */
42 public abstract class ProjectLevelVcsManager {
43
44   public static final Topic<VcsListener> VCS_CONFIGURATION_CHANGED = Topic.create("VCS configuration changed", VcsListener.class);
45   public static final Topic<VcsListener> VCS_CONFIGURATION_CHANGED_IN_PLUGIN = Topic.create("VCS configuration changed in VCS plugin", VcsListener.class);
46
47   public abstract void iterateVfUnderVcsRoot(VirtualFile file, Processor<VirtualFile> processor);
48
49   /**
50    * Returns the <code>ProjectLevelVcsManager<code> instance for the specified project.
51    *
52    * @param project the project for which the instance is requested.
53    * @return the manager instance.
54    */
55   public static ProjectLevelVcsManager getInstance(Project project) {
56     return PeriodicalTasksCloser.getInstance().safeGetComponent(project, ProjectLevelVcsManager.class);
57   }
58
59   /**
60    * Gets the instance of the component if the project wasn't disposed. If the project was
61    * disposed, throws ProcessCanceledException. Should only be used for calling from background
62    * threads (for example, committed changes refresh thread).
63    *
64    * @param project the project for which the component instance should be retrieved.
65    * @return component instance
66    */
67   public static ProjectLevelVcsManager getInstanceChecked(final Project project) {
68     return ApplicationManager.getApplication().runReadAction(new Computable<ProjectLevelVcsManager>() {
69       public ProjectLevelVcsManager compute() {
70         if (project.isDisposed()) throw new ProcessCanceledException();
71         return getInstance(project);
72       }
73     });
74   }
75
76   /**
77    * Returns the list of all registered version control systems.
78    *
79    * @return the list of registered version control systems.
80    */
81   public abstract VcsDescriptor[] getAllVcss();
82
83   /**
84    * Returns the version control system with the specified name.
85    *
86    * @param name the name of the VCS to find.
87    * @return the VCS instance, or null if none is found.
88    */
89   @Nullable
90   public abstract AbstractVcs findVcsByName(@NonNls String name);
91
92   @Nullable
93   public abstract VcsDescriptor getDescriptor(final String name);
94   /**
95    * Checks if all files in the specified array are managed by the specified VCS.
96    *
97    * @param abstractVcs the VCS to check.
98    * @param files       the files to check.
99    * @return true if all files are managed by the VCS, false otherwise.
100    */
101   public abstract boolean checkAllFilesAreUnder(AbstractVcs abstractVcs, VirtualFile[] files);
102
103   /**
104    * Returns the VCS managing the specified file.
105    *
106    * @param file the file to check.
107    * @return the VCS instance, or null if the file does not belong to any module or the module
108    *         it belongs to is not under version control.
109    */
110   @Nullable
111   public abstract AbstractVcs getVcsFor(@NotNull VirtualFile file);
112
113   /**
114    * Returns the VCS managing the specified file path.
115    *
116    * @param file the file to check.
117    * @return the VCS instance, or null if the file does not belong to any module or the module
118    *         it belongs to is not under version control.
119    */
120   @Nullable
121   public abstract AbstractVcs getVcsFor(FilePath file);
122
123   /**
124    * Return the parent directory of the specified file which is mapped to a VCS.
125    *
126    * @param file the file for which the root is requested.
127    * @return the root, or null if the specified file is not in a VCS-managed directory.
128    */
129   @Nullable
130   public abstract VirtualFile getVcsRootFor(@Nullable VirtualFile file);
131
132   /**
133    * Return the parent directory of the specified file path which is mapped to a VCS.
134    *
135    * @param file the file for which the root is requested.
136    * @return the root, or null if the specified file is not in a VCS-managed directory.
137    */
138   @Nullable
139   public abstract VirtualFile getVcsRootFor(FilePath file);
140
141   @Nullable
142   public abstract VcsRoot getVcsRootObjectFor(final VirtualFile file);
143   
144   @Nullable
145   public abstract VcsRoot getVcsRootObjectFor(FilePath file);
146
147   /**
148    * Checks if the specified VCS is used by any of the modules in the project.
149    *
150    * @param vcs the VCS to check.
151    * @return true if the VCS is used by any of the modules, false otherwise
152    */
153   public abstract boolean checkVcsIsActive(AbstractVcs vcs);
154
155   /**
156    * Checks if the VCS with the specified name is used by any of the modules in the project.
157    *
158    * @param vcsName the name of the VCS to check.
159    * @return true if the VCS is used by any of the modules, false otherwise
160    */
161   public abstract boolean checkVcsIsActive(@NonNls String vcsName);
162
163   /**
164    * Returns the list of VCSes used by at least one module in the project.
165    *
166    * @return the list of VCSes used in the project.
167    */
168   public abstract AbstractVcs[] getAllActiveVcss();
169
170   public abstract boolean hasActiveVcss();
171
172   public abstract boolean hasAnyMappings();
173
174   @Deprecated
175   public abstract void addMessageToConsoleWindow(String message, TextAttributes attributes);
176
177   public abstract void addMessageToConsoleWindow(@Nullable String message, @NotNull ConsoleViewContentType contentType);
178
179   @NotNull
180   public abstract VcsShowSettingOption getStandardOption(@NotNull VcsConfiguration.StandardOption option,
181                                                          @NotNull AbstractVcs vcs);
182
183   @NotNull
184   public abstract VcsShowConfirmationOption getStandardConfirmation(@NotNull VcsConfiguration.StandardConfirmation option,
185                                                                     AbstractVcs vcs);
186
187   @NotNull
188   public abstract VcsShowSettingOption getOrCreateCustomOption(@NotNull String vcsActionName,
189                                                                @NotNull AbstractVcs vcs);
190
191
192   public abstract void showProjectOperationInfo(final UpdatedFiles updatedFiles, String displayActionName);
193
194   /**
195    * Adds a listener for receiving notifications about changes in VCS configuration for the project.
196    *
197    * @param listener the listener instance.
198    * @deprecated use {@link #VCS_CONFIGURATION_CHANGED} instead
199    * @since 6.0
200    */
201   @Deprecated
202   public abstract void addVcsListener(VcsListener listener);
203
204   /**
205    * Removes a listener for receiving notifications about changes in VCS configuration for the project.
206    *
207    * @param listener the listener instance.
208    * @deprecated use {@link #VCS_CONFIGURATION_CHANGED} instead
209    * @since 6.0
210    */
211   @Deprecated
212   public abstract void removeVcsListener(VcsListener listener);
213
214   /**
215    * Marks the beginning of a background VCS operation (commit or update).
216    *
217    * @since 6.0
218    */
219   public abstract void startBackgroundVcsOperation();
220
221   /**
222    * Marks the end of a background VCS operation (commit or update).
223    *
224    * @since 6.0
225    */
226   public abstract void stopBackgroundVcsOperation();
227
228   /**
229    * Checks if a background VCS operation (commit or update) is currently in progress.
230    *
231    * @return true if a background operation is in progress, false otherwise.
232    * @since 6.0
233    */
234   public abstract boolean isBackgroundVcsOperationRunning();
235
236   public abstract List<VirtualFile> getRootsUnderVcsWithoutFiltering(final AbstractVcs vcs);
237
238   public abstract VirtualFile[] getRootsUnderVcs(@NotNull AbstractVcs vcs);
239
240   /**
241    * Also includes into list all modules under roots
242    */
243   public abstract List<VirtualFile> getDetailedVcsMappings(final AbstractVcs vcs);
244
245   public abstract VirtualFile[] getAllVersionedRoots();
246
247   @NotNull
248   public abstract VcsRoot[] getAllVcsRoots();
249
250   public abstract void updateActiveVcss();
251
252   public abstract List<VcsDirectoryMapping> getDirectoryMappings();
253   public abstract List<VcsDirectoryMapping> getDirectoryMappings(AbstractVcs vcs);
254
255   @Nullable
256   public abstract VcsDirectoryMapping getDirectoryMappingFor(FilePath path);
257
258   /**
259    * This method can be used only when initially loading the project configuration!
260    */
261   public abstract void setDirectoryMapping(final String path, final String activeVcsName);
262
263   public abstract void setDirectoryMappings(final List<VcsDirectoryMapping> items);
264
265   public abstract void iterateVcsRoot(final VirtualFile root, final Processor<FilePath> iterator);
266   
267   public abstract void iterateVcsRoot(final VirtualFile root, final Processor<FilePath> iterator,
268                                       @Nullable VirtualFileFilter directoryFilter);
269
270   @Nullable
271   public abstract AbstractVcs findVersioningVcs(VirtualFile file);
272
273   public abstract CheckoutProvider.Listener getCompositeCheckoutListener();
274
275   public abstract VcsHistoryCache getVcsHistoryCache();
276   public abstract ContentRevisionCache getContentRevisionCache();
277   public abstract boolean isFileInContent(final VirtualFile vf);
278   public abstract boolean isIgnored(VirtualFile vf);
279
280   @NotNull
281   public abstract VcsAnnotationLocalChangesListener getAnnotationLocalChangesListener();
282 }