private LocalTask doActivate(Task origin, boolean explicitly) {
    final LocalTaskImpl task =
        origin instanceof LocalTaskImpl ? (LocalTaskImpl) origin : new LocalTaskImpl(origin);
    if (explicitly) {
      task.setUpdated(new Date());
    }
    myActiveTask.setActive(false);
    task.setActive(true);
    addTask(task);
    if (task.isIssue()) {
      StartupManager.getInstance(myProject)
          .runWhenProjectIsInitialized(
              new Runnable() {
                public void run() {
                  ProgressManager.getInstance()
                      .run(
                          new com.intellij.openapi.progress.Task.Backgroundable(
                              myProject, "Updating " + task.getId()) {

                            public void run(@NotNull ProgressIndicator indicator) {
                              updateIssue(task.getId());
                            }
                          });
                }
              });
    }
    LocalTask oldActiveTask = myActiveTask;
    boolean isChanged = !task.equals(oldActiveTask);
    myActiveTask = task;
    if (isChanged) {
      myDispatcher.getMulticaster().taskDeactivated(oldActiveTask);
      myDispatcher.getMulticaster().taskActivated(task);
    }
    return task;
  }
 private static LocalTaskImpl createTask(@NotNull String id, @NotNull String summary) {
   LocalTaskImpl task = new LocalTaskImpl(id, summary);
   Date date = new Date();
   task.setCreated(date);
   task.setUpdated(date);
   return task;
 }
 @Override
 public void trackContext(LocalChangeList changeList) {
   ChangeListInfo changeListInfo = new ChangeListInfo(changeList);
   String changeListName = changeList.getName();
   LocalTaskImpl task = createLocalTask(changeListName);
   task.addChangelist(changeListInfo);
   addTask(task);
   if (changeList.isDefault()) {
     activateTask(task, false);
   }
 }
 private void addTask(LocalTaskImpl task) {
   myTasks.put(task.getId(), task);
   myDispatcher.getMulticaster().taskAdded(task);
 }