Search in sources :

Example 6 with LocalTask

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

the class TaskCheckinHandlerFactory method findTaskInRepositories.

@Nullable
private static Task findTaskInRepositories(String message, TaskManager manager) {
    TaskRepository[] repositories = manager.getAllRepositories();
    for (TaskRepository repository : repositories) {
        String id = repository.extractId(message);
        if (id == null)
            continue;
        LocalTask localTask = manager.findTask(id);
        if (localTask != null)
            return localTask;
        try {
            Task task = repository.findTask(id);
            if (task != null) {
                return task;
            }
        } catch (Exception ignore) {
        }
    }
    return null;
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) TaskRepository(com.intellij.tasks.TaskRepository) LocalTask(com.intellij.tasks.LocalTask) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with LocalTask

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

the class SwitchTaskAction method createActionsStep.

private static ActionGroup createActionsStep(final List<TaskListItem> tasks, final Project project, final Ref<Boolean> shiftPressed) {
    SimpleActionGroup group = new SimpleActionGroup();
    final TaskManager manager = TaskManager.getManager(project);
    final LocalTask task = tasks.get(0).getTask();
    if (tasks.size() == 1 && task != null) {
        group.add(new AnAction("&Switch to") {

            public void actionPerformed(AnActionEvent e) {
                manager.activateTask(task, !shiftPressed.get());
            }
        });
        group.add(new AnAction("&Edit") {

            @Override
            public void actionPerformed(AnActionEvent e) {
                EditTaskDialog.editTask((LocalTaskImpl) task, project);
            }
        });
    }
    final AnAction remove = new AnAction("&Remove") {

        @Override
        public void actionPerformed(AnActionEvent e) {
            for (TaskListItem item : tasks) {
                LocalTask itemTask = item.getTask();
                if (itemTask != null) {
                    removeTask(project, itemTask, manager);
                }
            }
        }
    };
    remove.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)), null);
    group.add(remove);
    return group;
}
Also used : SimpleActionGroup(com.intellij.tools.SimpleActionGroup) TaskManager(com.intellij.tasks.TaskManager) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) LocalTask(com.intellij.tasks.LocalTask)

Example 8 with LocalTask

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

the class SwitchTaskAction method update.

@Override
public void update(AnActionEvent e) {
    Presentation presentation = e.getPresentation();
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null || project.isDefault() || project.isDisposed()) {
        presentation.setEnabled(false);
        presentation.setText("");
        presentation.setIcon(null);
    } else {
        TaskManager taskManager = TaskManager.getManager(project);
        LocalTask activeTask = taskManager.getActiveTask();
        presentation.setVisible(true);
        presentation.setEnabled(true);
        if (isImplicit(activeTask) && taskManager.getAllRepositories().length == 0 && !TaskSettings.getInstance().ALWAYS_DISPLAY_COMBO) {
            presentation.setVisible(false);
        } else {
            String s = getText(activeTask);
            presentation.setText(s);
            presentation.setIcon(activeTask.getIcon());
            presentation.setDescription(activeTask.getSummary());
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) TaskManager(com.intellij.tasks.TaskManager) LocalTask(com.intellij.tasks.LocalTask)

Example 9 with LocalTask

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

the class CloseTaskAction method actionPerformed.

public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();
    assert project != null;
    TaskManagerImpl taskManager = (TaskManagerImpl) TaskManager.getManager(project);
    LocalTask task = taskManager.getActiveTask();
    CloseTaskDialog dialog = new CloseTaskDialog(project, task);
    if (dialog.showAndGet()) {
        final CustomTaskState taskState = dialog.getCloseIssueState();
        if (taskState != null) {
            try {
                TaskRepository repository = task.getRepository();
                assert repository != null;
                repository.setTaskState(task, taskState);
                repository.setPreferredCloseTaskState(taskState);
            } catch (Exception e1) {
                Messages.showErrorDialog(project, e1.getMessage(), "Cannot Set State For Issue");
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) TaskRepository(com.intellij.tasks.TaskRepository) TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) LocalTask(com.intellij.tasks.LocalTask) CustomTaskState(com.intellij.tasks.CustomTaskState)

Example 10 with LocalTask

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

the class GotoTaskAction method perform.

void perform(final Project project) {
    final Ref<Boolean> shiftPressed = Ref.create(false);
    final ChooseByNamePopup popup = createPopup(project, new GotoTaskPopupModel(project), new TaskItemProvider(project));
    popup.setShowListForEmptyPattern(true);
    popup.setSearchInAnyPlace(true);
    popup.setAlwaysHasMore(true);
    popup.setAdText("<html>Press SHIFT to merge with current context<br/>" + "Pressing " + KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_QUICK_JAVADOC)) + " would show task description and comments</html>");
    popup.registerAction("shiftPressed", KeyStroke.getKeyStroke("shift pressed SHIFT"), new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            shiftPressed.set(true);
        }
    });
    popup.registerAction("shiftReleased", KeyStroke.getKeyStroke("released SHIFT"), new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            shiftPressed.set(false);
        }
    });
    final DefaultActionGroup group = new DefaultActionGroup(new ConfigureServersAction() {

        @Override
        protected void serversChanged() {
            popup.rebuildList(true);
        }
    });
    final ActionToolbar actionToolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, group, true);
    actionToolbar.setLayoutPolicy(ActionToolbar.NOWRAP_LAYOUT_POLICY);
    actionToolbar.updateActionsImmediately();
    actionToolbar.getComponent().setFocusable(false);
    actionToolbar.getComponent().setBorder(null);
    popup.setToolArea(actionToolbar.getComponent());
    popup.setMaximumListSizeLimit(PAGE_SIZE);
    popup.setListSizeIncreasing(PAGE_SIZE);
    showNavigationPopup(new GotoActionCallback<Object>() {

        @Override
        public void elementChosen(ChooseByNamePopup popup, Object element) {
            TaskManager taskManager = TaskManager.getManager(project);
            if (element instanceof TaskPsiElement) {
                Task task = ((TaskPsiElement) element).getTask();
                LocalTask localTask = taskManager.findTask(task.getId());
                if (localTask != null) {
                    taskManager.activateTask(localTask, !shiftPressed.get());
                } else {
                    showOpenTaskDialog(project, task);
                }
            } else if (element == CREATE_NEW_TASK_ACTION) {
                LocalTask localTask = taskManager.createLocalTask(CREATE_NEW_TASK_ACTION.getTaskName());
                showOpenTaskDialog(project, localTask);
            }
        }
    }, null, popup);
}
Also used : Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) ActionEvent(java.awt.event.ActionEvent) LocalTask(com.intellij.tasks.LocalTask) TaskPsiElement(com.intellij.tasks.doc.TaskPsiElement) TaskManager(com.intellij.tasks.TaskManager)

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