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;
  }
  public void initComponent() {
    if (!ApplicationManager.getApplication().isUnitTestMode()) {
      myCacheRefreshTimer =
          UIUtil.createNamedTimer(
              "TaskManager refresh",
              myConfig.updateInterval * 60 * 1000,
              new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  if (myConfig.updateEnabled && !myUpdating) {
                    updateIssues(null);
                  }
                }
              });
      myCacheRefreshTimer.setInitialDelay(0);
      StartupManager.getInstance(myProject)
          .registerPostStartupActivity(
              new Runnable() {
                public void run() {
                  myCacheRefreshTimer.start();
                }
              });
    }

    // make sure that the default task is exist
    LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID);
    if (defaultTask == null) {
      defaultTask = createDefaultTask();
      addTask(defaultTask);
    }

    // search for active task
    LocalTask activeTask = null;
    final List<LocalTask> tasks = getLocalTasks();
    Collections.sort(tasks, TASK_UPDATE_COMPARATOR);
    for (LocalTask task : tasks) {
      if (activeTask == null) {
        if (task.isActive()) {
          activeTask = task;
        }
      } else {
        task.setActive(false);
      }
    }
    if (activeTask == null) {
      activeTask = defaultTask;
    }

    myActiveTask = activeTask;
    doActivate(myActiveTask, false);
    myDispatcher.getMulticaster().taskActivated(myActiveTask);
  }