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;
    }
  }
 @Override
 public void removeTask(LocalTask task) {
   if (task.isDefault()) return;
   if (myActiveTask.equals(task)) {
     activateTask(myTasks.get(LocalTaskImpl.DEFAULT_TASK_ID), true);
   }
   myTasks.remove(task.getId());
   myDispatcher.getMulticaster().taskRemoved(task);
   myContextManager.removeContext(task);
 }
 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);
               }
             });
   }
 }
  @Override
  public void rebuildList() {
    if (myInRebuildList) return;
    try {
      myInRebuildList = true;
      if (myChangesToDisplay == null) {
        // changes set not fixed === local changes
        final ChangeListManager manager = ChangeListManager.getInstance(myProject);
        myChangeListsMap = new HashMap<Change, LocalChangeList>();
        final List<LocalChangeList> lists = manager.getChangeListsCopy();
        Collection<Change> allChanges = new ArrayList<Change>();
        for (LocalChangeList list : lists) {
          final Collection<Change> changes = list.getChanges();
          allChanges.addAll(changes);
          for (Change change : changes) {
            myChangeListsMap.put(change, list);
          }
        }
        myAllChanges = allChanges;
        // refresh selected list also
        updateListsInChooser();
      }

      super.rebuildList();
      if (myRebuildListListener != null) {
        myRebuildListListener.run();
      }
    } finally {
      myInRebuildList = false;
    }
  }
  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);
      }
    }
  }
 @Override
 public List<Task> getCachedIssues(final boolean withClosed) {
   return ContainerUtil.filter(
       myIssueCache.values(),
       new Condition<Task>() {
         @Override
         public boolean value(final Task task) {
           return withClosed || !task.isClosed();
         }
       });
 }
 @Override
 public void run(ContinuationContext context) {
   if (myTheirsBinaryChanges.isEmpty()) return;
   final List<Change> converted;
   try {
     converted = convertPaths(myTheirsBinaryChanges);
   } catch (VcsException e) {
     context.handleException(e, true);
     return;
   }
   if (converted.isEmpty()) return;
   final Map<FilePath, Change> map = new HashMap<FilePath, Change>();
   for (Change change : converted) {
     map.put(ChangesUtil.getFilePath(change), change);
   }
   final Collection<FilePath> selected = chooseBinaryFiles(converted, map.keySet());
   myTheirsBinaryChanges.clear();
   for (FilePath filePath : selected) {
     myTheirsBinaryChanges.add(map.get(filePath));
   }
 }
 @Override
 public List<LocalTask> getLocalTasks(final boolean withClosed) {
   synchronized (myTasks) {
     return ContainerUtil.filter(
         myTasks.values(),
         new Condition<LocalTask>() {
           @Override
           public boolean value(final LocalTask task) {
             return withClosed || !isLocallyClosed(task);
           }
         });
   }
 }
  @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);
  }
 @SuppressWarnings({"unchecked"})
 @NotNull
 public Config getState() {
   myConfig.tasks =
       ContainerUtil.map(
           myTasks.values(),
           new Function<Task, LocalTaskImpl>() {
             public LocalTaskImpl fun(Task task) {
               return new LocalTaskImpl(task);
             }
           });
   myConfig.servers = XmlSerializer.serialize(getAllRepositories());
   return myConfig;
 }
Example #11
0
    private boolean isLocalRevisionMergeIteration(
        final TreeStructureNode<SVNLogEntry> tree,
        final String localURL,
        ProgressIndicator indicator) {
      final LinkedList<TreeStructureNode<SVNLogEntry>> queue =
          new LinkedList<TreeStructureNode<SVNLogEntry>>();
      queue.addLast(tree);

      while (!queue.isEmpty()) {
        final TreeStructureNode<SVNLogEntry> element = queue.removeFirst();
        indicator.checkCanceled();

        final Map map = element.getMe().getChangedPaths();
        for (Object o : map.values()) {
          final SVNLogEntryPath path = (SVNLogEntryPath) o;
          if (SVNPathUtil.isAncestor(localURL, path.getPath())) {
            return true;
          }
          break; // do not check all. first should match or fail
        }
        queue.addAll(element.getChildren());
      }
      return false;
    }
 @Override
 public List<Task> getIssues(
     @Nullable String query,
     int max,
     long since,
     boolean forceRequest,
     final boolean withClosed,
     @NotNull final ProgressIndicator cancelled) {
   List<Task> tasks = getIssuesFromRepositories(query, max, since, forceRequest, cancelled);
   if (tasks == null) return getCachedIssues(withClosed);
   myIssueCache.putAll(ContainerUtil.newMapFromValues(tasks.iterator(), KEY_CONVERTOR));
   return ContainerUtil.filter(
       tasks,
       new Condition<Task>() {
         @Override
         public boolean value(final Task task) {
           return withClosed || !task.isClosed();
         }
       });
 }
 private ChangeList getList(final Change change) {
   return myChangeListsMap.get(change);
 }
 @Nullable
 @Override
 public LocalTask findTask(String id) {
   return myTasks.get(id);
 }
Example #15
0
 public String getComment(final String listName) {
   return myLists.get(listName);
 }
Example #16
0
 public void add(
     @NotNull final String listName, @Nullable final String comment, final Change change) {
   myChangesSubset.putValue(listName, change);
   final String commentToPut = comment == null ? listName : comment;
   myLists.put(listName, commentToPut);
 }
 private void addTask(LocalTaskImpl task) {
   myTasks.put(task.getId(), task);
   myDispatcher.getMulticaster().taskAdded(task);
 }