Search in sources :

Example 1 with ChangeListInfo

use of com.intellij.tasks.ChangeListInfo 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 2 with ChangeListInfo

use of com.intellij.tasks.ChangeListInfo in project intellij-community by JetBrains.

the class EditTaskDialog method doOKAction.

@Override
protected void doOKAction() {
    myTask.setSummary(mySummary.getText());
    if (myChangelist.isVisible()) {
        List<ChangeListInfo> changeLists = myTask.getChangeLists();
        changeLists.clear();
        LocalChangeList item = (LocalChangeList) myChangelist.getSelectedItem();
        if (item != null) {
            changeLists.add(new ChangeListInfo(item));
        }
    }
    if (myBranch.isVisible()) {
        List<BranchInfo> branches = myTask.getBranches();
        branches.clear();
        VcsTaskHandler.TaskInfo branch = (VcsTaskHandler.TaskInfo) myBranch.getSelectedItem();
        if (branch != null) {
            List<BranchInfo> infos = BranchInfo.fromTaskInfo(branch, false);
            branches.addAll(infos);
        }
    }
    close(OK_EXIT_CODE);
}
Also used : BranchInfo(com.intellij.tasks.BranchInfo) VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListInfo(com.intellij.tasks.ChangeListInfo)

Aggregations

LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)2 ChangeListInfo (com.intellij.tasks.ChangeListInfo)2 DataManager (com.intellij.ide.DataManager)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 ComboBoxAction (com.intellij.openapi.actionSystem.ex.ComboBoxAction)1 DumbAware (com.intellij.openapi.project.DumbAware)1 Project (com.intellij.openapi.project.Project)1 Messages (com.intellij.openapi.ui.Messages)1 ActionCommand (com.intellij.openapi.ui.playback.commands.ActionCommand)1 com.intellij.openapi.ui.popup (com.intellij.openapi.ui.popup)1 Comparing (com.intellij.openapi.util.Comparing)1 Disposer (com.intellij.openapi.util.Disposer)1 Ref (com.intellij.openapi.util.Ref)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 VcsTaskHandler (com.intellij.openapi.vcs.VcsTaskHandler)1 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)1 BranchInfo (com.intellij.tasks.BranchInfo)1 LocalTask (com.intellij.tasks.LocalTask)1 TaskManager (com.intellij.tasks.TaskManager)1