public void projectOpened() {

    TaskProjectConfiguration projectConfiguration = getProjectConfiguration();

    servers:
    for (TaskProjectConfiguration.SharedServer server : projectConfiguration.servers) {
      if (server.type == null || server.url == null) {
        continue;
      }
      for (TaskRepositoryType<?> repositoryType : TaskRepositoryType.getRepositoryTypes()) {
        if (repositoryType.getName().equals(server.type)) {
          for (TaskRepository repository : myRepositories) {
            if (!repositoryType.equals(repository.getRepositoryType())) {
              continue;
            }
            if (server.url.equals(repository.getUrl())) {
              continue servers;
            }
          }
          TaskRepository repository = repositoryType.createRepository();
          repository.setUrl(server.url);
          myRepositories.add(repository);
        }
      }
    }

    myContextManager.pack(200, 50);

    // make sure the task is associated with default changelist
    LocalTask defaultTask = findTask(LocalTaskImpl.DEFAULT_TASK_ID);
    LocalChangeList defaultList = myChangeListManager.findChangeList(LocalChangeList.DEFAULT_NAME);
    if (defaultList != null && defaultTask != null) {
      ChangeListInfo listInfo = new ChangeListInfo(defaultList);
      if (!defaultTask.getChangeLists().contains(listInfo)) {
        defaultTask.addChangelist(listInfo);
      }
    }

    // remove already not existing changelists from tasks changelists
    for (LocalTask localTask : getLocalTasks()) {
      for (Iterator<ChangeListInfo> iterator = localTask.getChangeLists().iterator();
          iterator.hasNext(); ) {
        final ChangeListInfo changeListInfo = iterator.next();
        if (myChangeListManager.getChangeList(changeListInfo.id) == null) {
          iterator.remove();
        }
      }
    }

    myChangeListManager.addChangeListListener(myChangeListListener);
  }
 private void notifyAboutConnectionFailure(final TaskRepository repository, String details) {
   Notifications.Bus.register(TASKS_NOTIFICATION_GROUP, NotificationDisplayType.BALLOON);
   String content = "<p><a href=\"\">Configure server...</a></p>";
   if (!StringUtil.isEmpty(details)) {
     content = "<p>" + details + "</p>" + content;
   }
   Notifications.Bus.notify(
       new Notification(
           TASKS_NOTIFICATION_GROUP,
           "Cannot connect to " + repository.getUrl(),
           content,
           NotificationType.WARNING,
           new NotificationListener() {
             public void hyperlinkUpdate(
                 @NotNull Notification notification, @NotNull HyperlinkEvent event) {
               TaskRepositoriesConfigurable configurable =
                   new TaskRepositoriesConfigurable(myProject);
               ShowSettingsUtil.getInstance().editConfigurable(myProject, configurable);
               if (!ArrayUtil.contains(repository, getAllRepositories())) {
                 notification.expire();
               }
             }
           }),
       myProject);
 }
 @Nullable
 private List<Task> getIssuesFromRepositories(
     @Nullable String request,
     int max,
     long since,
     boolean forceRequest,
     @NotNull final ProgressIndicator cancelled) {
   List<Task> issues = null;
   for (final TaskRepository repository : getAllRepositories()) {
     if (!repository.isConfigured() || (!forceRequest && myBadRepositories.contains(repository))) {
       continue;
     }
     try {
       Task[] tasks = repository.getIssues(request, max, since, cancelled);
       myBadRepositories.remove(repository);
       if (issues == null) issues = new ArrayList<Task>(tasks.length);
       if (!repository.isSupported(TaskRepository.NATIVE_SEARCH) && request != null) {
         List<Task> filteredTasks =
             TaskSearchSupport.filterTasks(request, ContainerUtil.list(tasks));
         ContainerUtil.addAll(issues, filteredTasks);
       } else {
         ContainerUtil.addAll(issues, tasks);
       }
     } catch (ProcessCanceledException ignored) {
       // OK
     } catch (Exception e) {
       String reason = "";
       // Fix to IDEA-111810
       if (e.getClass() == Exception.class) {
         // probably contains some message meaningful to end-user
         reason = e.getMessage();
       }
       //noinspection InstanceofCatchParameter
       if (e instanceof SocketTimeoutException) {
         LOG.warn("Socket timeout from " + repository);
       } else {
         LOG.warn("Cannot connect to " + repository, e);
       }
       myBadRepositories.add(repository);
       if (forceRequest) {
         notifyAboutConnectionFailure(repository, reason);
       }
     }
   }
   return issues;
 }
 public static ArrayList<TaskRepository> loadRepositories(Element element) {
   ArrayList<TaskRepository> repositories = new ArrayList<TaskRepository>();
   for (TaskRepositoryType repositoryType : TaskRepositoryType.getRepositoryTypes()) {
     for (Object o : element.getChildren()) {
       if (((Element) o).getName().equals(repositoryType.getName())) {
         try {
           @SuppressWarnings({"unchecked"})
           TaskRepository repository =
               (TaskRepository)
                   XmlSerializer.deserialize((Element) o, repositoryType.getRepositoryClass());
           if (repository != null) {
             repository.setRepositoryType(repositoryType);
             repositories.add(repository);
           }
         } catch (XmlSerializationException e) {
           // ignore
           LOG.error(e.getMessage());
         }
       }
     }
   }
   return repositories;
 }
 @Nullable
 @Override
 public Task updateIssue(@NotNull String id) {
   for (TaskRepository repository : getAllRepositories()) {
     if (repository.extractId(id) == null) {
       continue;
     }
     try {
       Task issue = repository.findTask(id);
       if (issue != null) {
         LocalTask localTask = findTask(id);
         if (localTask != null) {
           localTask.updateFromIssue(issue);
           return localTask;
         }
         return issue;
       }
     } catch (Exception e) {
       LOG.info(e);
     }
   }
   return null;
 }