Java Code Examples for com.intellij.openapi.vcs.changes.ChangeListManager#getInstance()
The following examples show how to use
com.intellij.openapi.vcs.changes.ChangeListManager#getInstance() .
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: VcsVFSListener.java From consulo with Apache License 2.0 | 6 votes |
protected VcsVFSListener(@Nonnull Project project, @Nonnull AbstractVcs vcs) { myProject = project; myVcs = vcs; myChangeListManager = ChangeListManager.getInstance(project); myDirtyScopeManager = VcsDirtyScopeManager.getInstance(myProject); final MyVirtualFileListener myVFSListener = new MyVirtualFileListener(); final MyCommandAdapter myCommandListener = new MyCommandAdapter(); myVcsManager = ProjectLevelVcsManager.getInstance(project); myAddOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.ADD, vcs); myRemoveOption = myVcsManager.getStandardConfirmation(VcsConfiguration.StandardConfirmation.REMOVE, vcs); VirtualFileManager.getInstance().addVirtualFileListener(myVFSListener, this); CommandProcessor.getInstance().addCommandListener(myCommandListener, this); myVcsFileListenerContextHelper = VcsFileListenerContextHelper.getInstance(myProject); }
Example 2
Source File: CommonCheckinFilesAction.java From consulo with Apache License 2.0 | 6 votes |
@Nullable @Override protected LocalChangeList getInitiallySelectedChangeList(@Nonnull VcsContext context, @Nonnull Project project) { ChangeListManager manager = ChangeListManager.getInstance(project); LocalChangeList defaultChangeList = manager.getDefaultChangeList(); LocalChangeList result = null; for (FilePath root : getRoots(context)) { if (root.getVirtualFile() == null) continue; Collection<Change> changes = manager.getChangesIn(root); if (defaultChangeList != null && containsAnyChange(defaultChangeList, changes)) { return defaultChangeList; } result = changes.stream().findFirst().map(manager::getChangeList).orElse(null); } return ObjectUtils.chooseNotNull(result, defaultChangeList); }
Example 3
Source File: AbstractCommitChangesAction.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void update(final VcsContext vcsContext, final Presentation presentation) { super.update(vcsContext, presentation); if (presentation.isVisible() && presentation.isEnabled()) { final ChangeList[] selectedChangeLists = vcsContext.getSelectedChangeLists(); final Change[] selectedChanges = vcsContext.getSelectedChanges(); if (vcsContext.getPlace().equals(ActionPlaces.CHANGES_VIEW_POPUP)) { if (selectedChangeLists != null && selectedChangeLists.length > 0) { presentation.setEnabled(selectedChangeLists.length == 1); } else { presentation.setEnabled (selectedChanges != null && selectedChanges.length > 0); } } if (presentation.isEnabled() && selectedChanges != null) { final ChangeListManager changeListManager = ChangeListManager.getInstance(vcsContext.getProject()); for(Change c: selectedChanges) { if (c.getFileStatus() == FileStatus.HIJACKED && changeListManager.getChangeList(c) == null) { presentation.setEnabled(false); break; } } } } }
Example 4
Source File: CustomChangelistTodosTreeBuilder.java From consulo with Apache License 2.0 | 5 votes |
public CustomChangelistTodosTreeBuilder(JTree tree, Project project, final String title, final Collection<? extends TodoItem> todoItems) { super(tree, project); myProject = project; myTitle = title; myMap = new MultiMap<>(); myIncludedFiles = new HashSet<>(); myChangeListManager = ChangeListManager.getInstance(myProject); initMap(todoItems); initHelper(); }
Example 5
Source File: ChangelistConflictDialog.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override protected Action[] createLeftSideActions() { return new Action[] { new AbstractAction("&Configure...") { public void actionPerformed(ActionEvent e) { ChangeListManagerImpl manager = (ChangeListManagerImpl)ChangeListManager.getInstance(myProject); ShowSettingsUtil.getInstance().editConfigurable(myPanel, new ChangelistConflictConfigurable(manager)); } }}; }
Example 6
Source File: IgnoredEditingNotificationProvider.java From idea-gitignore with MIT License | 5 votes |
/** * Builds a new instance of {@link IgnoredEditingNotificationProvider}. * * @param project current project */ public IgnoredEditingNotificationProvider(@NotNull Project project) { this.notifications = EditorNotifications.getInstance(project); this.settings = IgnoreSettings.getInstance(); this.manager = IgnoreManager.getInstance(project); this.changeListManager = ChangeListManager.getInstance(project); }
Example 7
Source File: CloseIgnoredEditorsAction.java From idea-gitignore with MIT License | 5 votes |
/** * Obtains if editor is allowed to be closed. * * @return editor is allowed to be closed */ @Override protected boolean isFileToClose(final EditorComposite editor, final EditorWindow window) { final Project project = window.getManager().getProject(); final FileStatusManager fileStatusManager = FileStatusManager.getInstance(project); final ChangeListManager changeListManager = ChangeListManager.getInstance(project); final VirtualFile fileInEditor = editor.getFile(); return fileStatusManager != null && fileStatusManager.getStatus(fileInEditor).equals(IgnoreFileStatusProvider.IGNORED) || changeListManager.isIgnoredFile(fileInEditor); }
Example 8
Source File: ChangeListTodosPanel.java From consulo with Apache License 2.0 | 5 votes |
public ChangeListTodosPanel(Project project,TodoPanelSettings settings, Content content){ super(project,settings,false,content); ChangeListManager changeListManager = ChangeListManager.getInstance(project); final MyChangeListManagerListener myChangeListManagerListener = new MyChangeListManagerListener(); changeListManager.addChangeListListener(myChangeListManagerListener); Disposer.register(this, new Disposable() { @Override public void dispose() { ChangeListManager.getInstance(myProject).removeChangeListListener(myChangeListManagerListener); } }); myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, this); }
Example 9
Source File: GitLabOpenInBrowserAction.java From IDEA-GitLab-Integration with MIT License | 5 votes |
@Override public void update(final AnActionEvent e) { Project project = e.getData(PlatformDataKeys.PROJECT); VirtualFile virtualFile = e.getData(PlatformDataKeys.VIRTUAL_FILE); if (project == null || project.isDefault() || virtualFile == null) { setVisibleEnabled(e, false, false); return; } final GitRepository gitRepository = GitUtil.getRepositoryManager(project).getRepositoryForFile(virtualFile); if (gitRepository == null) { setVisibleEnabled(e, false, false); return; } ChangeListManager changeListManager = ChangeListManager.getInstance(project); if (changeListManager.isUnversioned(virtualFile)) { setVisibleEnabled(e, true, false); return; } Change change = changeListManager.getChange(virtualFile); if (change != null && change.getType() == Change.Type.NEW) { setVisibleEnabled(e, true, false); return; } setVisibleEnabled(e, true, true); }
Example 10
Source File: VcsRootProblemNotifier.java From consulo with Apache License 2.0 | 5 votes |
private VcsRootProblemNotifier(@Nonnull Project project) { myProject = project; mySettings = VcsConfiguration.getInstance(myProject); myChangeListManager = ChangeListManager.getInstance(project); myProjectFileIndex = ProjectFileIndex.SERVICE.getInstance(myProject); myVcsManager = ProjectLevelVcsManager.getInstance(project); myReportedUnregisteredRoots = new HashSet<>(mySettings.IGNORED_UNREGISTERED_ROOTS); }
Example 11
Source File: VcsHandleType.java From consulo with Apache License 2.0 | 5 votes |
public VcsHandleType(AbstractVcs vcs) { super(VcsBundle.message("handle.ro.file.status.type.using.vcs", vcs.getDisplayName()), true); myVcs = vcs; myChangeListManager = ChangeListManager.getInstance(myVcs.getProject()); myChangeFunction = new NullableFunction<VirtualFile, Change>() { @Override public Change fun(VirtualFile file) { return myChangeListManager.getChange(file); } }; }
Example 12
Source File: EditChangelistDialog.java From consulo with Apache License 2.0 | 5 votes |
protected void doOKAction() { String oldName = myList.getName(); String oldComment = myList.getComment(); if (!Comparing.equal(oldName, myPanel.getChangeListName()) && ChangeListManager.getInstance(myProject).findChangeList(myPanel.getChangeListName()) != null) { Messages.showErrorDialog(myPanel.getContent(), VcsBundle.message("changes.dialog.editchangelist.error.already.exists", myPanel.getChangeListName()), VcsBundle.message("changes.dialog.editchangelist.title")); return; } if (!Comparing.equal(oldName, myPanel.getChangeListName(), true) || !Comparing.equal(oldComment, myPanel.getDescription(), true)) { final ChangeListManager clManager = ChangeListManager.getInstance(myProject); final String newName = myPanel.getChangeListName(); if (! myList.getName().equals(newName)) { clManager.editName(myList.getName(), newName); } final String newDescription = myPanel.getDescription(); if (! myList.getComment().equals(newDescription)) { clManager.editComment(myList.getName(), newDescription); } } if (!myList.isDefault() && myPanel.getMakeActiveCheckBox().isSelected()) { ChangeListManager.getInstance(myProject).setDefaultChangeList(myList); } myPanel.changelistCreatedOrChanged(myList); super.doOKAction(); }
Example 13
Source File: BaseAnalysisActionDialog.java From consulo with Apache License 2.0 | 4 votes |
@Override protected JComponent createCenterPanel() { myTitledSeparator.setText(myAnalysisNoon); //include test option myInspectTestSource.setSelected(myAnalysisOptions.ANALYZE_TEST_SOURCES); //module scope if applicable myModuleButton.setText(AnalysisScopeBundle.message("scope.option.module.with.mnemonic", myModuleName)); boolean useModuleScope = false; if (myModuleName != null) { useModuleScope = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.MODULE; myModuleButton.setSelected(myRememberScope && useModuleScope); } myModuleButton.setVisible(myModuleName != null && ModuleManager.getInstance(myProject).getModules().length > 1); boolean useUncommitedFiles = false; final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); final boolean hasVCS = !changeListManager.getAffectedFiles().isEmpty(); if (hasVCS){ useUncommitedFiles = myAnalysisOptions.SCOPE_TYPE == AnalysisScope.UNCOMMITTED_FILES; myUncommitedFilesButton.setSelected(myRememberScope && useUncommitedFiles); } myUncommitedFilesButton.setVisible(hasVCS); DefaultComboBoxModel model = new DefaultComboBoxModel(); model.addElement(ALL); final List<? extends ChangeList> changeLists = changeListManager.getChangeListsCopy(); for (ChangeList changeList : changeLists) { model.addElement(changeList.getName()); } myChangeLists.setModel(model); myChangeLists.setEnabled(myUncommitedFilesButton.isSelected()); myChangeLists.setVisible(hasVCS); //file/package/directory/module scope if (myFileName != null) { myFileButton.setText(myFileName); myFileButton.setMnemonic(myFileName.charAt(getSelectedScopeMnemonic())); } else { myFileButton.setVisible(false); } VirtualFile file = PsiUtilBase.getVirtualFile(myContext); ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex(); boolean searchInLib = file != null && (fileIndex.isInLibraryClasses(file) || fileIndex.isInLibrarySource(file)); String preselect = StringUtil.isEmptyOrSpaces(myAnalysisOptions.CUSTOM_SCOPE_NAME) ? FindSettings.getInstance().getDefaultScopeName() : myAnalysisOptions.CUSTOM_SCOPE_NAME; if (searchInLib && GlobalSearchScope.projectScope(myProject).getDisplayName().equals(preselect)) { preselect = GlobalSearchScope.allScope(myProject).getDisplayName(); } if (GlobalSearchScope.allScope(myProject).getDisplayName().equals(preselect) && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM) { myAnalysisOptions.CUSTOM_SCOPE_NAME = preselect; searchInLib = true; } //custom scope myCustomScopeButton.setSelected(myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.CUSTOM); myScopeCombo.init(myProject, searchInLib, true, preselect); //correct selection myProjectButton.setSelected(myRememberScope && myAnalysisOptions.SCOPE_TYPE == AnalysisScope.PROJECT || myFileName == null); myFileButton.setSelected(myFileName != null && (!myRememberScope || myAnalysisOptions.SCOPE_TYPE != AnalysisScope.PROJECT && !useModuleScope && myAnalysisOptions.SCOPE_TYPE != AnalysisScope.CUSTOM && !useUncommitedFiles)); myScopeCombo.setEnabled(myCustomScopeButton.isSelected()); final ActionListener radioButtonPressed = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onScopeRadioButtonPressed(); } }; final Enumeration<AbstractButton> enumeration = myGroup.getElements(); while (enumeration.hasMoreElements()) { enumeration.nextElement().addActionListener(radioButtonPressed); } //additional panel - inspection profile chooser JPanel wholePanel = new JPanel(new BorderLayout()); wholePanel.add(myPanel, BorderLayout.NORTH); final JComponent additionalPanel = getAdditionalActionSettings(myProject); if (additionalPanel!= null){ wholePanel.add(additionalPanel, BorderLayout.CENTER); } new RadioUpDownListener(myProjectButton, myModuleButton, myUncommitedFilesButton, myFileButton, myCustomScopeButton); return wholePanel; }
Example 14
Source File: TFSChangeProvider.java From azure-devops-intellij with MIT License | 4 votes |
public void getChanges(@NotNull final VcsDirtyScope dirtyScope, @NotNull final ChangelistBuilder builder, @NotNull final ProgressIndicator progress, @NotNull final ChangeListManagerGate addGate) { Project project = myVcs.getProject(); if (project.isDisposed()) { return; } progress.setText("Processing changes"); // process only roots, filter out child items since requests are recursive anyway RootsCollection.FilePathRootsCollection roots = new RootsCollection.FilePathRootsCollection(); roots.addAll(dirtyScope.getRecursivelyDirtyDirectories()); final ChangeListManager changeListManager = ChangeListManager.getInstance(project); for (FilePath dirtyFile : dirtyScope.getDirtyFiles()) { // workaround for IDEADEV-31511 and IDEADEV-31721 if (dirtyFile.getVirtualFile() == null || !changeListManager.isIgnoredFile(dirtyFile.getVirtualFile())) { roots.add(dirtyFile); } } if (roots.isEmpty()) { return; } final List<String> pathsToProcess = TFVCUtil.filterValidTFVCPaths(project, roots); if (pathsToProcess.isEmpty()) { return; } List<PendingChange> changes; try { ServerContext serverContext = myVcs.getServerContext(true); changes = TfvcClient.getInstance(project).getStatusForFiles(serverContext, pathsToProcess); } catch (final Throwable t) { logger.error("Failed to get changes from command line. roots=" + StringUtils.join(pathsToProcess, ", "), t); changes = Collections.emptyList(); } // for each change, find out the status of the changes and then add to the list final ChangelistBuilderStatusVisitor changelistBuilderStatusVisitor = new ChangelistBuilderStatusVisitor(project, builder); for (final PendingChange change : changes) { StatusProvider.visitByStatus(changelistBuilderStatusVisitor, change); } }
Example 15
Source File: ChangeListChooserPanel.java From consulo with Apache License 2.0 | 4 votes |
private LocalChangeList getExistingChangelistByName(@Nonnull String changeListName) { ChangeListManager manager = ChangeListManager.getInstance(myProject); return manager.findChangeList(changeListName); }
Example 16
Source File: VcsCherryPickManager.java From consulo with Apache License 2.0 | 4 votes |
public CherryPickingTask(@Nonnull Project project, @Nonnull List<VcsFullCommitDetails> detailsInReverseOrder) { super(project, "Cherry-Picking"); myAllDetailsInReverseOrder = detailsInReverseOrder; myChangeListManager = (ChangeListManagerEx)ChangeListManager.getInstance(myProject); myChangeListManager.blockModalNotifications(); }
Example 17
Source File: HideIgnoredFilesTreeStructureProvider.java From idea-gitignore with MIT License | 4 votes |
/** Builds a new instance of {@link HideIgnoredFilesTreeStructureProvider}. */ public HideIgnoredFilesTreeStructureProvider(@NotNull Project project) { this.ignoreSettings = IgnoreSettings.getInstance(); this.ignoreManager = IgnoreManager.getInstance(project); this.changeListManager = ChangeListManager.getInstance(project); }
Example 18
Source File: PluginSetup.java From p4ic4idea with Apache License 2.0 | 4 votes |
public ChangeListManager getMockChangelistManager() { return ChangeListManager.getInstance(idea.getMockProject()); }
Example 19
Source File: L2Test.java From azure-devops-intellij with MIT License | 4 votes |
protected void updateChangeListManager() { ChangeListManager changeListManager = ChangeListManager.getInstance(myProject); VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty(); changeListManager.ensureUpToDate(false); }
Example 20
Source File: BaseAnalysisActionDialog.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull public AnalysisScope getScope(@Nonnull AnalysisUIOptions uiOptions, @Nonnull AnalysisScope defaultScope, @Nonnull Project project, Module module) { AnalysisScope scope; if (isProjectScopeSelected()) { scope = new AnalysisScope(project); uiOptions.SCOPE_TYPE = AnalysisScope.PROJECT; } else { final SearchScope customScope = getCustomScope(); if (customScope != null) { scope = new AnalysisScope(customScope, project); uiOptions.SCOPE_TYPE = AnalysisScope.CUSTOM; uiOptions.CUSTOM_SCOPE_NAME = customScope.getDisplayName(); } else if (isModuleScopeSelected()) { scope = new AnalysisScope(module); uiOptions.SCOPE_TYPE = AnalysisScope.MODULE; } else if (isUncommitedFilesSelected()) { final ChangeListManager changeListManager = ChangeListManager.getInstance(project); List<VirtualFile> files; if (myChangeLists.getSelectedItem() == ALL) { files = changeListManager.getAffectedFiles(); } else { files = new ArrayList<VirtualFile>(); for (ChangeList list : changeListManager.getChangeListsCopy()) { if (!Comparing.strEqual(list.getName(), (String)myChangeLists.getSelectedItem())) continue; final Collection<Change> changes = list.getChanges(); for (Change change : changes) { final ContentRevision afterRevision = change.getAfterRevision(); if (afterRevision != null) { final VirtualFile vFile = afterRevision.getFile().getVirtualFile(); if (vFile != null) { files.add(vFile); } } } } } scope = new AnalysisScope(project, new HashSet<VirtualFile>(files)); uiOptions.SCOPE_TYPE = AnalysisScope.UNCOMMITTED_FILES; } else { scope = defaultScope; uiOptions.SCOPE_TYPE = defaultScope.getScopeType();//just not project scope } } uiOptions.ANALYZE_TEST_SOURCES = isInspectTestSources(); scope.setIncludeTestSource(isInspectTestSources()); scope.setScope(getCustomScope()); FindSettings.getInstance().setDefaultScopeName(scope.getDisplayName()); return scope; }