Search in sources :

Example 21 with LocalChangeList

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

the class RemoveChangeListAction method askIfShouldRemoveChangeLists.

private static boolean askIfShouldRemoveChangeLists(@NotNull List<? extends LocalChangeList> lists, Project project) {
    for (LocalChangeList list : lists) {
        if (list.isDefault()) {
            return confirmActiveChangeListRemoval(project, lists, list.getChanges().isEmpty());
        }
    }
    boolean haveNoChanges = lists.stream().noneMatch(list -> !list.getChanges().isEmpty());
    String message = lists.size() == 1 ? VcsBundle.message("changes.removechangelist.warning.text", lists.get(0).getName()) : VcsBundle.message("changes.removechangelist.multiple.warning.text", lists.size());
    return haveNoChanges || Messages.YES == Messages.showYesNoDialog(project, message, VcsBundle.message("changes.removechangelist.warning.title"), Messages.getQuestionIcon());
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList)

Example 22 with LocalChangeList

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

the class RenameChangeListAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    ChangeList[] lists = e.getData(VcsDataKeys.CHANGE_LISTS);
    assert lists != null;
    final LocalChangeList list = ChangeListManager.getInstance(project).findChangeList(lists[0].getName());
    if (list != null) {
        new EditChangelistDialog(project, list).show();
    }
}
Also used : Project(com.intellij.openapi.project.Project) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) EditChangelistDialog(com.intellij.openapi.vcs.changes.ui.EditChangelistDialog)

Example 23 with LocalChangeList

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

the class ApplyPatchDifferentiatedDialog method runExecutor.

@CalledInAwt
private void runExecutor(ApplyPatchExecutor executor) {
    final Collection<AbstractFilePatchInProgress> included = getIncluded();
    if (included.isEmpty())
        return;
    final MultiMap<VirtualFile, AbstractFilePatchInProgress> patchGroups = new MultiMap<>();
    for (AbstractFilePatchInProgress patchInProgress : included) {
        patchGroups.putValue(patchInProgress.getBase(), patchInProgress);
    }
    final LocalChangeList selected = getSelectedChangeList();
    FilePresentationModel presentation = myRecentPathFileChange.get();
    VirtualFile vf = presentation != null ? presentation.getVf() : null;
    executor.apply(getOriginalRemaining(), patchGroups, selected, vf == null ? null : vf.getName(), myReader == null ? null : myReader.getAdditionalInfo(ApplyPatchDefaultExecutor.pathsFromGroups(patchGroups)));
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 24 with LocalChangeList

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

the class SwitchTaskAction method removeTask.

public static void removeTask(@NotNull final Project project, LocalTask task, TaskManager manager) {
    if (task.isDefault()) {
        Messages.showInfoMessage(project, "Default task cannot be removed", "Cannot Remove");
    } else {
        List<ChangeListInfo> infos = task.getChangeLists();
        List<LocalChangeList> lists = ContainerUtil.mapNotNull(infos, (NullableFunction<ChangeListInfo, LocalChangeList>) changeListInfo -> {
            LocalChangeList changeList = ChangeListManager.getInstance(project).getChangeList(changeListInfo.id);
            return changeList != null && !changeList.isDefault() ? changeList : null;
        });
        boolean removeIt = true;
        l: for (LocalChangeList list : lists) {
            if (!list.getChanges().isEmpty()) {
                int result = Messages.showYesNoCancelDialog(project, "Changelist associated with '" + task.getSummary() + "' is not empty.\n" + "Do you want to remove it and move the changes to the active changelist?", "Changelist Not Empty", Messages.getWarningIcon());
                switch(result) {
                    case Messages.YES:
                        break l;
                    case Messages.NO:
                        removeIt = false;
                        break;
                    default:
                        return;
                }
            }
        }
        if (removeIt) {
            for (LocalChangeList list : lists) {
                ChangeListManager.getInstance(project).removeChangeList(list);
            }
        }
        manager.removeTask(task);
    }
}
Also used : TaskSettings(com.intellij.tasks.config.TaskSettings) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) ContainerUtil(com.intellij.util.containers.ContainerUtil) ArrayList(java.util.ArrayList) ActionCommand(com.intellij.openapi.ui.playback.commands.ActionCommand) Comparing(com.intellij.openapi.util.Comparing) Disposer(com.intellij.openapi.util.Disposer) Project(com.intellij.openapi.project.Project) Messages(com.intellij.openapi.ui.Messages) LocalTask(com.intellij.tasks.LocalTask) ComboBoxAction(com.intellij.openapi.actionSystem.ex.ComboBoxAction) DumbAware(com.intellij.openapi.project.DumbAware) DataManager(com.intellij.ide.DataManager) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) StringUtil(com.intellij.openapi.util.text.StringUtil) SimpleActionGroup(com.intellij.tools.SimpleActionGroup) NullableFunction(com.intellij.util.NullableFunction) com.intellij.openapi.ui.popup(com.intellij.openapi.ui.popup) KeyEvent(java.awt.event.KeyEvent) ActionEvent(java.awt.event.ActionEvent) Disposable(com.intellij.openapi.Disposable) java.awt(java.awt) com.intellij.openapi.actionSystem(com.intellij.openapi.actionSystem) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) ChangeListInfo(com.intellij.tasks.ChangeListInfo) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) ListPopupImpl(com.intellij.ui.popup.list.ListPopupImpl) Collections(java.util.Collections) TaskManager(com.intellij.tasks.TaskManager) javax.swing(javax.swing) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListInfo(com.intellij.tasks.ChangeListInfo)

Example 25 with LocalChangeList

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

the class HgTestChangeListManager method commitFiles.

/**
   * Commits all changes of the given files.
   */
public void commitFiles(VirtualFile... files) {
    ensureUpToDate();
    final List<Change> changes = new ArrayList<>(files.length);
    for (VirtualFile f : files) {
        changes.addAll(peer.getChangesIn(f));
    }
    final LocalChangeList list = peer.getDefaultChangeList();
    assertNotNull(list);
    list.setComment("A comment to a commit");
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {

        @Override
        public void run() {
            Assert.assertTrue(peer.commitChangesSynchronouslyWithResult(list, changes));
        }
    });
    ensureUpToDate();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ArrayList(java.util.ArrayList) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) Change(com.intellij.openapi.vcs.changes.Change)

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