Search in sources :

Example 1 with TaskManagerImpl

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

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

the class OpenTaskDialog method createTask.

public void createTask() {
    final TaskManagerImpl taskManager = (TaskManagerImpl) TaskManager.getManager(myProject);
    if (myUpdateState.isSelected()) {
        final CustomTaskState taskState = myTaskStateCombo.getSelectedState();
        final TaskRepository repository = myTask.getRepository();
        if (repository != null && taskState != null) {
            try {
                repository.setTaskState(myTask, taskState);
                repository.setPreferredOpenTaskState(taskState);
            } catch (Exception ex) {
                Messages.showErrorDialog(myProject, ex.getMessage(), "Cannot Set State For Issue");
                LOG.warn(ex);
            }
        }
    }
    taskManager.activateTask(myTask, isClearContext());
    if (myTask.getType() == TaskType.EXCEPTION && AnalyzeTaskStacktraceAction.hasTexts(myTask)) {
        AnalyzeTaskStacktraceAction.analyzeStacktrace(myTask, myProject);
    }
    for (TaskDialogPanel panel : myPanels) {
        panel.commit();
    }
}
Also used : TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) TaskDialogPanel(com.intellij.tasks.ui.TaskDialogPanel)

Example 3 with TaskManagerImpl

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

the class TaskSettingsTest method testCarriageReturnInFormat.

public void testCarriageReturnInFormat() throws Exception {
    TaskRepository repository = new YouTrackRepository();
    String format = "foo \n bar";
    repository.setCommitMessageFormat(format);
    ((TaskManagerImpl) myTaskManager).setRepositories(Collections.singletonList(repository));
    TaskManagerImpl.Config config = ((TaskManagerImpl) myTaskManager).getState();
    Element element = XmlSerializer.serialize(config);
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    JDOMUtil.writeDocument(new Document(element), stream, "\n");
    Element element1 = JDOMUtil.load(new ByteArrayInputStream(stream.toByteArray()));
    TaskManagerImpl.Config deserialize = XmlSerializer.deserialize(element1, TaskManagerImpl.Config.class);
    ((TaskManagerImpl) myTaskManager).loadState(deserialize);
    TaskRepository[] repositories = myTaskManager.getAllRepositories();
    assertEquals(format, repositories[0].getCommitMessageFormat());
}
Also used : YouTrackRepository(com.intellij.tasks.youtrack.YouTrackRepository) ByteArrayInputStream(java.io.ByteArrayInputStream) Element(org.jdom.Element) TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Document(org.jdom.Document)

Example 4 with TaskManagerImpl

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

the class TaskCompletionTest method configureRepository.

private TestRepository configureRepository(LocalTaskImpl... tasks) {
    TaskManagerImpl manager = getManager();
    TestRepository repository = new TestRepository(tasks);
    manager.setRepositories(Arrays.asList(repository));
    manager.getState().updateEnabled = false;
    return repository;
}
Also used : TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl)

Example 5 with TaskManagerImpl

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

the class TaskManagerTest method testBranchNameSuggestion.

public void testBranchNameSuggestion() throws Exception {
    TaskTestUtil.TaskBuilder task = new TaskTestUtil.TaskBuilder("IDEA-666", "Bad news", null);
    TaskManagerImpl taskManager = myTaskManager;
    assertEquals("IDEA-666", taskManager.suggestBranchName(task));
    String format = taskManager.getState().branchNameFormat;
    try {
        taskManager.getState().branchNameFormat = "feature/{id}";
        assertEquals("feature/IDEA-666", taskManager.suggestBranchName(task));
        taskManager.getState().branchNameFormat = "{id}_{summary}";
        assertEquals("IDEA-666_Bad-news", taskManager.suggestBranchName(task));
    } finally {
        taskManager.getState().branchNameFormat = format;
    }
}
Also used : TaskManagerImpl(com.intellij.tasks.impl.TaskManagerImpl)

Aggregations

TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)8 LocalTask (com.intellij.tasks.LocalTask)2 InsertHandler (com.intellij.codeInsight.completion.InsertHandler)1 InsertionContext (com.intellij.codeInsight.completion.InsertionContext)1 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 Document (com.intellij.openapi.editor.Document)1 Project (com.intellij.openapi.project.Project)1 CustomTaskState (com.intellij.tasks.CustomTaskState)1 TaskManager (com.intellij.tasks.TaskManager)1 TaskRepository (com.intellij.tasks.TaskRepository)1 TaskDialogPanel (com.intellij.tasks.ui.TaskDialogPanel)1 YouTrackRepository (com.intellij.tasks.youtrack.YouTrackRepository)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 Document (org.jdom.Document)1 Element (org.jdom.Element)1