Search in sources :

Example 31 with CommittedChangeList

use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.

the class ChangesCacheFile method loadAllData.

private List<Boolean> loadAllData(final List<CommittedChangeList> lists) throws IOException {
    List<Boolean> idx = new ArrayList<>();
    openStreams();
    try {
        loadHeader();
        final long length = myIndexStream.length();
        long totalCount = length / INDEX_ENTRY_SIZE;
        for (int i = 0; i < totalCount; i++) {
            final long indexOffset = length - (i + 1) * INDEX_ENTRY_SIZE;
            myIndexStream.seek(indexOffset);
            IndexEntry e = new IndexEntry();
            readIndexEntry(e);
            final CommittedChangeList list = loadChangeListAt(e.offset);
            lists.add(list);
            idx.add(e.completelyDownloaded);
        }
    } finally {
        closeStreams();
    }
    return idx;
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)

Example 32 with CommittedChangeList

use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.

the class ChangesCacheFile method readChanges.

public List<CommittedChangeList> readChanges(final ChangeBrowserSettings settings, final int maxCount) throws IOException {
    final List<CommittedChangeList> result = new ArrayList<>();
    final ChangeBrowserSettings.Filter filter = settings.createFilter();
    openStreams();
    try {
        if (maxCount == 0) {
            // skip header
            myStream.seek(HEADER_SIZE);
            while (myStream.getFilePointer() < myStream.length()) {
                CommittedChangeList changeList = myChangesProvider.readChangeList(myLocation, myStream);
                if (filter.accepts(changeList)) {
                    result.add(changeList);
                }
            }
        } else if (!settings.isAnyFilterSpecified()) {
            IndexEntry[] entries = readLastIndexEntries(0, maxCount);
            for (IndexEntry entry : entries) {
                myStream.seek(entry.offset);
                result.add(myChangesProvider.readChangeList(myLocation, myStream));
            }
        } else {
            int offset = 0;
            while (result.size() < maxCount) {
                IndexEntry[] entries = readLastIndexEntries(offset, 1);
                if (entries.length == 0) {
                    break;
                }
                CommittedChangeList changeList = loadChangeListAt(entries[0].offset);
                if (filter.accepts(changeList)) {
                    result.add(0, changeList);
                }
                offset++;
            }
        }
        return result;
    } finally {
        closeStreams();
    }
}
Also used : ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)

Example 33 with CommittedChangeList

use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.

the class IncomingChangesViewProvider method initContent.

public JComponent initContent() {
    myBrowser = new CommittedChangesTreeBrowser(myProject, Collections.<CommittedChangeList>emptyList());
    myBrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.not.loaded.message"));
    ActionGroup group = (ActionGroup) ActionManager.getInstance().getAction("IncomingChangesToolbar");
    final ActionToolbar toolbar = myBrowser.createGroupFilterToolbar(myProject, group, null, Collections.<AnAction>emptyList());
    myBrowser.setToolBar(toolbar.getComponent());
    myBrowser.setTableContextMenu(group, Collections.<AnAction>emptyList());
    myConnection = myBus.connect();
    myConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new MyCommittedChangesListener());
    loadChangesToBrowser(false, true);
    return myBrowser;
}
Also used : ActionGroup(com.intellij.openapi.actionSystem.ActionGroup) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) ActionToolbar(com.intellij.openapi.actionSystem.ActionToolbar)

Example 34 with CommittedChangeList

use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.

the class CommittedChangesCache method writeChangesInReadAction.

private static List<CommittedChangeList> writeChangesInReadAction(final ChangesCacheFile cacheFile, final List<CommittedChangeList> newChanges) throws IOException {
    // ensure that changes are loaded before taking read action, to avoid stalling UI
    for (CommittedChangeList changeList : newChanges) {
        changeList.getChanges();
    }
    final Ref<IOException> ref = new Ref<>();
    final List<CommittedChangeList> savedChanges = ApplicationManager.getApplication().runReadAction(new Computable<List<CommittedChangeList>>() {

        @Override
        public List<CommittedChangeList> compute() {
            try {
                // skip duplicates;
                return cacheFile.writeChanges(newChanges);
            } catch (IOException e) {
                ref.set(e);
                return null;
            }
        }
    });
    if (!ref.isNull()) {
        throw ref.get();
    }
    return savedChanges;
}
Also used : Ref(com.intellij.openapi.util.Ref) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) IOException(java.io.IOException)

Example 35 with CommittedChangeList

use of com.intellij.openapi.vcs.versionBrowser.CommittedChangeList in project intellij-community by JetBrains.

the class CommittedChangesCache method notifyIncomingChangesUpdated.

private void notifyIncomingChangesUpdated(@Nullable final Collection<CommittedChangeList> receivedChanges) {
    final Collection<CommittedChangeList> changes = receivedChanges == null ? myCachedIncomingChangeLists : receivedChanges;
    if (changes == null) {
        final Application application = ApplicationManager.getApplication();
        final Runnable runnable = new Runnable() {

            @Override
            public void run() {
                final List<CommittedChangeList> lists = loadIncomingChanges(true);
                fireIncomingChangesUpdated(lists);
            }
        };
        if (application.isDispatchThread()) {
            myTaskQueue.run(runnable);
        } else {
            runnable.run();
        }
        return;
    }
    final ArrayList<CommittedChangeList> listCopy = new ArrayList<>(changes);
    fireIncomingChangesUpdated(listCopy);
}
Also used : CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) Application(com.intellij.openapi.application.Application)

Aggregations

CommittedChangeList (com.intellij.openapi.vcs.versionBrowser.CommittedChangeList)45 ChangeBrowserSettings (com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings)8 Nullable (org.jetbrains.annotations.Nullable)8 Change (com.intellij.openapi.vcs.changes.Change)7 ChangesBunch (com.intellij.openapi.vcs.changes.committed.ChangesBunch)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)5 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)4 NotNull (org.jetbrains.annotations.NotNull)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Project (com.intellij.openapi.project.Project)3 Pair (com.intellij.openapi.util.Pair)3 List (java.util.List)3 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)3 Application (com.intellij.openapi.application.Application)2 Task (com.intellij.openapi.progress.Task)2 Ref (com.intellij.openapi.util.Ref)2 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)2 VcsRevisionNumber (com.intellij.openapi.vcs.history.VcsRevisionNumber)2 ChangesBrowserSettingsEditor (com.intellij.openapi.vcs.versionBrowser.ChangesBrowserSettingsEditor)2 IOException (java.io.IOException)2