Search in sources :

Example 11 with TaskManager

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

the class AssociateWithTaskAction method isSelected.

@Override
public boolean isSelected(AnActionEvent e) {
    ChangeList[] lists = e.getData(VcsDataKeys.CHANGE_LISTS);
    if (lists == null) {
        return false;
    }
    Project project = e.getData(CommonDataKeys.PROJECT);
    TaskManager manager = TaskManager.getManager(project);
    for (ChangeList list : lists) {
        if (list instanceof LocalChangeList && manager.getAssociatedTask((LocalChangeList) list) == null) {
            return false;
        }
    }
    return true;
}
Also used : Project(com.intellij.openapi.project.Project) TaskManager(com.intellij.tasks.TaskManager) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeList(com.intellij.openapi.vcs.changes.ChangeList) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList)

Example 12 with TaskManager

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

the class CreateChangelistAction method update.

@Override
public void update(AnActionEvent event) {
    super.update(event);
    if (event.getPresentation().isEnabled()) {
        TaskManager manager = getTaskManager(event);
        Presentation presentation = event.getPresentation();
        if (manager == null || !manager.isVcsEnabled()) {
            presentation.setText(getTemplatePresentation().getText());
            presentation.setEnabled(false);
        } else {
            presentation.setEnabled(true);
            if (manager.getActiveTask().getChangeLists().size() == 0) {
                presentation.setText("Create changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
            } else {
                presentation.setText("Add changelist for '" + TaskUtil.getTrimmedSummary(manager.getActiveTask()) + "'");
            }
        }
    }
}
Also used : TaskManager(com.intellij.tasks.TaskManager) Presentation(com.intellij.openapi.actionSystem.Presentation)

Aggregations

TaskManager (com.intellij.tasks.TaskManager)12 LocalTask (com.intellij.tasks.LocalTask)7 Project (com.intellij.openapi.project.Project)5 LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)3 Task (com.intellij.tasks.Task)3 ActionEvent (java.awt.event.ActionEvent)3 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2 TaskPsiElement (com.intellij.tasks.doc.TaskPsiElement)2 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)2 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)2 SimpleActionGroup (com.intellij.tools.SimpleActionGroup)2 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)2 NullableFunction (com.intellij.util.NullableFunction)2 ArrayList (java.util.ArrayList)2 List (java.util.List)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