private void doUpdate(@Nullable Runnable onComplete) {
    try {
      List<Task> issues =
          getIssuesFromRepositories(
              null, myConfig.updateIssuesCount, 0, false, new EmptyProgressIndicator());
      if (issues == null) return;

      synchronized (myIssueCache) {
        myIssueCache.clear();
        for (Task issue : issues) {
          myIssueCache.put(issue.getId(), issue);
        }
      }
      // update local tasks
      synchronized (myTasks) {
        for (Map.Entry<String, LocalTask> entry : myTasks.entrySet()) {
          Task issue = myIssueCache.get(entry.getKey());
          if (issue != null) {
            entry.getValue().updateFromIssue(issue);
          }
        }
      }
    } finally {
      if (onComplete != null) {
        onComplete.run();
      }
      myUpdating = false;
    }
  }
 public String suggestBranchName(Task task) {
   if (task.isIssue() && StringUtil.isNotEmpty(task.getNumber())) {
     return task.getId().replace(' ', '-');
   } else {
     String summary = task.getSummary();
     List<String> words = StringUtil.getWordsIn(summary);
     String[] strings = ArrayUtil.toStringArray(words);
     return StringUtil.join(strings, 0, Math.min(2, strings.length), "-");
   }
 }
  public void testSuggestBranchName() throws Exception {
    Task task = myRepository.findTask("TEST-001");
    assertNotNull(task);
    assertTrue(task.isIssue());
    assertEquals("TEST-001", myTaskManager.suggestBranchName(task));

    LocalTaskImpl simple = new LocalTaskImpl("1", "simple");
    assertEquals("simple", myTaskManager.suggestBranchName(simple));

    LocalTaskImpl strange = new LocalTaskImpl("1", "very long and strange summary");
    assertEquals("very-long", myTaskManager.suggestBranchName(strange));

    myTaskManager.getState().branchNameFormat = "{id} {summary}";

    LocalTaskImpl withIllegalSymbolsInIssue = new LocalTaskImpl("1", "contains Illegal$Symbols");
    withIllegalSymbolsInIssue.setIssue(true);
    assertEquals(
        "1-contains-Illegal$Symbols", myTaskManager.suggestBranchName(withIllegalSymbolsInIssue));
  }
  @Override
  public LocalTask activateTask(@NotNull final Task origin, boolean clearContext) {
    LocalTask activeTask = getActiveTask();
    if (origin.equals(activeTask)) return activeTask;

    saveActiveTask();

    if (clearContext) {
      myContextManager.clearContext();
    }
    myContextManager.restoreContext(origin);

    final LocalTask task = doActivate(origin, true);

    return restoreVcsContext(task);
  }
 public String getChangelistName(Task task) {
   if (task.isIssue() && myConfig.changelistNameFormat != null) {
     return TaskUtil.formatTask(task, myConfig.changelistNameFormat);
   }
   return task.getSummary();
 }
 @Override
 public String convert(Task o) {
   return o.getId();
 }
 public int compare(Task o1, Task o2) {
   int i = Comparing.compare(o2.getUpdated(), o1.getUpdated());
   return i == 0 ? Comparing.compare(o2.getCreated(), o1.getCreated()) : i;
 }