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 void updateIssues(final @Nullable Runnable onComplete) { TaskRepository first = ContainerUtil.find( getAllRepositories(), new Condition<TaskRepository>() { public boolean value(TaskRepository repository) { return repository.isConfigured(); } }); if (first == null) { myIssueCache.clear(); if (onComplete != null) { onComplete.run(); } return; } myUpdating = true; if (ApplicationManager.getApplication().isUnitTestMode()) { doUpdate(onComplete); } else { ApplicationManager.getApplication() .executeOnPooledThread( new Runnable() { public void run() { doUpdate(onComplete); } }); } }
public <T extends TaskRepository> void setRepositories(List<T> repositories) { Set<TaskRepository> set = new HashSet<TaskRepository>(myRepositories); set.removeAll(repositories); myBadRepositories.removeAll(set); // remove all changed reps myIssueCache.clear(); myRepositories.clear(); myRepositories.addAll(repositories); reps: for (T repository : repositories) { if (repository.isShared() && repository.getUrl() != null) { List<TaskProjectConfiguration.SharedServer> servers = getProjectConfiguration().servers; TaskRepositoryType type = repository.getRepositoryType(); for (TaskProjectConfiguration.SharedServer server : servers) { if (repository.getUrl().equals(server.url) && type.getName().equals(server.type)) { continue reps; } } TaskProjectConfiguration.SharedServer server = new TaskProjectConfiguration.SharedServer(); server.type = type.getName(); server.url = repository.getUrl(); servers.add(server); } } }
@SuppressWarnings({"unchecked"}) public void loadState(Config config) { XmlSerializerUtil.copyBean(config, myConfig); myTasks.clear(); for (LocalTaskImpl task : config.tasks) { addTask(task); } myRepositories.clear(); Element element = config.servers; List<TaskRepository> repositories = loadRepositories(element); myRepositories.addAll(repositories); }