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;
}
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);
}
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());
}
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());
}
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());
}
Aggregations