protected AbstractRefreshablePanel(final Project project, final String loadingTitle, final BackgroundTaskQueue queue) { myQueue = queue; myTicket = new Ticket(); myDetailsPanel = new DetailsPanel(); myDetailsPanel.loading(); myDetailsPanel.layout(); myDetailsLoader = new GenericDetailsLoader<Ticket, T>(new Consumer<Ticket>() { @Override public void consume(Ticket ticket) { final Loader loader = new Loader(project, loadingTitle, myTicket.copy()); loader.runSteadily(new Consumer<Task.Backgroundable>() { @Override public void consume(Task.Backgroundable backgroundable) { myQueue.run(backgroundable); } }); } }, new PairConsumer<Ticket, T>() { @Override public void consume(Ticket ticket, T t) { acceptData(t); } }); }
public ByRootLoader(Project project, LoaderAndRefresherImpl.MyRootHolder rootHolder, Mediator mediator, DetailsCache detailsCache, Ticket ticket, UsersIndex usersIndex, GitLogFilters gitLogFilters, final Collection<String> startingPoints) { super("Initial checks", Where.POOLED); myProject = project; myRootHolder = rootHolder; myUsersIndex = usersIndex; myStartingPoints = startingPoints; myLowLevelAccess = new LowLevelAccessImpl(myProject, myRootHolder.getRoot()); myMediator = mediator; myDetailsCache = detailsCache; myTicket = ticket; myGitLogFilters = gitLogFilters; }
@CalledInBackground @Override public void reportSymbolicRefs(final Ticket ticket, final VirtualFile root, final CachedRefs symbolicRefs) { Runnable runnable = new Runnable() { @Override public void run() { if (!myTicket.equals(ticket)) return; myDetailsLoader.reportRefs(root, symbolicRefs); myUIRefresh.reportSymbolicRefs(root, symbolicRefs); } }; if (ApplicationManager.getApplication().isDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } }
@CalledInAwt @Override public void refresh() { ApplicationManager.getApplication().assertIsDispatchThread(); if (! Comparing.equal(myDetailsLoader.getCurrentlySelected(), myTicket)) { final Ticket copy = myTicket.copy(); myDetailsLoader.updateSelection(copy, false); myDetailsPanel.loading(); myDetailsPanel.layout(); } else { refreshPresentation(); } }
public MediatorImpl(final Project project, GitCommitsSequentially gitCommitsSequentially) { myProject = project; myGitCommitsSequentially = gitCommitsSequentially; myTicket = new Ticket(); myController = new LoadGrowthController(); mySequenceBuffers = new HashMap<VirtualFile, SequenceSupportBuffer>(); myHaveRestrictingFilters = false; }
@CalledInBackground @Override public StepType appendResult(final Ticket ticket, final List<CommitI> result, final @Nullable List<List<AbstractHash>> parents, VirtualFile root, boolean checkForSequential) { if (! myTicket.equals(ticket)) { return StepType.STOP; } if (! result.isEmpty()) { /*if (mySequenceBuffers != null && checkForSequential) { try { mySequenceBuffers.get(root).appendResult(ticket, result, parents); } catch (VcsException e) { // todo myUIRefresh.acceptException(e); myTableWrapper.forceStop(); return StepType.STOP; } } else {*/ myTableWrapper.appendResult(ticket, result, parents); //} } if (myTableWrapper.isSuspend()) { return StepType.PAUSE; } return StepType.CONTINUE; }
@CalledInBackground public void appendResult(final Ticket ticket, final List<CommitI> result, final @Nullable List<List<AbstractHash>> parents) { final Runnable runnable = new Runnable() { @Override public void run() { if (! myTicket.equals(ticket)) return; // todo check for continuation right here myTableModel.appendData(result, parents); if (myController.isEmpty()) { myTableModel.restore(); mySuspend = false; } else if (! myForcedStop) { int nextCut = nextCut(); if ((nextCut + 1) < myTableModel.getTrueCount()) { if (nextCut > myRecentCut) { mySuspend = true; myRecentCut = nextCut; myTableModel.cutAt(myRecentCut); } } } myUIRefresh.linesReloaded(mySuspend); if (myController.isEmpty()) { myUIRefresh.finished(); } } }; if (ApplicationManager.getApplication().isDispatchThread()) { runnable.run(); } else { SwingUtilities.invokeLater(runnable); } }
@RequiredDispatchThread @Override public void refresh() { ApplicationManager.getApplication().assertIsDispatchThread(); if (! Comparing.equal(myDetailsLoader.getCurrentlySelected(), myTicket)) { final Ticket copy = myTicket.copy(); myDetailsLoader.updateSelection(copy, false); myDetailsPanel.loading(); myDetailsPanel.layout(); } else { refreshPresentation(); } }
private Loader(@Nullable Project project, @NotNull String title, final Ticket ticketCopy) { super(project, title, false, BackgroundFromStartOption.getInstance()); myTicketCopy = ticketCopy; }
@CalledInAwt @Override public void loadSkeleton(final Ticket ticket, final RootsHolder rootsHolder, final Collection<String> startingPoints, final GitLogFilters gitLogFilters, final LoadGrowthController loadGrowthController, final boolean topoOrder) { if (myPreviousAlgorithm != null) { myPreviousAlgorithm.stop(); } final List<LoaderAndRefresher<CommitHashPlusParents>> list = new ArrayList<LoaderAndRefresher<CommitHashPlusParents>>(); final List<ByRootLoader> shortLoaders = new ArrayList<ByRootLoader>(); final List<VirtualFile> roots = rootsHolder.getRoots(); int i = 0; for (VirtualFile root : roots) { final LoaderAndRefresherImpl.MyRootHolder rootHolder = roots.size() == 1 ? new LoaderAndRefresherImpl.OneRootHolder(root) : new LoaderAndRefresherImpl.ManyCaseHolder(i, rootsHolder); if (! gitLogFilters.isUseOnlyHashes()) { final boolean haveStructureFilter = gitLogFilters.haveStructureFilter(); // check if no files under root are selected if (haveStructureFilter && ! gitLogFilters.haveStructuresForRoot(root)) { ++ i; continue; } gitLogFilters.callConsumer(new Consumer<List<ChangesFilter.Filter>>() { @Override public void consume(final List<ChangesFilter.Filter> filters) { final LoaderAndRefresherImpl loaderAndRefresher = new LoaderAndRefresherImpl(ticket, filters, myMediator, startingPoints, myDetailsCache, myProject, rootHolder, myUsersIndex, loadGrowthController.getId(), haveStructureFilter, topoOrder, gitLogFilters.haveDisordering()); list.add(loaderAndRefresher); } }, true, root); } shortLoaders.add(new ByRootLoader(myProject, rootHolder, myMediator, myDetailsCache, ticket, myUsersIndex, gitLogFilters, startingPoints)); ++ i; } myUsersComponent.acceptUpdate(myUsersIndex.getKeys()); if (myPreviousAlgorithm != null) { final Continuation oldContinuation = myPreviousAlgorithm.getContinuation(); oldContinuation.cancelCurrent(); oldContinuation.clearQueue(); } final RepositoriesSorter sorter = new RepositoriesSorter(list, shortLoaders); // this will set previous algorithm for stop final Runnable runnable = new Runnable() { @Override public void run() { final Continuation continuation = Continuation.createForCurrentProgress(myProject, true, "Load git log data"); sorter.setContinuation(continuation); continuation.add(Arrays.<TaskDescriptor>asList(sorter)); continuation.resume(); } }; loadUnderProgress(runnable); }
/** * @return false -> ticket already changed */ StepType appendResult(final Ticket ticket, final List<CommitI> result, @Nullable final List<List<AbstractHash>> parents, VirtualFile root, boolean checkForSequential);
@Override public void acceptStashHead(Ticket ticket, VirtualFile root, Pair<AbstractHash, AbstractHash> hash) { if (! myTicket.equals(ticket)) return; myUIRefresh.reportStash(root, hash); }
public void appendResult(final Ticket ticket, final List<CommitI> result, final @Nullable List<List<AbstractHash>> parents) throws VcsException { assert result.size() == parents.size(); result.addAll(myCommits); parents.addAll(myParents); final SortListsByFirst sortListsByFirst = new SortListsByFirst(result, CommitIComparator.getInstance()); sortListsByFirst.sortAnyOther(parents); final long commitTime = myTail == null ? result.get(0).getTime() : myTail.getTime(); final Ref<Integer> cnt = new Ref<Integer>(myTail == null ? 0 : -1); myCommitsSequentially.iterateDescending(myRoot, commitTime, new Processor<Pair<AbstractHash, Long>>() { boolean startFound = false; @Override public boolean process(Pair<AbstractHash, Long> pair) { if (cnt.get() == -1) { if (! pair.getFirst().getString().startsWith(myTail.getHash().getString())) { System.out.println("!!!!!!!!! (1) pair: " + pair.getFirst().getString() + " commit (" + cnt.get() + "): " + myTail.getHash().getString()); return (! startFound) ? pair.getSecond() == commitTime : false; } else { cnt.set(0); startFound = true; return true; } } if (! pair.getFirst().getString().startsWith(result.get(cnt.get()).getHash().getString())) { System.out.println("(2) pair: " + pair.getFirst().getString() + " commit (" + cnt.get() + "): " + result.get(cnt.get()).getHash().getString()); return (! startFound) ? pair.getSecond() == commitTime : false; } cnt.set(cnt.get() + 1); startFound = true; return cnt.get() < result.size(); } }); myCommits = new ArrayList<CommitI>(result.subList(cnt.get(), result.size())); myParents = new ArrayList<List<AbstractHash>>(parents.subList(cnt.get(), parents.size())); if (cnt.get() > 0) { myTableWrapper.appendResult(ticket, result.subList(0, cnt.get()), parents.subList(0, cnt.get())); myTail = result.get(cnt.get() - 1); } }
void loadSkeleton(Ticket ticket, RootsHolder rootsHolder, final Collection<String> startingPoints, final GitLogFilters filters, LoadGrowthController loadGrowthController, final boolean topoOrder);
public LoaderAndRefresherImpl(final Ticket ticket, Collection<ChangesFilter.Filter> filters, Mediator mediator, Collection<String> startingPoints, DetailsCache detailsCache, Project project, MyRootHolder rootHolder, final UsersIndex usersIndex, final LoadGrowthController.ID id, boolean haveStructureFilter, boolean topoOrder, boolean haveDisordering) { myRootHolder = rootHolder; myUsersIndex = usersIndex; myId = id; myHaveStructureFilter = haveStructureFilter; myTopoOrder = topoOrder; myLoadParents = ! haveDisordering; myTicket = ticket; myFilters = filters; myMediator = mediator; myStartingPoints = startingPoints; myDetailsCache = detailsCache; myStepType = StepType.CONTINUE; myProject = project; myProgressAnalog = new Getter<Boolean>() { @Override public Boolean get() { return isInterrupted(); } }; myLowLevelAccess = new LowLevelAccessImpl(myProject, myRootHolder.getRoot()); myRealConsumer = new Consumer<List<CommitHashPlusParents>>() { @Override public void consume(final List<CommitHashPlusParents> list) { if (isInterrupted()) return; final List<CommitI> buffer = new ArrayList<CommitI>(); final List<List<AbstractHash>> parents = myLoadParents ? new ArrayList<List<AbstractHash>>() : null; for (CommitHashPlusParents commitHashPlusParents : list) { CommitI commit = new Commit(commitHashPlusParents.getHash(), commitHashPlusParents.getTime(), myUsersIndex.put(commitHashPlusParents.getAuthorName())); commit = myRootHolder.decorateByRoot(commit); buffer.add(commit); if (myLoadParents) { parents.add(commitHashPlusParents.getParents()); } } StepType stepType = myMediator.appendResult(myTicket, buffer, parents, myRootHolder.getRoot(), true); if (! StepType.FINISHED.equals(myStepType)) { myStepType = stepType; } } }; myBufferConsumer = new BufferedListConsumer<CommitHashPlusParents>(15, myRealConsumer, 400); myRepeatingLoadConsumer = new RepeatingLoadConsumer<CommitHashPlusParents>(myProject, myBufferConsumer.asConsumer()); }
private Loader(@Nullable Project project, @Nonnull String title, final Ticket ticketCopy) { super(project, title, false, BackgroundFromStartOption.getInstance()); myTicketCopy = ticketCopy; }
void reportSymbolicRefs(final Ticket ticket, VirtualFile root, final CachedRefs symbolicRefs);
void acceptStashHead(final Ticket ticket, VirtualFile root, Pair<AbstractHash, AbstractHash> hash);