Search in sources :

Example 16 with LocalChangeList

use of com.intellij.openapi.vcs.changes.LocalChangeList in project intellij-community by JetBrains.

the class GitMergeUpdater method getLocalChangesFilteredByFiles.

private Collection<Change> getLocalChangesFilteredByFiles(List<FilePath> paths) {
    final Collection<Change> changes = new HashSet<>();
    for (LocalChangeList list : myChangeListManager.getChangeLists()) {
        for (Change change : list.getChanges()) {
            final ContentRevision afterRevision = change.getAfterRevision();
            final ContentRevision beforeRevision = change.getBeforeRevision();
            if ((afterRevision != null && paths.contains(afterRevision.getFile())) || (beforeRevision != null && paths.contains(beforeRevision.getFile()))) {
                changes.add(change);
            }
        }
    }
    return changes;
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ContentRevision(com.intellij.openapi.vcs.changes.ContentRevision) Change(com.intellij.openapi.vcs.changes.Change)

Example 17 with LocalChangeList

use of com.intellij.openapi.vcs.changes.LocalChangeList in project checkstyle-idea by jshiell.

the class ScanCurrentChangeList method update.

@Override
public void update(final AnActionEvent event) {
    super.update(event);
    project(event).ifPresent(project -> {
        try {
            final Presentation presentation = event.getPresentation();
            final LocalChangeList changeList = ChangeListManager.getInstance(project).getDefaultChangeList();
            if (changeList == null || changeList.getChanges() == null || changeList.getChanges().size() == 0) {
                presentation.setEnabled(false);
            } else {
                presentation.setEnabled(!staticScanner(project).isScanInProgress());
            }
        } catch (Throwable e) {
            LOG.warn("Button update failed.", e);
        }
    });
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 18 with LocalChangeList

use of com.intellij.openapi.vcs.changes.LocalChangeList in project intellij-community by JetBrains.

the class CommonCheckinFilesAction method getInitiallySelectedChangeList.

@Nullable
@Override
protected LocalChangeList getInitiallySelectedChangeList(@NotNull VcsContext context, @NotNull 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);
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Nullable(org.jetbrains.annotations.Nullable)

Example 19 with LocalChangeList

use of com.intellij.openapi.vcs.changes.LocalChangeList in project intellij-community by JetBrains.

the class ScheduleForAdditionAction method addUnversioned.

public static boolean addUnversioned(@NotNull Project project, @NotNull List<VirtualFile> files, @NotNull Condition<FileStatus> unversionedFileCondition, @Nullable ChangesBrowserBase browser) {
    boolean result = true;
    if (!files.isEmpty()) {
        FileDocumentManager.getInstance().saveAllDocuments();
        @SuppressWarnings("unchecked") Consumer<List<Change>> consumer = browser == null ? null : changes -> {
            browser.rebuildList();
            browser.getViewer().excludeChanges((List) files);
            browser.getViewer().includeChanges((List) changes);
        };
        ChangeListManagerImpl manager = ChangeListManagerImpl.getInstanceImpl(project);
        LocalChangeList targetChangeList = browser == null ? manager.getDefaultChangeList() : (LocalChangeList) browser.getSelectedChangeList();
        List<VcsException> exceptions = manager.addUnversionedFiles(targetChangeList, files, unversionedFileCondition, consumer);
        result = exceptions.isEmpty();
    }
    return result;
}
Also used : ChangeListManagerImpl(com.intellij.openapi.vcs.changes.ChangeListManagerImpl) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) List(java.util.List)

Example 20 with LocalChangeList

use of com.intellij.openapi.vcs.changes.LocalChangeList in project intellij-community by JetBrains.

the class SetDefaultChangeListAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    final ChangeList[] lists = e.getData(VcsDataKeys.CHANGE_LISTS);
    assert lists != null;
    ChangeListManager.getInstance(project).setDefaultChangeList((LocalChangeList) lists[0]);
}
Also used : Project(com.intellij.openapi.project.Project) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList)

Aggregations

LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)44 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 Test (org.junit.Test)20 Project (com.intellij.openapi.project.Project)8 Change (com.intellij.openapi.vcs.changes.Change)7 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)5 TaskManager (com.intellij.tasks.TaskManager)3 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)2 ChangeListInfo (com.intellij.tasks.ChangeListInfo)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 DataManager (com.intellij.ide.DataManager)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ComboBoxAction (com.intellij.openapi.actionSystem.ex.ComboBoxAction)1 DumbAware (com.intellij.openapi.project.DumbAware)1