Search in sources :

Example 1 with ChangeListChooser

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());
}
Also used : ChangeListChooser(com.intellij.openapi.vcs.changes.ui.ChangeListChooser) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 2 with ChangeListChooser

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();
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Task(com.intellij.openapi.progress.Task) ChangeListChooser(com.intellij.openapi.vcs.changes.ui.ChangeListChooser) ArrayList(java.util.ArrayList) Change(com.intellij.openapi.vcs.changes.Change) BinaryFilePatch(com.intellij.openapi.diff.impl.patch.BinaryFilePatch) FilePatch(com.intellij.openapi.diff.impl.patch.FilePatch) Project(com.intellij.openapi.project.Project) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) PatchApplier(com.intellij.openapi.diff.impl.patch.formove.PatchApplier) ArrayList(java.util.ArrayList) List(java.util.List) ChangeList(com.intellij.openapi.vcs.changes.ChangeList)

Example 3 with ChangeListChooser

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();
}
Also used : ChangeListChooser(com.intellij.openapi.vcs.changes.ui.ChangeListChooser) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ChangeListChooser

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);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GitRepository(git4idea.repo.GitRepository) ChangeListChooser(com.intellij.openapi.vcs.changes.ui.ChangeListChooser)

Aggregations

ChangeListChooser (com.intellij.openapi.vcs.changes.ui.ChangeListChooser)4 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 BinaryFilePatch (com.intellij.openapi.diff.impl.patch.BinaryFilePatch)1 FilePatch (com.intellij.openapi.diff.impl.patch.FilePatch)1 PatchApplier (com.intellij.openapi.diff.impl.patch.formove.PatchApplier)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 VcsException (com.intellij.openapi.vcs.VcsException)1 Change (com.intellij.openapi.vcs.changes.Change)1 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)1 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)1 GitRepository (git4idea.repo.GitRepository)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Nullable (org.jetbrains.annotations.Nullable)1