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;
}
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);
}
});
}
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);
}
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;
}
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]);
}
Aggregations