Search in sources :

Example 1 with ChangeList

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

the class ConfigureBranchesAction method update.

public void update(final AnActionEvent e) {
    final Project project = e.getProject();
    final Presentation presentation = e.getPresentation();
    if (project == null) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
        return;
    }
    presentation.setText(SvnBundle.message("configure.branches.item"));
    presentation.setDescription(SvnBundle.message("configure.branches.item"));
    presentation.setIcon(SvnIcons.ConfigureBranches);
    presentation.setVisible(true);
    final ChangeList[] cls = e.getData(VcsDataKeys.CHANGE_LISTS);
    presentation.setEnabled((cls != null) && (cls.length > 0) && (SvnVcs.getInstance(project).getName().equals(((CommittedChangeList) cls[0]).getVcs().getName())) && (((SvnChangeList) cls[0]).getRoot() != null));
}
Also used : Project(com.intellij.openapi.project.Project) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) Presentation(com.intellij.openapi.actionSystem.Presentation)

Example 2 with ChangeList

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

the class ConfigureBranchesAction method actionPerformed.

public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getProject();
    final ChangeList[] cls = e.getData(VcsDataKeys.CHANGE_LISTS);
    if ((cls == null) || (cls.length == 0) || (!SvnVcs.getInstance(project).getName().equals(((CommittedChangeList) cls[0]).getVcs().getName())) || (((SvnChangeList) cls[0]).getRoot() == null)) {
        return;
    }
    final SvnChangeList svnList = (SvnChangeList) cls[0];
    BranchConfigurationDialog.configureBranches(project, svnList.getRoot());
}
Also used : Project(com.intellij.openapi.project.Project) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) SvnChangeList(org.jetbrains.idea.svn.history.SvnChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)

Example 3 with ChangeList

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

the class HgCachingCommittedChangesProvider method createActions.

public VcsCommittedViewAuxiliary createActions(DecoratorManager decoratorManager, RepositoryLocation repositoryLocation) {
    AnAction copyHashAction = new AnAction("Copy &Hash", "Copy hash to clipboard", PlatformIcons.COPY_ICON) {

        @Override
        public void actionPerformed(AnActionEvent e) {
            ChangeList[] changeLists = e.getData(VcsDataKeys.CHANGE_LISTS);
            if (changeLists != null && changeLists[0] instanceof HgCommittedChangeList) {
                HgRevisionNumber revisionNumber = ((HgCommittedChangeList) changeLists[0]).getRevisionNumber();
                CopyPasteManager.getInstance().setContents(new StringSelection(revisionNumber.getChangeset()));
            }
        }
    };
    return new VcsCommittedViewAuxiliary(Collections.singletonList(copyHashAction), new Runnable() {

        public void run() {
        }
    }, Collections.singletonList(copyHashAction));
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) VcsCommittedViewAuxiliary(com.intellij.openapi.vcs.changes.committed.VcsCommittedViewAuxiliary) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) AnAction(com.intellij.openapi.actionSystem.AnAction) StringSelection(java.awt.datatransfer.StringSelection)

Example 4 with ChangeList

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

the class RemoveChangeListAction method actionPerformed.

public void actionPerformed(@NotNull AnActionEvent e) {
    final Project project = e.getRequiredData(CommonDataKeys.PROJECT);
    final ChangeList[] selectedLists = e.getRequiredData(VcsDataKeys.CHANGE_LISTS);
    //noinspection unchecked
    ChangeListRemoveConfirmation.processLists(project, true, (Collection) Arrays.asList(selectedLists), new ChangeListRemoveConfirmation() {

        @Override
        public boolean askIfShouldRemoveChangeLists(@NotNull List<? extends LocalChangeList> lists) {
            return RemoveChangeListAction.askIfShouldRemoveChangeLists(lists, project);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList)

Example 5 with ChangeList

use of com.intellij.openapi.vcs.changes.ChangeList 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)

Aggregations

ChangeList (com.intellij.openapi.vcs.changes.ChangeList)19 Project (com.intellij.openapi.project.Project)11 CommittedChangeList (com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)7 Change (com.intellij.openapi.vcs.changes.Change)6 LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 SvnChangeList (org.jetbrains.idea.svn.history.SvnChangeList)3 DataContext (com.intellij.openapi.actionSystem.DataContext)2 FilePath (com.intellij.openapi.vcs.FilePath)2 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)2 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)2 TaskManager (com.intellij.tasks.TaskManager)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)2 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 CamelHumpMatcher (com.intellij.codeInsight.completion.impl.CamelHumpMatcher)1 LookupElementBuilder (com.intellij.codeInsight.lookup.LookupElementBuilder)1 AnAction (com.intellij.openapi.actionSystem.AnAction)1 AnActionEvent (com.intellij.openapi.actionSystem.AnActionEvent)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1