use of com.intellij.openapi.vcs.changes.ui.ChangeListChooser in project intellij-community by JetBrains.
the class UnshelveWithDialogAction method unshelveMultipleShelveChangeLists.
private static void unshelveMultipleShelveChangeLists(@NotNull final Project project, @NotNull final List<ShelvedChangeList> changeLists, @NotNull List<ShelvedBinaryFile> binaryFiles, @NotNull List<ShelvedChange> changes) {
String suggestedName = changeLists.get(0).DESCRIPTION;
final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
final ChangeListChooser chooser = new ChangeListChooser(project, changeListManager.getChangeListsCopy(), changeListManager.getDefaultChangeList(), VcsBundle.message("unshelve.changelist.chooser.title"), suggestedName) {
@Nullable
@Override
protected JComponent createDoNotAskCheckbox() {
return createRemoveFilesStrategyCheckbox(project);
}
};
if (!chooser.showAndGet())
return;
ShelveChangesManager.getInstance(project).unshelveSilentlyAsynchronously(project, changeLists, changes, binaryFiles, chooser.getSelectedList());
}
use of com.intellij.openapi.vcs.changes.ui.ChangeListChooser in project intellij-community by JetBrains.
the class RevertCommittedStuffAbstractAction method actionPerformed.
public void actionPerformed(final AnActionEvent e) {
final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
final VirtualFile baseDir = project.getBaseDir();
assert baseDir != null;
final Change[] changes = myForPerformConvertor.convert(e);
if (changes == null || changes.length == 0)
return;
final List<Change> changesList = new ArrayList<>();
Collections.addAll(changesList, changes);
FileDocumentManager.getInstance().saveAllDocuments();
String defaultName = null;
final ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS);
if (changeLists != null && changeLists.length > 0) {
defaultName = VcsBundle.message("revert.changes.default.name", changeLists[0].getName());
}
final ChangeListChooser chooser = new ChangeListChooser(project, ChangeListManager.getInstance(project).getChangeListsCopy(), null, "Select Target Changelist", defaultName);
if (!chooser.showAndGet()) {
return;
}
final List<FilePatch> patches = new ArrayList<>();
ProgressManager.getInstance().run(new Task.Backgroundable(project, VcsBundle.message("revert.changes.title"), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
final List<Change> preprocessed = ChangesPreprocess.preprocessChangesRemoveDeletedForDuplicateMoved(changesList);
patches.addAll(IdeaTextPatchBuilder.buildPatch(project, preprocessed, baseDir.getPresentableUrl(), true));
} catch (final VcsException ex) {
WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
@Override
public void run() {
Messages.showErrorDialog(project, "Failed to revert changes: " + ex.getMessage(), VcsBundle.message("revert.changes.title"));
}
}, null, myProject);
indicator.cancel();
}
}
@Override
public void onSuccess() {
new PatchApplier<BinaryFilePatch>(project, baseDir, patches, chooser.getSelectedList(), null, null).execute();
}
});
}
use of com.intellij.openapi.vcs.changes.ui.ChangeListChooser in project intellij-community by JetBrains.
the class MoveChangesToAnotherListAction method askTargetList.
@Nullable
private static LocalChangeList askTargetList(@NotNull Project project, @NotNull Collection<Change> changes) {
ChangeListManagerImpl listManager = ChangeListManagerImpl.getInstanceImpl(project);
List<LocalChangeList> preferredLists = getPreferredLists(listManager.getChangeListsCopy(), changes);
List<LocalChangeList> listsForChooser = preferredLists.isEmpty() ? Collections.singletonList(listManager.getDefaultChangeList()) : preferredLists;
ChangeListChooser chooser = new ChangeListChooser(project, listsForChooser, guessPreferredList(preferredLists), ActionsBundle.message("action.ChangesView.Move.text"), null);
chooser.show();
return chooser.getSelectedList();
}
use of com.intellij.openapi.vcs.changes.ui.ChangeListChooser in project intellij-community by JetBrains.
the class GitUncommitAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getRequiredData(CommonDataKeys.PROJECT);
VcsLogData data = (VcsLogData) e.getRequiredData(VcsLogDataKeys.VCS_LOG_DATA_PROVIDER);
VcsLog log = e.getRequiredData(VcsLogDataKeys.VCS_LOG);
VcsShortCommitDetails commit = assertNotNull(getFirstItem(log.getSelectedShortDetails()));
VirtualFile root = commit.getRoot();
Hash hash = commit.getId();
GitRepository repository = assertNotNull(getRepositoryManager(project).getRepositoryForRoot(commit.getRoot()));
List<String> branches = findContainingBranches(data, root, hash);
if (!branches.contains(HEAD)) {
Messages.showErrorDialog(project, COMMIT_NOT_IN_HEAD, FAILURE_TITLE);
return;
}
// and not if pushed to a protected branch
String protectedBranch = findProtectedRemoteBranch(repository, branches);
if (protectedBranch != null) {
Messages.showErrorDialog(project, COMMIT_PUSHED_TO_PROTECTED + protectedBranch, FAILURE_TITLE);
return;
}
ChangeListChooser chooser = new ChangeListChooser(project, ChangeListManager.getInstance(project).getChangeListsCopy(), null, "Select Target Changelist", commit.getSubject());
chooser.show();
LocalChangeList selectedList = chooser.getSelectedList();
if (selectedList != null) {
resetInBackground(data, repository, commit, selectedList);
}
}
Aggregations