com.intellij.util.AsynchConsumer Java Examples
The following examples show how to use
com.intellij.util.AsynchConsumer.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TFSCommittedChangesProvider.java From azure-devops-intellij with MIT License | 5 votes |
@Override 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; }
Example #2
Source File: P4CommittedChangesProvider.java From p4ic4idea with Apache License 2.0 | 5 votes |
@Override public void loadCommittedChanges(P4ChangeBrowserSettings settings, RepositoryLocation location, int maxCount, AsynchConsumer consumer) throws VcsException { if (LOG.isDebugEnabled()) { LOG.debug("Loading committed changes for location " + location); } if (consumer == null) { LOG.debug("Attempted to load committed changes with null consumer"); return; } asyncLoadCommittedChanges(settings, location, maxCount) .whenCompleted((c) -> c.forEach(consumer::consume)) .whenAnyState(consumer::finished) .whenServerError((e) -> LOG.warn("Problem loading committed changes", e)); }
Example #3
Source File: TFSCommittedChangesProvider.java From azure-devops-intellij with MIT License | 4 votes |
@SuppressWarnings("unchecked") // TODO: We have to use the raw type for the AsynchConsumer here, because the // signature in question was changed in IDEA 2019.2. We may use the proper type here // only after migration to 2019.2+. @Override public void loadCommittedChanges(final ChangeBrowserSettings settings, final RepositoryLocation location, final int maxCount, final AsynchConsumer 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); final TFSRepositoryLocation tfsRepositoryLocation = (TFSRepositoryLocation) location; logger.info("Loading committed changes for file {}, range {}", tfsRepositoryLocation.getRoot(), range); 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(); }
Example #4
Source File: AbstractVcsHelperImpl.java From consulo with Apache License 2.0 | 4 votes |
@Override 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>() { @Override public void consume(CommittedChangeList committedChangeList) { myRevisionsReturned = true; bufferedListConsumer.consumeOne(committedChangeList); if (myCanceled) { indicator.cancel(); } } @Override public void finished() { bufferedListConsumer.flush(); appender.finished(); if (! myRevisionsReturned) { application.invokeLater(new Runnable() { @Override public void run() { myDlg.close(-1); } }, ModalityState.stateForComponent(myDlg.getWindow())); } } }); } catch (VcsException e) { myExceptions.add(e); application.invokeLater(new Runnable() { @Override public void run() { myDlg.close(-1); } }, ModalityState.stateForComponent(myDlg.getWindow())); } }
Example #5
Source File: CompositeCommittedChangesProvider.java From consulo with Apache License 2.0 | 4 votes |
public void loadCommittedChanges(CompositeChangeBrowserSettings settings, RepositoryLocation location, int maxCount, AsynchConsumer<CommittedChangeList> consumer) throws VcsException { throw new UnsupportedOperationException(); }
Example #6
Source File: ChangesBrowserDialog.java From consulo with Apache License 2.0 | 4 votes |
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); } }
Example #7
Source File: ChangesBrowserDialog.java From consulo with Apache License 2.0 | 4 votes |
public AsynchConsumer<List<CommittedChangeList>> getAppender() { return myAppender; }
Example #8
Source File: CommittedChangesPanel.java From consulo with Apache License 2.0 | 4 votes |
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); } } }); }
Example #9
Source File: CommittedChangesProvider.java From consulo with Apache License 2.0 | votes |
void loadCommittedChanges(U settings, RepositoryLocation location, final int maxCount, final AsynchConsumer<CommittedChangeList> consumer) throws VcsException;