com.intellij.openapi.vcs.ProjectLevelVcsManager Java Examples
The following examples show how to use
com.intellij.openapi.vcs.ProjectLevelVcsManager.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VcsBackgroundableComputable.java From consulo with Apache License 2.0 | 6 votes |
private static <T> void createAndRun(final Project project, @javax.annotation.Nullable final VcsBackgroundableActions actionKey, @javax.annotation.Nullable final Object actionParameter, final String title, final String errorTitle, final ThrowableComputable<T, VcsException> backgroundable, @javax.annotation.Nullable final Consumer<T> awtSuccessContinuation, @Nullable final Runnable awtErrorContinuation, final boolean silent) { final ProjectLevelVcsManagerImpl vcsManager = (ProjectLevelVcsManagerImpl) ProjectLevelVcsManager.getInstance(project); final BackgroundableActionEnabledHandler handler; if (actionKey != null) { handler = vcsManager.getBackgroundableActionHandler(actionKey); // fo not start same action twice if (handler.isInProgress(actionParameter)) return; } else { handler = null; } final VcsBackgroundableComputable<T> backgroundableComputable = new VcsBackgroundableComputable<T>(project, title, errorTitle, backgroundable, awtSuccessContinuation, awtErrorContinuation, handler, actionParameter); backgroundableComputable.setSilent(silent); if (handler != null) { handler.register(actionParameter); } ProgressManager.getInstance().run(backgroundableComputable); }
Example #2
Source File: VcsSyncListener.java From intellij with Apache License 2.0 | 6 votes |
/** * Asynchronously notifies all available {@link VcsSyncListener}s of a VCS sync event, for all * open projects with the given VCS root. */ static void notifyVcsSync(VirtualFile vcsRoot) { List<Project> projects = Arrays.stream(ProjectManager.getInstance().getOpenProjects()) .filter(p -> ProjectLevelVcsManager.getInstance(p).getVcsFor(vcsRoot) != null) .collect(Collectors.toList()); if (projects.isEmpty()) { return; } @SuppressWarnings("unused") Future<?> ignored = ApplicationManager.getApplication() .executeOnPooledThread( () -> projects.forEach( p -> { for (VcsSyncListener l : EP_NAME.getExtensions()) { l.onVcsSync(p); } })); }
Example #3
Source File: UpdateRequestsQueue.java From consulo with Apache License 2.0 | 6 votes |
public UpdateRequestsQueue(final Project project, @Nonnull ChangeListManagerImpl.Scheduler scheduler, final Runnable delegate) { myProject = project; myScheduler = scheduler; myTrackHeavyLatch = Boolean.parseBoolean(System.getProperty(ourHeavyLatchOptimization)); myDelegate = delegate; myPlVcsManager = ProjectLevelVcsManager.getInstance(myProject); myStartupManager = StartupManager.getInstance(myProject); myLock = new Object(); myWaitingUpdateCompletionQueue = new ArrayList<>(); // not initialized myStarted = false; myStopped = false; myIsStoppedGetter = new Getter<Boolean>() { @Override public Boolean get() { return isStopped(); } }; }
Example #4
Source File: ChangesViewManager.java From consulo with Apache License 2.0 | 6 votes |
private void refreshView() { if (myDisposed || !myProject.isInitialized() || ApplicationManager.getApplication().isUnitTestMode()) return; if (!ProjectLevelVcsManager.getInstance(myProject).hasActiveVcss()) return; ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(myProject); TreeModelBuilder treeModelBuilder = new TreeModelBuilder(myProject, myView.isShowFlatten()).setChangeLists(changeListManager.getChangeListsCopy()).setLocallyDeletedPaths(changeListManager.getDeletedFiles()) .setModifiedWithoutEditing(changeListManager.getModifiedWithoutEditing()).setSwitchedFiles(changeListManager.getSwitchedFilesMap()) .setSwitchedRoots(changeListManager.getSwitchedRoots()).setLockedFolders(changeListManager.getLockedFolders()) .setLogicallyLockedFiles(changeListManager.getLogicallyLockedFolders()).setUnversioned(changeListManager.getUnversionedFiles()); if (myState.myShowIgnored) { treeModelBuilder.setIgnored(changeListManager.getIgnoredFiles(), changeListManager.isIgnoredInUpdateMode()); } myView.updateModel(treeModelBuilder.build()); changeDetails(); }
Example #5
Source File: TodoView.java From consulo with Apache License 2.0 | 6 votes |
@Override public void directoryMappingChanged() { ApplicationManager.getApplication().invokeLater(() -> { if (myContentManager == null || myProject.isDisposed()) { // was not initialized yet return; } boolean hasActiveVcss = ProjectLevelVcsManager.getInstance(myProject).hasActiveVcss(); if (myIsVisible && !hasActiveVcss) { myContentManager.removeContent(myChangeListTodosContent, false); myIsVisible = false; } else if (!myIsVisible && hasActiveVcss) { myContentManager.addContent(myChangeListTodosContent); myIsVisible = true; } }, ModalityState.NON_MODAL); }
Example #6
Source File: ShowGraphHistoryAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); if (!Registry.is("vcs.log.graph.history")) { presentation.setEnabledAndVisible(false); } else { VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); Project project = e.getProject(); if (file == null || project == null) { presentation.setEnabledAndVisible(false); } else { VirtualFile root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(file); VcsLogData dataManager = VcsProjectLog.getInstance(project).getDataManager(); if (root == null || dataManager == null) { presentation.setEnabledAndVisible(false); } else { presentation.setVisible(dataManager.getRoots().contains(root)); presentation.setEnabled(dataManager.getIndex().isIndexed(root)); } } } }
Example #7
Source File: ContentRevisionCache.java From consulo with Apache License 2.0 | 6 votes |
public static Pair<VcsRevisionNumber, byte[]> getOrLoadCurrentAsBytes(final Project project, FilePath path, @Nonnull VcsKey vcsKey, final CurrentRevisionProvider loader) throws VcsException, IOException { ContentRevisionCache cache = ProjectLevelVcsManager.getInstance(project).getContentRevisionCache(); VcsRevisionNumber currentRevision; Pair<VcsRevisionNumber, byte[]> loaded; while (true) { currentRevision = putIntoCurrentCache(cache, path, vcsKey, loader); final byte[] cachedCurrent = cache.getBytes(path, currentRevision, vcsKey, UniqueType.REPOSITORY_CONTENT); if (cachedCurrent != null) { return Pair.create(currentRevision, cachedCurrent); } checkLocalFileSize(path); loaded = loader.get(); if (loaded.getFirst().equals(currentRevision)) break; } cache.put(path, currentRevision, vcsKey, UniqueType.REPOSITORY_CONTENT, loaded.getSecond()); return loaded; }
Example #8
Source File: AbstractCommonCheckinAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(@Nonnull VcsContext context) { LOG.debug("actionPerformed. "); Project project = ObjectUtils.notNull(context.getProject()); if (ChangeListManager.getInstance(project).isFreezedWithNotification("Can not " + getMnemonicsFreeActionName(context) + " now")) { LOG.debug("ChangeListManager is freezed. returning."); } else if (ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning()) { LOG.debug("Background operation is running. returning."); } else { FilePath[] roots = prepareRootsForCommit(getRoots(context), project); ChangeListManager.getInstance(project) .invokeAfterUpdate(() -> performCheckIn(context, project, roots), InvokeAfterUpdateMode.SYNCHRONOUS_CANCELLABLE, VcsBundle.message("waiting.changelists.update.for.show.commit.dialog.message"), ModalityState.current()); } }
Example #9
Source File: AbstractCommonCheckinAction.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(@Nonnull VcsContext vcsContext, @Nonnull Presentation presentation) { Project project = vcsContext.getProject(); if (project == null || !ProjectLevelVcsManager.getInstance(project).hasActiveVcss()) { presentation.setEnabledAndVisible(false); } else if (!approximatelyHasRoots(vcsContext)) { presentation.setEnabled(false); } else { presentation.setText(getActionName(vcsContext) + "..."); presentation.setEnabled(!ProjectLevelVcsManager.getInstance(project).isBackgroundVcsOperationRunning()); presentation.setVisible(true); } }
Example #10
Source File: SelectAndCompareWithSelectedRevisionAction.java From consulo with Apache License 2.0 | 6 votes |
protected void actionPerformed(VcsContext vcsContext) { final VirtualFile file = vcsContext.getSelectedFiles()[0]; final Project project = vcsContext.getProject(); final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file); if (vcs == null) { return; } RevisionSelector selector = vcs.getRevisionSelector(); final DiffProvider diffProvider = vcs.getDiffProvider(); if (selector != null) { final VcsRevisionNumber vcsRevisionNumber = selector.selectNumber(file); if (vcsRevisionNumber != null) { DiffActionExecutor.showDiff(diffProvider, vcsRevisionNumber, file, project, VcsBackgroundableActions.COMPARE_WITH); } } }
Example #11
Source File: VcsQuickListPopupAction.java From consulo with Apache License 2.0 | 6 votes |
private Pair<SupportedVCS, AbstractVcs> getActiveVCS(@Nonnull final Project project, @javax.annotation.Nullable final DataContext dataContext) { final AbstractVcs[] activeVcss = getActiveVCSs(project); if (activeVcss.length == 0) { // no vcs return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.NOT_IN_VCS, null); } else if (activeVcss.length == 1) { // get by name return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, activeVcss[0]); } // by current file final VirtualFile file = dataContext != null ? dataContext.getData(PlatformDataKeys.VIRTUAL_FILE) : null; if (file != null) { final AbstractVcs vscForFile = ProjectLevelVcsManager.getInstance(project).getVcsFor(file); if (vscForFile != null) { return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, vscForFile); } } return new Pair<SupportedVCS, AbstractVcs>(SupportedVCS.VCS, null); }
Example #12
Source File: MoveChangesToAnotherListAction.java From consulo with Apache License 2.0 | 5 votes |
protected boolean isEnabled(@Nonnull AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null || !ProjectLevelVcsManager.getInstance(project).hasActiveVcss()) { return false; } return !VcsUtil.isEmpty(e.getData(ChangesListView.UNVERSIONED_FILES_DATA_KEY)) || !ArrayUtil.isEmpty(e.getData(VcsDataKeys.CHANGES)) || !ArrayUtil.isEmpty(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)); }
Example #13
Source File: VcsToolbarLabelAction.java From consulo with Apache License 2.0 | 5 votes |
private static String getConsolidatedVcsName(Project project) { String name = DEFAULT_LABEL; if (project != null) { AbstractVcs[] vcss = ProjectLevelVcsManager.getInstance(project).getAllActiveVcss(); List<String> ids = Arrays.stream(vcss).map(vcs -> vcs.getShortName()).distinct().collect(Collectors.toList()); if (ids.size() == 1) { name = ids.get(0) + ":"; } } return name; }
Example #14
Source File: TfvcIntegrationEnabler.java From azure-devops-intellij with MIT License | 5 votes |
private void addVcsRoot(@NotNull VirtualFile root) { ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); List<VirtualFile> currentVcsRoots = Arrays.asList(vcsManager.getRootsUnderVcs(myVcs)); List<VcsDirectoryMapping> mappings = new ArrayList<>(vcsManager.getDirectoryMappings(myVcs)); if (!currentVcsRoots.contains(root)) { mappings.add(new VcsDirectoryMapping(root.getPath(), myVcs.getName())); } vcsManager.setDirectoryMappings(mappings); }
Example #15
Source File: CompareWithSelectedRevisionAction.java From consulo with Apache License 2.0 | 5 votes |
protected void actionPerformed(VcsContext vcsContext) { final VirtualFile file = vcsContext.getSelectedFiles()[0]; final Project project = vcsContext.getProject(); final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).getVcsFor(file); final VcsHistoryProvider vcsHistoryProvider = vcs.getVcsHistoryProvider(); new VcsHistoryProviderBackgroundableProxy(vcs, vcsHistoryProvider, vcs.getDiffProvider()). createSessionFor(vcs.getKeyInstanceMethod(), new FilePathImpl(file), new Consumer<VcsHistorySession>() { public void consume(VcsHistorySession session) { if (session == null) return; final List<VcsFileRevision> revisions = session.getRevisionList(); final HistoryAsTreeProvider treeHistoryProvider = session.getHistoryAsTreeProvider(); if (treeHistoryProvider != null) { showTreePopup(treeHistoryProvider.createTreeOn(revisions), file, project, vcs.getDiffProvider()); } else { showListPopup(revisions, project, new Consumer<VcsFileRevision>() { public void consume(final VcsFileRevision revision) { DiffActionExecutor.showDiff(vcs.getDiffProvider(), revision.getRevisionNumber(), file, project, VcsBackgroundableActions.COMPARE_WITH); } }, true); } } }, VcsBackgroundableActions.COMPARE_WITH, false, null); }
Example #16
Source File: VcsRootScanner.java From consulo with Apache License 2.0 | 5 votes |
private VcsRootScanner(@Nonnull Project project, @Nonnull List<VcsRootChecker> checkers) { myRootProblemNotifier = VcsRootProblemNotifier.getInstance(project); myCheckers = checkers; final MessageBus messageBus = project.getMessageBus(); messageBus.connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this); messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, this); messageBus.connect().subscribe(ProjectTopics.PROJECT_ROOTS, this); myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project); }
Example #17
Source File: VcsRootDetectorImpl.java From consulo with Apache License 2.0 | 5 votes |
@Inject public VcsRootDetectorImpl(@Nonnull Project project, @Nonnull ProjectRootManager projectRootManager, @Nonnull ProjectLevelVcsManager projectLevelVcsManager) { myProject = project; myProjectManager = projectRootManager; myVcsManager = projectLevelVcsManager; myCheckers = VcsRootChecker.EXTENSION_POINT_NAME.getExtensionList(); }
Example #18
Source File: VcsToolbarLabelAction.java From consulo with Apache License 2.0 | 5 votes |
@RequiredUIAccess @Override public void update(@Nonnull AnActionEvent e) { e.getPresentation().setEnabled(false); Project project = e.getProject(); e.getPresentation().setVisible(project != null && ProjectLevelVcsManager.getInstance(project).hasActiveVcss()); }
Example #19
Source File: ChangeListsScopesProvider.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<NamedScope> getCustomScopes() { if (myProject.isDefault() || ProjectLevelVcsManager.getInstance(myProject).getAllActiveVcss().length == 0) return Collections.emptyList(); final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final List<NamedScope> result = new ArrayList<NamedScope>(); result.add(createScope(changeListManager.getAffectedFiles(), IdeBundle.message("scope.modified.files"))); for (ChangeList list : changeListManager.getChangeListsCopy()) { result.add(createChangeListScope(list)); } return result; }
Example #20
Source File: TFVCUtil.java From azure-devops-intellij with MIT License | 5 votes |
/** * Will check invalid paths for TFVC (i.e. paths containing dollar in any component, or $tf / .tf service * directory). * <p> * Performs a quick check (without checking every VCS mapping) because we often need this in performance-sensitive * contexts. */ public static boolean isInvalidTFVCPath(@NotNull TFSVcs vcs, @NotNull FilePath path) { if (isInServiceDirectory(path)) return true; ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(vcs.getProject()); return vcsManager.getDirectoryMappings(vcs).stream() .map(mapping -> new LocalFilePath(mapping.getDirectory(), true)) .anyMatch(mapping -> hasIllegalDollarInAnyComponent(mapping, path)); }
Example #21
Source File: StandardVcsGroup.java From consulo with Apache License 2.0 | 5 votes |
public void update(AnActionEvent e) { Presentation presentation = e.getPresentation(); Project project = e.getData(CommonDataKeys.PROJECT); if (project != null) { final String vcsName = getVcsName(project); presentation.setVisible(vcsName != null && ProjectLevelVcsManager.getInstance(project).checkVcsIsActive(vcsName)); } else { presentation.setVisible(false); } presentation.setEnabled(presentation.isVisible()); }
Example #22
Source File: VcsContentAnnotationImpl.java From consulo with Apache License 2.0 | 5 votes |
@javax.annotation.Nullable @Override public VcsRevisionNumber fileRecentlyChanged(VirtualFile vf) { final ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(myProject); final AbstractVcs vcs = vcsManager.getVcsFor(vf); if (vcs == null) return null; if (vcs.getDiffProvider() instanceof DiffMixin) { final VcsRevisionDescription description = ((DiffMixin)vcs.getDiffProvider()).getCurrentRevisionDescription(vf); final Date date = description.getRevisionDate(); return isRecent(date) ? description.getRevisionNumber() : null; } return null; }
Example #23
Source File: VcsCherryPickAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static List<VcsCherryPicker> getActiveCherryPickersForProject(@Nullable final Project project) { if (project != null) { final ProjectLevelVcsManager projectLevelVcsManager = ProjectLevelVcsManager.getInstance(project); AbstractVcs[] vcss = projectLevelVcsManager.getAllActiveVcss(); return ContainerUtil.mapNotNull(vcss, vcs -> vcs != null ? VcsCherryPickManager.getInstance(project) .getCherryPickerFor(vcs.getKeyInstanceMethod()) : null); } return ContainerUtil.emptyList(); }
Example #24
Source File: VcsRepositoryManager.java From consulo with Apache License 2.0 | 5 votes |
@Inject public VcsRepositoryManager(@Nonnull Project project, @Nonnull ProjectLevelVcsManager vcsManager) { myProject = project; myVcsManager = vcsManager; myRepositoryCreators = Arrays.asList(Extensions.getExtensions(VcsRepositoryCreator.EXTENSION_POINT_NAME, project)); myProject.getMessageBus().connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this); }
Example #25
Source File: DvcsUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable public static VirtualFile guessVcsRoot(@Nonnull Project project, @javax.annotation.Nullable VirtualFile file) { VirtualFile root = null; if (file != null) { root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(file); if (root == null) { LOGGER.debug("Cannot get root by file. Trying with get by library: " + file); root = getVcsRootForLibraryFile(project, file); } } return root; }
Example #26
Source File: VcsDirtyScopeManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Inject public VcsDirtyScopeManagerImpl(Project project, ChangeListManager changeListManager, ProjectLevelVcsManager vcsManager) { myProject = project; myChangeListManager = changeListManager; myVcsManager = (ProjectLevelVcsManagerImpl)vcsManager; myGuess = new VcsGuess(myProject); myDirtBuilder = new DirtBuilder(myGuess); ((ChangeListManagerImpl) myChangeListManager).setDirtyScopeManager(this); }
Example #27
Source File: VcsProjectLog.java From consulo with Apache License 2.0 | 5 votes |
@Override public void runActivity(@Nonnull Project project) { if (ApplicationManager.getApplication().isUnitTestMode() || ApplicationManager.getApplication().isHeadlessEnvironment()) return; VcsProjectLog projectLog = getInstance(project); MessageBusConnection connection = project.getMessageBus().connect(project); connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, projectLog::recreateLog); if (projectLog.hasDvcsRoots()) { ApplicationManager.getApplication().invokeLater(projectLog::createLog); } }
Example #28
Source File: RegisterMappingCheckoutListener.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean processCheckedOutDirectory(Project currentProject, File directory, VcsKey vcsKey) { Project project = CompositeCheckoutListener.findProjectByBaseDirLocation(directory); if (project != null) { ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); if (!vcsManager.hasAnyMappings()) { vcsManager.setDirectoryMappings(Collections.singletonList(VcsDirectoryMapping.createDefault(vcsKey.getName()))); } return true; } return false; }
Example #29
Source File: DvcsUtil.java From consulo with Apache License 2.0 | 5 votes |
@javax.annotation.Nullable private static VirtualFile getVcsRootForLibraryFile(@Nonnull Project project, @Nonnull VirtualFile file) { ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); // for a file inside .jar/.zip consider the .jar/.zip file itself VirtualFile root = vcsManager.getVcsRootFor(VfsUtilCore.getVirtualFileForJar(file)); if (root != null) { LOGGER.debug("Found root for zip/jar file: " + root); return root; } // for other libs which don't have jars inside the project dir (such as JDK) take the owner module of the lib List<OrderEntry> entries = ProjectRootManager.getInstance(project).getFileIndex().getOrderEntriesForFile(file); Set<VirtualFile> libraryRoots = new HashSet<>(); for (OrderEntry entry : entries) { if (entry instanceof LibraryOrderEntry || entry instanceof ModuleExtensionWithSdkOrderEntry) { VirtualFile moduleRoot = vcsManager.getVcsRootFor(entry.getOwnerModule().getModuleDir()); if (moduleRoot != null) { libraryRoots.add(moduleRoot); } } } if (libraryRoots.size() == 0) { LOGGER.debug("No library roots"); return null; } // if the lib is used in several modules, take the top module // (for modules of the same level we can't guess anything => take the first one) Iterator<VirtualFile> libIterator = libraryRoots.iterator(); VirtualFile topLibraryRoot = libIterator.next(); while (libIterator.hasNext()) { VirtualFile libRoot = libIterator.next(); if (VfsUtilCore.isAncestor(libRoot, topLibraryRoot, true)) { topLibraryRoot = libRoot; } } LOGGER.debug("Several library roots, returning " + topLibraryRoot); return topLibraryRoot; }
Example #30
Source File: VirtualFileUnderSvnActionBase.java From SVNToolBox with Apache License 2.0 | 5 votes |
@Override public void update(AnActionEvent e) { super.update(e); final Presentation presentation = e.getPresentation(); final DataContext dataContext = e.getDataContext(); Project project = PlatformDataKeys.PROJECT.getData(dataContext); if (project == null) { presentation.setEnabled(false); presentation.setVisible(false); return; } VirtualFile vFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext); if (vFile == null) { presentation.setEnabled(false); presentation.setVisible(false); return; } SvnVcs vcs = SvnVcs.getInstance(project); if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, new VirtualFile[]{vFile})) { presentation.setEnabled(false); presentation.setVisible(true); return; } presentation.setEnabled(true); presentation.setVisible(true); }