Java 类com.intellij.util.AsynchConsumer 实例源码

项目:intellij-ce-playground    文件:HgCachingCommittedChangesProvider.java   
@Override
public void loadCommittedChanges(ChangeBrowserSettings changeBrowserSettings,
                                 RepositoryLocation repositoryLocation,
                                 int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {

  try {
    List<CommittedChangeList> results = getCommittedChanges(changeBrowserSettings, repositoryLocation, maxCount);
    for (CommittedChangeList result : results) {
      consumer.consume(result);
    }
  }
  finally {
    consumer.finished();
  }
}
项目:intellij-ce-playground    文件:SvnCommittedChangesProvider.java   
public void loadCommittedChanges(@NotNull ChangeBrowserSettings settings,
                                 @NotNull RepositoryLocation location,
                                 int maxCount,
                                 @NotNull final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
  try {
    final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
    final String repositoryRoot = getRepositoryRoot(svnLocation);
    final ChangeBrowserSettings.Filter filter = settings.createFilter();

    getCommittedChangesImpl(settings, svnLocation, maxCount, new Consumer<LogEntry>() {
      public void consume(final LogEntry svnLogEntry) {
        final SvnChangeList cl = new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot);
        if (filter.accepts(cl)) {
          consumer.consume(cl);
        }
      }
    }, false, true);
  }
  finally {
    consumer.finished();
  }
}
项目:eZ-completion    文件:Php.java   
public Php()
{
    Php currentContributor = this;

    DataManager
            .getInstance()
            .getDataContextFromFocus()
            .doWhenDone(new AsynchConsumer<DataContext>()
            {
                @Override
                public void finished() {}

                @Override
                public void consume(DataContext dataContext)
                {
                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
                    CompletionPreloader.getInstance(project).attachContributor(currentContributor);
                }
            });
}
项目:tools-idea    文件:GitHistoryUtils.java   
private static void takeLine(final Project project, String line,
                             StringBuilder sb,
                             GitLogParser parser,
                             SymbolicRefsI refs,
                             VirtualFile root,
                             VcsException[] exc, GitLineHandler h, AsynchConsumer<GitHeavyCommit> gitCommitConsumer) {
  final String text = sb.toString();
  sb.setLength(0);
  sb.append(line);
  if (text.length() == 0) return;
  GitLogRecord record = parser.parseOneRecord(text);

  final GitHeavyCommit gitCommit;
  try {
    gitCommit = createCommit(project, refs, root, record);
  }
  catch (VcsException e) {
    exc[0] = e;
    h.cancel();
    return;
  }
  gitCommitConsumer.consume(gitCommit);
}
项目:tools-idea    文件:LoaderAndRefresherImpl.java   
private void loadFull(final int count, final long continuation) {
  try {
    final Collection<ChangesFilter.Filter> filters = addContinuation(continuation);
    myLowLevelAccess.loadCommits(myStartingPoints, Collections.<String>emptyList(), filters, new AsynchConsumer<GitHeavyCommit>() {
      @Override
      public void consume(GitHeavyCommit gitCommit) {
        if (gitCommit.getParentsHashes().size() <= 1) {
          myDetailsCache.acceptAnswer(Collections.singleton(gitCommit), myRootHolder.getRoot());
        }
        myRepeatingLoadConsumer.consume(GitCommitToCommitConvertor.getInstance().convert(gitCommit));
      }

      @Override
      public void finished() {
      }
    }, count, myProgressAnalog, mySymbolicRefs, myTopoOrder);
  }
  catch (VcsException e) {
    myMediator.acceptException(e);
  }
}
项目:tools-idea    文件:HgCachingCommitedChangesProvider.java   
@Override
public void loadCommittedChanges(ChangeBrowserSettings changeBrowserSettings,
                                 RepositoryLocation repositoryLocation,
                                 int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {

  try {
    List<CommittedChangeList> results = getCommittedChanges(changeBrowserSettings, repositoryLocation, maxCount);
    for (CommittedChangeList result : results) {
      consumer.consume(result);
    }
  }
  finally {
    consumer.finished();
  }
}
项目:intellij-ce-playground    文件:BytecodeAnalysisIntegrationTest.java   
private void setUpExternalUpAnnotations() {
  String annotationsPath = PathManagerEx.getTestDataPath() + "/codeInspection/bytecodeAnalysis/annotations";
  final VirtualFile annotationsDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(annotationsPath);
  assertNotNull(annotationsDir);

  ModuleRootModificationUtil.updateModel(myModule, new AsynchConsumer<ModifiableRootModel>() {
    @Override
    public void finished() {
    }

    @Override
    public void consume(ModifiableRootModel modifiableRootModel) {
      final LibraryTable libraryTable = modifiableRootModel.getModuleLibraryTable();
      Library[] libs = libraryTable.getLibraries();
      for (Library library : libs) {
        final Library.ModifiableModel libraryModel = library.getModifiableModel();
        libraryModel.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
        libraryModel.commit();
      }
      Sdk sdk = modifiableRootModel.getSdk();
      if (sdk != null) {
        SdkModificator sdkModificator = sdk.getSdkModificator();
        sdkModificator.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
        sdkModificator.commitChanges();
      }
    }
  });

  VfsUtilCore.visitChildrenRecursively(annotationsDir, new VirtualFileVisitor() { });
  annotationsDir.refresh(false, true);
}
项目:intellij-ce-playground    文件:AbstractVcsHelperImpl.java   
public void run(@NotNull final ProgressIndicator indicator) {
  final AsynchConsumer<List<CommittedChangeList>> appender = myDlg.getAppender();
  final BufferedListConsumer<CommittedChangeList> bufferedListConsumer = new BufferedListConsumer<CommittedChangeList>(10, appender, -1);

  final Application application = ApplicationManager.getApplication();
  try {
    myProvider.loadCommittedChanges(mySettings, myLocation, 0, new AsynchConsumer<CommittedChangeList>() {
      public void consume(CommittedChangeList committedChangeList) {
        myRevisionsReturned = true;
        bufferedListConsumer.consumeOne(committedChangeList);
        if (myCanceled) {
          indicator.cancel();
        }
      }

      public void finished() {
        bufferedListConsumer.flush();
        appender.finished();

        if (! myRevisionsReturned) {
          application.invokeLater(new Runnable() {
            public void run() {
              myDlg.close(-1);
            }
          }, ModalityState.stateForComponent(myDlg.getWindow()));
        }
      }
    });
  }
  catch (VcsException e) {
    myExceptions.add(e);
    application.invokeLater(new Runnable() {
      public void run() {
        myDlg.close(-1);
      }
    }, ModalityState.stateForComponent(myDlg.getWindow()));
  }
}
项目:intellij-ce-playground    文件:GitCommittedChangeListProvider.java   
public void loadCommittedChanges(ChangeBrowserSettings settings, RepositoryLocation location, int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
  try {
    getCommittedChangesImpl(settings, location, maxCount, new Consumer<GitCommittedChangeList>() {
      @Override
      public void consume(GitCommittedChangeList gitCommittedChangeList) {
        consumer.consume(gitCommittedChangeList);
      }
    });
  }
  finally {
    consumer.finished();
  }
}
项目:vso-intellij    文件:TFSCommittedChangesProvider.java   
public List<TFSChangeList> getCommittedChanges(final ChangeBrowserSettings settings,
                                               final RepositoryLocation location,
                                               final int maxCount) throws VcsException {
    final List<TFSChangeList> result = new ArrayList<TFSChangeList>();
    loadCommittedChanges(settings, location, maxCount, new AsynchConsumer<CommittedChangeList>() {
        public void finished() {
        }

        public void consume(final CommittedChangeList committedChangeList) {
            result.add((TFSChangeList) committedChangeList);
        }
    });
    return result;
}
项目:tools-idea    文件:AbstractVcsHelperImpl.java   
public void run(@NotNull final ProgressIndicator indicator) {
  final AsynchConsumer<List<CommittedChangeList>> appender = myDlg.getAppender();
  final BufferedListConsumer<CommittedChangeList> bufferedListConsumer = new BufferedListConsumer<CommittedChangeList>(10, appender, -1);

  final Application application = ApplicationManager.getApplication();
  try {
    myProvider.loadCommittedChanges(mySettings, myLocation, 0, new AsynchConsumer<CommittedChangeList>() {
      public void consume(CommittedChangeList committedChangeList) {
        myRevisionsReturned = true;
        bufferedListConsumer.consumeOne(committedChangeList);
        if (myCanceled) {
          indicator.cancel();
        }
      }

      public void finished() {
        bufferedListConsumer.flush();
        appender.finished();

        if (! myRevisionsReturned) {
          application.invokeLater(new Runnable() {
            public void run() {
              myDlg.close(-1);
            }
          }, ModalityState.stateForComponent(myDlg.getWindow()));
        }
      }
    });
  }
  catch (VcsException e) {
    myExceptions.add(e);
    application.invokeLater(new Runnable() {
      public void run() {
        myDlg.close(-1);
      }
    }, ModalityState.stateForComponent(myDlg.getWindow()));
  }
}
项目:tools-idea    文件:GitCommittedChangeListProvider.java   
public void loadCommittedChanges(ChangeBrowserSettings settings, RepositoryLocation location, int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
  try {
    getCommittedChangesImpl(settings, location, maxCount, new Consumer<GitCommittedChangeList>() {
      @Override
      public void consume(GitCommittedChangeList gitCommittedChangeList) {
        consumer.consume(gitCommittedChangeList);
      }
    });
  }
  finally {
    consumer.finished();
  }
}
项目:tools-idea    文件:LowLevelAccessImpl.java   
public void loadHashesWithParents(final @NotNull Collection<String> startingPoints,
                                  @NotNull final Collection<ChangesFilter.Filter> filters,
                                  final AsynchConsumer<CommitHashPlusParents> consumer,
                                  Getter<Boolean> isCanceled, int useMaxCnt, final boolean topoOrder) throws VcsException {
  final List<String> parameters = new ArrayList<String>();
  final Collection<VirtualFile> paths = new HashSet<VirtualFile>();
  ChangesFilter.filtersToParameters(filters, parameters, paths);

  if (! startingPoints.isEmpty()) {
    for (String startingPoint : startingPoints) {
      parameters.add(startingPoint);
    }
  } else {
    parameters.add("HEAD");
    parameters.add("--branches");
    parameters.add("--remotes");
    parameters.add("--tags");
  }
  if (useMaxCnt > 0) {
    parameters.add("--max-count=" + useMaxCnt);
  }
  if (topoOrder) {
    parameters.add("--topo-order");
  } else {
    parameters.add("--date-order");
  }

  GitHistoryUtils.hashesWithParents(myProject, new FilePathImpl(myRoot), consumer, isCanceled, paths, ArrayUtil.toStringArray(parameters));
}
项目:tools-idea    文件:LowLevelAccessImpl.java   
public void loadCommits(final @NotNull Collection<String> startingPoints, @NotNull final Collection<String> endPoints,
                        @NotNull final Collection<ChangesFilter.Filter> filters,
                        @NotNull final AsynchConsumer<GitHeavyCommit> consumer,
                        int useMaxCnt,
                        Getter<Boolean> isCanceled, SymbolicRefsI refs, final boolean topoOrder)
  throws VcsException {

  final List<String> parameters = new ArrayList<String>();
  if (useMaxCnt > 0) {
    parameters.add("--max-count=" + useMaxCnt);
  }

  final Collection<VirtualFile> paths = new HashSet<VirtualFile>();
  ChangesFilter.filtersToParameters(filters, parameters, paths);

  if (! startingPoints.isEmpty()) {
    for (String startingPoint : startingPoints) {
      parameters.add(startingPoint);
    }
  } else {
    parameters.add("HEAD");
    parameters.add("--branches");
    parameters.add("--remotes");
    parameters.add("--tags");
  }
  if (topoOrder) {
    parameters.add("--topo-order");
  } else {
    parameters.add("--date-order");
  }

  for (String endPoint : endPoints) {
    parameters.add("^" + endPoint);
  }

  GitHistoryUtils.historyWithLinks(myProject, new FilePathImpl(myRoot),
                                   refs, consumer, isCanceled, paths, true, ArrayUtil.toStringArray(parameters));
}
项目:tools-idea    文件:GitHistoryUtilsTest.java   
@Test(enabled = false)
public void testHashesWithParents() throws Exception {
  final int expectedSize = myRevisionsAfterRename.size();

  final List<CommitHashPlusParents> hashesWithParents = new ArrayList<CommitHashPlusParents>(3);
  AsynchConsumer<CommitHashPlusParents> consumer = new AsynchConsumer<CommitHashPlusParents>() {
    @Override
    public void consume(CommitHashPlusParents gitFileRevision) {
      hashesWithParents.add(gitFileRevision);
    }

    @Override
    public void finished() {
    }
  };

  GitHistoryUtils.hashesWithParents(myProject, bfilePath, consumer, null, null);

  assertEquals(hashesWithParents.size(), expectedSize);
  for (Iterator hit = hashesWithParents.iterator(), myIt = myRevisionsAfterRename.iterator(); hit.hasNext(); ) {
    CommitHashPlusParents chpp = (CommitHashPlusParents)hit.next();
    GitTestRevision rev = (GitTestRevision)myIt.next();
    assertEquals(chpp.getHash(), rev.myHash);
    final List<AbstractHash> parents = chpp.getParents();
    final ArrayList<String> list = new ArrayList<String>();
    for (AbstractHash parent : parents) {
      list.add(parent.getString());
    }
    assertEqualHashes(list, Arrays.asList(rev.myParents));
  }
}
项目:consulo    文件:AbstractVcsHelperImpl.java   
public void run(@Nonnull final ProgressIndicator indicator) {
  final AsynchConsumer<List<CommittedChangeList>> appender = myDlg.getAppender();
  final BufferedListConsumer<CommittedChangeList> bufferedListConsumer = new BufferedListConsumer<>(10, appender, -1);

  final Application application = ApplicationManager.getApplication();
  try {
    myProvider.loadCommittedChanges(mySettings, myLocation, 0, new AsynchConsumer<CommittedChangeList>() {
      public void consume(CommittedChangeList committedChangeList) {
        myRevisionsReturned = true;
        bufferedListConsumer.consumeOne(committedChangeList);
        if (myCanceled) {
          indicator.cancel();
        }
      }

      public void finished() {
        bufferedListConsumer.flush();
        appender.finished();

        if (! myRevisionsReturned) {
          application.invokeLater(new Runnable() {
            public void run() {
              myDlg.close(-1);
            }
          }, ModalityState.stateForComponent(myDlg.getWindow()));
        }
      }
    });
  }
  catch (VcsException e) {
    myExceptions.add(e);
    application.invokeLater(new Runnable() {
      public void run() {
        myDlg.close(-1);
      }
    }, ModalityState.stateForComponent(myDlg.getWindow()));
  }
}
项目:intellij-ce-playground    文件:CompositeCommittedChangesProvider.java   
public void loadCommittedChanges(CompositeChangeBrowserSettings settings,
                                 RepositoryLocation location,
                                 int maxCount,
                                 AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
  throw new UnsupportedOperationException();
}
项目:intellij-ce-playground    文件:ChangesBrowserDialog.java   
private void initDialog(final Project project, final CommittedChangesTableModel changes, final Mode mode) {
  myProject = project;
  myChanges = changes;
  myMode = mode;
  setTitle(VcsBundle.message("dialog.title.changes.browser"));
  setCancelButtonText(CommonBundle.getCloseButtonText());
  final ModalityState currentState = ModalityState.current();
  if ((mode != Mode.Choose) && (ModalityState.NON_MODAL.equals(currentState))) {
    setModal(false);
  }
  myAppender = new AsynchConsumer<List<CommittedChangeList>>() {

    public void finished() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            myCommittedChangesBrowser.stopLoading();
          }
        }
      });
    }

    public void consume(final List<CommittedChangeList> committedChangeLists) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            final boolean selectFirst = (myChanges.getRowCount() == 0) && (!committedChangeLists.isEmpty());
            myChanges.addRows(committedChangeLists);
            if (selectFirst) {
              myCommittedChangesBrowser.selectFirstIfAny();
            }
          }
        }
      });
    }
  };

  init();

  if (myInitRunnable != null) {
    new AdjustComponentWhenShown() {
      @Override
      protected boolean init() {
        myInitRunnable.consume(ChangesBrowserDialog.this);
        return true;
      }
    }.install(myCommittedChangesBrowser);
  }
}
项目:intellij-ce-playground    文件:ChangesBrowserDialog.java   
public AsynchConsumer<List<CommittedChangeList>> getAppender() {
  return myAppender;
}
项目:intellij-ce-playground    文件:CommittedChangesPanel.java   
private void refreshChangesFromLocation() {
  myBrowser.reset();

  myInLoad = true;
  myBrowser.setLoading(true);
  ProgressManager.getInstance().run(new Task.Backgroundable(myProject, "Loading changes", true, BackgroundFromStartOption.getInstance()) {

    public void run(@NotNull final ProgressIndicator indicator) {
      try {
        final AsynchConsumer<List<CommittedChangeList>> appender = new AsynchConsumer<List<CommittedChangeList>>() {
          public void finished() {
          }

          public void consume(final List<CommittedChangeList> list) {
            new AbstractCalledLater(myProject, ModalityState.stateForComponent(myBrowser)) {
              public void run() {
                myBrowser.append(list);
              }
            }.callMe();
          }
        };
        final BufferedListConsumer<CommittedChangeList> bufferedListConsumer = new BufferedListConsumer<CommittedChangeList>(30, appender,-1);

        myProvider.loadCommittedChanges(mySettings, myLocation, myMaxCount, new AsynchConsumer<CommittedChangeList>() {
          public void finished() {
            bufferedListConsumer.flush();
          }
          public void consume(CommittedChangeList committedChangeList) {
            if (myDisposed) {
              indicator.cancel();
            }
            ProgressManager.checkCanceled();
            bufferedListConsumer.consumeOne(committedChangeList);
          }
        });
      }
      catch (final VcsException e) {
        LOG.info(e);
        WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
          public void run() {
            Messages.showErrorDialog(myProject, "Error refreshing view: " + StringUtil.join(e.getMessages(), "\n"), "Committed Changes");
          }
        }, null, myProject);
      } finally {
        myInLoad = false;
        myBrowser.setLoading(false);
      }
    }
  });
}
项目:intellij-ce-playground    文件:CvsCommittedChangesProvider.java   
public void loadCommittedChanges(ChangeBrowserSettings settings,
                                 RepositoryLocation location,
                                 int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer)
  throws VcsException {
  try {
    final CvsRepositoryLocation cvsLocation = (CvsRepositoryLocation) location;
    final String module = cvsLocation.getModuleName();
    final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
    if (connectionSettings.isOffline()) {
      return;
    }
    final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, cvsLocation.getRootFile());
    final Date dateTo = settings.getDateBeforeFilter();
    Date dateFrom = settings.getDateAfterFilter();
    if (dateFrom == null) {
      final Calendar calendar = Calendar.getInstance();
      calendar.set(1970, Calendar.MARCH, 2);
      dateFrom = calendar.getTime();
    }
    final ChangeBrowserSettings.Filter filter = settings.createFilter();
    final Set<CvsChangeList> controlSet = new HashSet<CvsChangeList>();
    final LoadHistoryOperation operation =
      new LoadHistoryOperation(connectionSettings, module, dateFrom, dateTo, new Consumer<LogInformationWrapper>() {
        public void consume(LogInformationWrapper wrapper) {
          final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
          if (wrappers != null) {
            for (RevisionWrapper revisionWrapper : wrappers) {
              final CvsChangeList changeList = builder.addRevision(revisionWrapper);
              if (controlSet.contains(changeList)) continue;
              controlSet.add(changeList);
              if (filter.accepts(changeList)) {
                consumer.consume(changeList);
              }
            }
          }
        }
      });
    final CvsResult executionResult = operation.run(myProject);

    if (executionResult.isCanceled()) {
      throw new ProcessCanceledException();
    }
    else if (executionResult.hasErrors()) {
      throw executionResult.composeError();
    }
  }
  finally {
    consumer.finished();
  }
}
项目:vso-intellij    文件:TFSCommittedChangesProvider.java   
public void loadCommittedChanges(final ChangeBrowserSettings settings,
                                 final RepositoryLocation location,
                                 final int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
    // TODO: (Jetbrains) if revision and date filters are both set, which one should have priority?
    VersionSpec versionFrom = VersionSpec.create(1);
    if (settings.getChangeAfterFilter() != null) {
        versionFrom = VersionSpec.create((int) settings.getChangeAfterFilter().longValue());
    }
    if (settings.getDateAfterFilter() != null) {
        versionFrom = VersionSpec.create(settings.getDateAfterFilter());
    }

    VersionSpec versionTo = VersionSpec.LATEST;
    if (settings.getChangeBeforeFilter() != null) {
        versionTo = VersionSpec.create((int) settings.getChangeBeforeFilter().longValue());
    }
    if (settings.getDateBeforeFilter() != null) {
        versionTo = VersionSpec.create(settings.getDateBeforeFilter());
    }
    final VersionSpec.Range range = new VersionSpec.Range(versionFrom, versionTo);

    logger.info(String.format("Loading committed changes for range %s", range.toString()));
    final TFSRepositoryLocation tfsRepositoryLocation = (TFSRepositoryLocation) location;
    final ServerContext context = TFSVcs.getInstance(project).getServerContext(false);
    final List<ChangeSet> changeSets = CommandUtils.getHistoryCommand(context, tfsRepositoryLocation.getRoot().getPath(),
            range.toString(), maxCount, true, settings.getUserFilter() == null ? StringUtils.EMPTY : settings.getUserFilter());

    // no changesets were found with the parameters
    if (changeSets.isEmpty()) {
        logger.info(String.format("No changesets were found in history for the range %s and user %s"
                , range.toString(), settings.getUserFilter() == null ? StringUtils.EMPTY : settings.getUserFilter()));
        consumer.finished();
        return;
    }

    final TFSChangeListBuilder tfsChangeListBuilder = new TFSChangeListBuilder(vcs, tfsRepositoryLocation.getWorkspace());
    // list is in order of newest to oldest so we can assume the next checkin in the list is the actual previous checkin in time
    for (int i = 0; i < changeSets.size() - 1; i++) {
        consumer.consume(tfsChangeListBuilder.createChangeList(changeSets.get(i), changeSets.get(i + 1).getIdAsInt(), changeSets.get(i + 1).getDate()));
    }
    // this is the first checkin to the repo so there is no previous checkin to refer to
    consumer.consume(tfsChangeListBuilder.createChangeList(changeSets.get(changeSets.size() - 1), 0, StringUtils.EMPTY));
    consumer.finished();
}
项目:tools-idea    文件:CompositeCommittedChangesProvider.java   
public void loadCommittedChanges(CompositeChangeBrowserSettings settings,
                                 RepositoryLocation location,
                                 int maxCount,
                                 AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
  throw new UnsupportedOperationException();
}
项目:tools-idea    文件:ChangesBrowserDialog.java   
private void initDialog(final Project project, final CommittedChangesTableModel changes, final Mode mode) {
  myProject = project;
  myChanges = changes;
  myMode = mode;
  setTitle(VcsBundle.message("dialog.title.changes.browser"));
  setCancelButtonText(CommonBundle.getCloseButtonText());
  final ModalityState currentState = ModalityState.current();
  if ((mode != Mode.Choose) && (ModalityState.NON_MODAL.equals(currentState))) {
    setModal(false);
  }
  myAppender = new AsynchConsumer<List<CommittedChangeList>>() {

    public void finished() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            myCommittedChangesBrowser.stopLoading();
          }
        }
      });
    }

    public void consume(final List<CommittedChangeList> committedChangeLists) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            final boolean selectFirst = (myChanges.getRowCount() == 0) && (!committedChangeLists.isEmpty());
            myChanges.addRows(committedChangeLists);
            if (selectFirst) {
              myCommittedChangesBrowser.selectFirstIfAny();
            }
          }
        }
      });
    }
  };

  init();

  if (myInitRunnable != null) {
    new AdjustComponentWhenShown() {
      @Override
      protected boolean init() {
        myInitRunnable.consume(ChangesBrowserDialog.this);
        return true;
      }
    }.install(myCommittedChangesBrowser);
  }
}
项目:tools-idea    文件:ChangesBrowserDialog.java   
public AsynchConsumer<List<CommittedChangeList>> getAppender() {
  return myAppender;
}
项目:tools-idea    文件:CommittedChangesPanel.java   
private void refreshChangesFromLocation() {
  myBrowser.reset();

  myInLoad = true;
  myBrowser.setLoading(true);
  ProgressManager.getInstance().run(new Task.Backgroundable(myProject, "Loading changes", true, BackgroundFromStartOption.getInstance()) {

    public void run(@NotNull final ProgressIndicator indicator) {
      try {
        final AsynchConsumer<List<CommittedChangeList>> appender = new AsynchConsumer<List<CommittedChangeList>>() {
          public void finished() {
          }

          public void consume(final List<CommittedChangeList> list) {
            new AbstractCalledLater(myProject, ModalityState.stateForComponent(myBrowser)) {
              public void run() {
                myBrowser.append(list);
              }
            }.callMe();
          }
        };
        final BufferedListConsumer<CommittedChangeList> bufferedListConsumer = new BufferedListConsumer<CommittedChangeList>(30, appender,-1);

        myProvider.loadCommittedChanges(mySettings, myLocation, myMaxCount, new AsynchConsumer<CommittedChangeList>() {
          public void finished() {
            bufferedListConsumer.flush();
          }
          public void consume(CommittedChangeList committedChangeList) {
            if (myDisposed) {
              indicator.cancel();
            }
            ProgressManager.checkCanceled();
            bufferedListConsumer.consumeOne(committedChangeList);
          }
        });
      }
      catch (final VcsException e) {
        LOG.info(e);
        WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
          public void run() {
            Messages.showErrorDialog(myProject, "Error refreshing view: " + StringUtil.join(e.getMessages(), "\n"), "Committed Changes");
          }
        }, null, myProject);
      } finally {
        myInLoad = false;
        myBrowser.setLoading(false);
      }
    }
  });
}
项目:tools-idea    文件:GitHistoryUtils.java   
public static void hashesWithParents(Project project, FilePath path, final AsynchConsumer<CommitHashPlusParents> consumer,
                                     final Getter<Boolean> isCanceled,
                                     Collection<VirtualFile> paths, final String... parameters) throws VcsException {
  // adjust path using change manager
  path = getLastCommitName(project, path);
  final VirtualFile root = GitUtil.getGitRoot(path);
  final GitLineHandler h = new GitLineHandler(project, root, GitCommand.LOG);
  final GitLogParser parser = new GitLogParser(project, GitLogParser.NameStatus.NAME,  SHORT_HASH, COMMIT_TIME, SHORT_PARENTS, AUTHOR_NAME);
  h.setStdoutSuppressed(true);
  h.addParameters(parameters);
  h.addParameters(parser.getPretty(), "--encoding=UTF-8", "--full-history");

  if (paths != null && ! paths.isEmpty()) {
    h.endOptions();
    h.addRelativeFiles(paths);
  } else {
    h.addParameters("--sparse");
    h.endOptions();
    h.addRelativePaths(path);
  }

  final Semaphore semaphore = new Semaphore();
  h.addLineListener(new GitLineHandlerListener() {
    @Override
    public void onLineAvailable(final String line, final Key outputType) {
      try {
        if (ProcessOutputTypes.STDOUT.equals(outputType)) {
          if (isCanceled != null && isCanceled.get()) {
            h.cancel();
            return;
          }
          GitLogRecord record = parser.parseOneRecord(line);
          consumer.consume(new CommitHashPlusParents(record.getShortHash(),
                                                     record.getParentsShortHashes(), record.getLongTimeStamp() * 1000,
                                                     record.getAuthorName()));
        }
      } catch (ProcessCanceledException e) {
        h.cancel();
        semaphore.up();
      }
    }

    @Override
    public void processTerminated(int exitCode) {
      semaphore.up();
    }

    @Override
    public void startFailed(Throwable exception) {
      semaphore.up();
    }
  });
  semaphore.down();
  h.start();
  semaphore.waitFor();
  consumer.finished();
}
项目:tools-idea    文件:LowLevelAccess.java   
void loadCommits(final Collection<String> startingPoints,
final Collection<String> endPoints,
final Collection<ChangesFilter.Filter> filters,
final AsynchConsumer<GitHeavyCommit> consumer,
int useMaxCnt,
Getter<Boolean> isCanceled, SymbolicRefsI refs, final boolean topoOrder) throws VcsException;
项目:tools-idea    文件:LowLevelAccess.java   
void loadHashesWithParents(final @NotNull Collection<String> startingPoints, @NotNull final Collection<ChangesFilter.Filter> filters,
final AsynchConsumer<CommitHashPlusParents> consumer, Getter<Boolean> isCanceled, int useMaxCnt,
final boolean topoOrder) throws VcsException;
项目:tools-idea    文件:CvsCommittedChangesProvider.java   
public void loadCommittedChanges(ChangeBrowserSettings settings,
                                 RepositoryLocation location,
                                 int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer)
  throws VcsException {
  try {
    final CvsRepositoryLocation cvsLocation = (CvsRepositoryLocation) location;
    final String module = cvsLocation.getModuleName();
    final CvsEnvironment connectionSettings = cvsLocation.getEnvironment();
    if (connectionSettings.isOffline()) {
      return;
    }
    final CvsChangeListsBuilder builder = new CvsChangeListsBuilder(module, connectionSettings, myProject, cvsLocation.getRootFile());
    final Date dateTo = settings.getDateBeforeFilter();
    Date dateFrom = settings.getDateAfterFilter();
    if (dateFrom == null) {
      final Calendar calendar = Calendar.getInstance();
      calendar.set(1970, Calendar.MARCH, 2);
      dateFrom = calendar.getTime();
    }
    final ChangeBrowserSettings.Filter filter = settings.createFilter();
    final Set<CvsChangeList> controlSet = new HashSet<CvsChangeList>();
    final LoadHistoryOperation operation =
      new LoadHistoryOperation(connectionSettings, module, dateFrom, dateTo, new Consumer<LogInformationWrapper>() {
        public void consume(LogInformationWrapper wrapper) {
          final List<RevisionWrapper> wrappers = builder.revisionWrappersFromLog(wrapper);
          if (wrappers != null) {
            for (RevisionWrapper revisionWrapper : wrappers) {
              final CvsChangeList changeList = builder.addRevision(revisionWrapper);
              if (controlSet.contains(changeList)) continue;
              controlSet.add(changeList);
              if (filter.accepts(changeList)) {
                consumer.consume(changeList);
              }
            }
          }
        }
      });
    final CvsResult executionResult = operation.run(myProject);

    if (executionResult.isCanceled()) {
      throw new ProcessCanceledException();
    }
    else if (executionResult.hasErrors()) {
      throw executionResult.composeError();
    }
  }
  finally {
    consumer.finished();
  }
}
项目:tools-idea    文件:SvnCommittedChangesProvider.java   
public void loadCommittedChanges(ChangeBrowserSettings settings,
                                 RepositoryLocation location,
                                 int maxCount,
                                 final AsynchConsumer<CommittedChangeList> consumer)
  throws VcsException {
  try {
    final SvnRepositoryLocation svnLocation = (SvnRepositoryLocation) location;
    final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
    if (progress != null) {
      progress.setText(SvnBundle.message("progress.text.changes.collecting.changes"));
      progress.setText2(SvnBundle.message("progress.text2.changes.establishing.connection", location));
    }

    final String repositoryRoot;
    SVNRepository repository = null;
    try {
      repository = myVcs.createRepository(svnLocation.getURL());
      repositoryRoot = repository.getRepositoryRoot(true).toString();
    }
    catch (SVNException e) {
      throw new VcsException(e);
    } finally {
      if (repository != null) {
        repository.closeSession();
      }
    }

    final ChangeBrowserSettings.Filter filter = settings.createFilter();

    getCommittedChangesImpl(settings, svnLocation.getURL(), new String[]{""}, maxCount, new Consumer<SVNLogEntry>() {
      public void consume(final SVNLogEntry svnLogEntry) {
        final SvnChangeList cl = new SvnChangeList(myVcs, svnLocation, svnLogEntry, repositoryRoot);
        if (filter.accepts(cl)) {
          consumer.consume(cl);
        }
      }
    }, false, true);
  }
  finally {
    consumer.finished();
  }
}
项目:consulo    文件:CompositeCommittedChangesProvider.java   
public void loadCommittedChanges(CompositeChangeBrowserSettings settings,
                                 RepositoryLocation location,
                                 int maxCount,
                                 AsynchConsumer<CommittedChangeList> consumer) throws VcsException {
  throw new UnsupportedOperationException();
}
项目:consulo    文件:ChangesBrowserDialog.java   
private void initDialog(final Project project, final CommittedChangesTableModel changes, final Mode mode) {
  myProject = project;
  myChanges = changes;
  myMode = mode;
  setTitle(VcsBundle.message("dialog.title.changes.browser"));
  setCancelButtonText(CommonBundle.getCloseButtonText());
  final ModalityState currentState = ModalityState.current();
  if ((mode != Mode.Choose) && (ModalityState.NON_MODAL.equals(currentState))) {
    setModal(false);
  }
  myAppender = new AsynchConsumer<List<CommittedChangeList>>() {

    public void finished() {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            myCommittedChangesBrowser.stopLoading();
          }
        }
      });
    }

    public void consume(final List<CommittedChangeList> committedChangeLists) {
      SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
          if (ChangesBrowserDialog.this.isShowing()) {
            final boolean selectFirst = (myChanges.getRowCount() == 0) && (!committedChangeLists.isEmpty());
            myChanges.addRows(committedChangeLists);
            if (selectFirst) {
              myCommittedChangesBrowser.selectFirstIfAny();
            }
          }
        }
      });
    }
  };

  init();

  if (myInitRunnable != null) {
    new AdjustComponentWhenShown() {
      @Override
      protected boolean init() {
        myInitRunnable.consume(ChangesBrowserDialog.this);
        return true;
      }
    }.install(myCommittedChangesBrowser);
  }
}
项目:consulo    文件:ChangesBrowserDialog.java   
public AsynchConsumer<List<CommittedChangeList>> getAppender() {
  return myAppender;
}
项目:consulo    文件:CommittedChangesPanel.java   
private void refreshChangesFromLocation() {
  myBrowser.reset();

  myInLoad = true;
  myBrowser.setLoading(true);
  ProgressManager.getInstance().run(new Task.Backgroundable(myProject, "Loading changes", true, BackgroundFromStartOption.getInstance()) {

    @Override
    public void run(@Nonnull final ProgressIndicator indicator) {
      try {
        final AsynchConsumer<List<CommittedChangeList>> appender = new AsynchConsumer<List<CommittedChangeList>>() {
          @Override
          public void finished() {
          }

          @Override
          public void consume(final List<CommittedChangeList> list) {
            new AbstractCalledLater(myProject, ModalityState.stateForComponent(myBrowser)) {
              @Override
              public void run() {
                myBrowser.append(list);
              }
            }.callMe();
          }
        };
        final BufferedListConsumer<CommittedChangeList> bufferedListConsumer = new BufferedListConsumer<CommittedChangeList>(30, appender,-1);

        myProvider.loadCommittedChanges(mySettings, myLocation, myMaxCount, new AsynchConsumer<CommittedChangeList>() {
          @Override
          public void finished() {
            bufferedListConsumer.flush();
          }
          @Override
          public void consume(CommittedChangeList committedChangeList) {
            if (myDisposed) {
              indicator.cancel();
            }
            ProgressManager.checkCanceled();
            bufferedListConsumer.consumeOne(committedChangeList);
          }
        });
      }
      catch (final VcsException e) {
        LOG.info(e);
        WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {
          @Override
          public void run() {
            Messages.showErrorDialog(myProject, "Error refreshing view: " + StringUtil.join(e.getMessages(), "\n"), "Committed Changes");
          }
        }, null, myProject);
      } finally {
        myInLoad = false;
        myBrowser.setLoading(false);
      }
    }
  });
}
项目:intellij-ce-playground    文件:CommittedChangesProvider.java   
void loadCommittedChanges(U settings, RepositoryLocation location, final int maxCount, final AsynchConsumer<CommittedChangeList> consumer) throws VcsException;
项目:tools-idea    文件:CommittedChangesProvider.java   
void loadCommittedChanges(U settings, RepositoryLocation location, final int maxCount, final AsynchConsumer<CommittedChangeList> consumer) throws VcsException;
项目:consulo    文件:CommittedChangesProvider.java   
void loadCommittedChanges(U settings, RepositoryLocation location, final int maxCount, final AsynchConsumer<CommittedChangeList> consumer) throws VcsException;