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;
}
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();
}
}
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;
}
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;
}
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);
}
Aggregations