Search in sources :

Example 1 with LocalTaskImpl

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

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

the class TaskCompletionTest method doTest.

private void doTest(String text, final String after) {
    configureFile(text);
    final TestRepository repository = configureRepository();
    repository.setTasks(new LocalTaskImpl("TEST-001", "Test task") {

        @Override
        public TaskRepository getRepository() {
            return repository;
        }

        @Override
        public boolean isIssue() {
            return true;
        }
    });
    myFixture.completeBasic();
    myFixture.checkResult(after);
}
Also used : LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl)

Example 3 with LocalTaskImpl

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

the class TaskCompletionTest method testKeepOrder.

public void testKeepOrder() throws Exception {
    configureFile("<caret>");
    configureRepository(new LocalTaskImpl("TEST-002", "Test task 2"), new LocalTaskImpl("TEST-003", "Test task 1"), new LocalTaskImpl("TEST-001", "Test task 1"), new LocalTaskImpl("TEST-004", "Test task 1"));
    getManager().updateIssues(null);
    List<Task> issues = getManager().getCachedIssues();
    //    assertEquals("TEST-002", issues.get(0).getSummary());
    myFixture.complete(CompletionType.BASIC);
    assertEquals(Arrays.asList("TEST-002", "TEST-003", "TEST-001", "TEST-004"), myFixture.getLookupElementStrings());
}
Also used : LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl)

Example 4 with LocalTaskImpl

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

the class TaskManagerTest method testIssuesCacheSurvival.

public void testIssuesCacheSurvival() throws Exception {
    final Ref<Boolean> stopper = new Ref<>(Boolean.FALSE);
    TestRepository repository = new TestRepository(new LocalTaskImpl("foo", "bar")) {

        @Override
        public Task[] getIssues(@Nullable String query, int max, long since) throws Exception {
            if (stopper.get())
                throw new Exception();
            return super.getIssues(query, max, since);
        }
    };
    myTaskManager.setRepositories(Collections.singletonList(repository));
    List<Task> issues = myTaskManager.getIssues("");
    assertEquals(1, issues.size());
    stopper.set(Boolean.TRUE);
    issues = myTaskManager.getIssues("");
    assertEquals(1, issues.size());
}
Also used : Ref(com.intellij.openapi.util.Ref) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with LocalTaskImpl

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

the class JiraIntegrationTest method testSetTimeSpend.

public void testSetTimeSpend() throws Exception {
    // only REST API 2.0 supports this feature
    myRepository.setUrl(JIRA_5_TEST_SERVER_URL);
    final String issueId = createIssueViaRestApi("BTTTU", "Test issue for time tracking updates (" + SHORT_TIMESTAMP_FORMAT.format(new Date()) + ")");
    final Task task = myRepository.findTask(issueId);
    assertNotNull("Test task not found", task);
    // timestamp as comment
    final String comment = "Timestamp: " + TaskUtil.formatDate(new Date());
    final Couple<Integer> duration = generateWorkItemDuration();
    final int hours = duration.getFirst(), minutes = duration.getSecond();
    myRepository.updateTimeSpent(new LocalTaskImpl(task), String.format("%dh %dm", hours, minutes), comment);
    final GetMethod request = new GetMethod(myRepository.getRestUrl("issue", task.getId(), "worklog"));
    final String response = myRepository.executeMethod(request);
    final JsonObject object = new Gson().fromJson(response, JsonObject.class);
    final JsonArray worklogs = object.get("worklogs").getAsJsonArray();
    final JsonObject last = worklogs.get(worklogs.size() - 1).getAsJsonObject();
    assertEquals(comment, last.get("comment").getAsString());
    // don't depend on concrete response format: zero hours stripping, zero padding and so on
    assertEquals((hours * 60 + minutes) * 60, last.get("timeSpentSeconds").getAsInt());
}
Also used : JsonArray(com.google.gson.JsonArray) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) GetMethod(org.apache.commons.httpclient.methods.GetMethod) JsonObject(com.google.gson.JsonObject) Gson(com.google.gson.Gson)

Aggregations

LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)20 LocalTask (com.intellij.tasks.LocalTask)5 Repository (com.intellij.dvcs.repo.Repository)4 BranchInfo (com.intellij.tasks.BranchInfo)2 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 LookupElement (com.intellij.codeInsight.lookup.LookupElement)1 Project (com.intellij.openapi.project.Project)1 Ref (com.intellij.openapi.util.Ref)1 Task (com.intellij.tasks.Task)1 TaskManager (com.intellij.tasks.TaskManager)1 OpenTaskDialog (com.intellij.tasks.actions.OpenTaskDialog)1 GitlabTask (com.intellij.tasks.gitlab.GitlabTask)1 GitlabIssue (com.intellij.tasks.gitlab.model.GitlabIssue)1 GitlabProject (com.intellij.tasks.gitlab.model.GitlabProject)1 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)1 SimpleActionGroup (com.intellij.tools.SimpleActionGroup)1 HttpClient (org.apache.commons.httpclient.HttpClient)1 GetMethod (org.apache.commons.httpclient.methods.GetMethod)1