Search in sources :

Example 16 with LocalTask

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

the class SwitchTaskAction method createPopupActionGroup.

@NotNull
private static List<TaskListItem> createPopupActionGroup(@NotNull final Project project, final Ref<Boolean> shiftPressed, final Component contextComponent) {
    List<TaskListItem> group = new ArrayList<>();
    final AnAction action = ActionManager.getInstance().getAction(GotoTaskAction.ID);
    assert action instanceof GotoTaskAction;
    final GotoTaskAction gotoTaskAction = (GotoTaskAction) action;
    group.add(new TaskListItem(gotoTaskAction.getTemplatePresentation().getText(), gotoTaskAction.getTemplatePresentation().getIcon()) {

        @Override
        void select() {
            ActionManager.getInstance().tryToExecute(gotoTaskAction, ActionCommand.getInputEvent(GotoTaskAction.ID), contextComponent, ActionPlaces.UNKNOWN, false);
        }
    });
    final TaskManager manager = TaskManager.getManager(project);
    LocalTask activeTask = manager.getActiveTask();
    List<LocalTask> localTasks = manager.getLocalTasks();
    Collections.sort(localTasks, TaskManagerImpl.TASK_UPDATE_COMPARATOR);
    ArrayList<LocalTask> temp = new ArrayList<>();
    for (final LocalTask task : localTasks) {
        if (task == activeTask) {
            continue;
        }
        if (manager.isLocallyClosed(task)) {
            temp.add(task);
            continue;
        }
        group.add(new TaskListItem(task, group.size() == 1 ? "" : null, false) {

            @Override
            void select() {
                manager.activateTask(task, !shiftPressed.get());
            }
        });
    }
    if (!temp.isEmpty()) {
        for (int i = 0, tempSize = temp.size(); i < Math.min(tempSize, 15); i++) {
            final LocalTask task = temp.get(i);
            group.add(new TaskListItem(task, i == 0 ? "Recently Closed Tasks" : null, true) {

                @Override
                void select() {
                    manager.activateTask(task, !shiftPressed.get());
                }
            });
        }
    }
    return group;
}
Also used : TaskManager(com.intellij.tasks.TaskManager) ArrayList(java.util.ArrayList) LocalTask(com.intellij.tasks.LocalTask) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with LocalTask

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

the class TaskCellRenderer method getListCellRendererComponent.

public Component getListCellRendererComponent(JList list, Object value, int index, boolean sel, boolean focus) {
    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(UIUtil.getListBackground(sel));
    panel.setForeground(UIUtil.getListForeground(sel));
    if (value instanceof TaskPsiElement) {
        final Task task = ((TaskPsiElement) value).getTask();
        final SimpleColoredComponent c = new SimpleColoredComponent();
        final TaskManager taskManager = TaskManager.getManager(myProject);
        final boolean isLocalTask = taskManager.findTask(task.getId()) != null;
        final boolean isClosed = task.isClosed() || (task instanceof LocalTask && taskManager.isLocallyClosed((LocalTask) task));
        final Color bg = sel ? UIUtil.getListSelectionBackground() : isLocalTask ? UIUtil.getListBackground() : UIUtil.getDecoratedRowColor();
        panel.setBackground(bg);
        SimpleTextAttributes attr = getAttributes(sel, isClosed);
        c.setIcon(isClosed ? IconLoader.getTransparentIcon(task.getIcon()) : task.getIcon());
        SpeedSearchUtil.appendColoredFragmentForMatcher(task.getPresentableName(), c, attr, MatcherHolder.getAssociatedMatcher(list), bg, sel);
        panel.add(c, BorderLayout.CENTER);
    } else if ("...".equals(value)) {
        final SimpleColoredComponent c = new SimpleColoredComponent();
        c.setIcon(EmptyIcon.ICON_16);
        c.append((String) value);
        panel.add(c, BorderLayout.CENTER);
    } else if (GotoTaskAction.CREATE_NEW_TASK_ACTION == value) {
        final SimpleColoredComponent c = new SimpleColoredComponent();
        c.setIcon(LayeredIcon.create(TasksIcons.Unknown, AllIcons.Actions.New));
        c.append(GotoTaskAction.CREATE_NEW_TASK_ACTION.getActionText());
        panel.add(c, BorderLayout.CENTER);
    } else if (ChooseByNameBase.NON_PREFIX_SEPARATOR == value) {
        return ChooseByNameBase.renderNonPrefixSeparatorComponent(UIUtil.getListBackground());
    }
    return panel;
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) TaskManager(com.intellij.tasks.TaskManager) SimpleTextAttributes(com.intellij.ui.SimpleTextAttributes) LocalTask(com.intellij.tasks.LocalTask) TaskPsiElement(com.intellij.tasks.doc.TaskPsiElement) SimpleColoredComponent(com.intellij.ui.SimpleColoredComponent)

Example 18 with LocalTask

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

the class AnalyzeTaskStacktraceAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    final LocalTask activeTask = getActiveTask(e);
    final Project project = getProject(e);
    assert activeTask != null;
    assert project != null;
    analyzeStacktrace(activeTask, project);
}
Also used : Project(com.intellij.openapi.project.Project) LocalTask(com.intellij.tasks.LocalTask)

Example 19 with LocalTask

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

the class CreateChangelistAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    TaskManagerImpl manager = (TaskManagerImpl) getTaskManager(e);
    assert manager != null;
    LocalTask activeTask = manager.getActiveTask();
    String name = Messages.showInputDialog(getProject(e), "Changelist name:", "Create Changelist", null, manager.getChangelistName(activeTask), null);
    if (name != null) {
        manager.createChangeList(activeTask, name);
    }
}
Also used : TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) LocalTask(com.intellij.tasks.LocalTask)

Aggregations

LocalTask (com.intellij.tasks.LocalTask)19 Project (com.intellij.openapi.project.Project)7 TaskManager (com.intellij.tasks.TaskManager)7 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)6 Repository (com.intellij.dvcs.repo.Repository)4 Task (com.intellij.tasks.Task)4 TaskPsiElement (com.intellij.tasks.doc.TaskPsiElement)3 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)3 ActionEvent (java.awt.event.ActionEvent)3 NotNull (org.jetbrains.annotations.NotNull)3 TaskRepository (com.intellij.tasks.TaskRepository)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 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