mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[vcs-log] create VcsLogManager in background, not in edt
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.vcs.log.impl;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
|
||||
@@ -80,14 +81,16 @@ public class VcsLogContentProvider implements ChangesViewContentProvider {
|
||||
|
||||
@CalledInAwt
|
||||
private void addLogUi(@NotNull VcsLogManager logManager) {
|
||||
VcsLogUiImpl ui = logManager.createLogUi(VcsLogTabsProperties.MAIN_LOG_ID, TAB_NAME);
|
||||
myProjectLog.setMainUi(ui);
|
||||
myContainer.add(new VcsLogPanel(logManager, ui), BorderLayout.CENTER);
|
||||
if (myProjectLog.getMainLogUi() == null) {
|
||||
VcsLogUiImpl ui = logManager.createLogUi(VcsLogTabsProperties.MAIN_LOG_ID, TAB_NAME);
|
||||
myProjectLog.setMainUi(ui);
|
||||
myContainer.add(new VcsLogPanel(logManager, ui), BorderLayout.CENTER);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent initContent() {
|
||||
myProjectLog.createLog();
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() -> myProjectLog.createLog());
|
||||
return myContainer;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.vcs.log.impl;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.vcs.changes.ui.ChangesViewContentManager;
|
||||
@@ -51,8 +52,10 @@ public class VcsLogTabsWatcher implements Disposable {
|
||||
myToolWindowManager = ToolWindowManagerEx.getInstanceEx(project);
|
||||
|
||||
myPostponedEventsListener = new MyRefreshPostponedEventsListener();
|
||||
myToolWindowManager.addToolWindowManagerListener(myPostponedEventsListener);
|
||||
installContentListener();
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
myToolWindowManager.addToolWindowManagerListener(myPostponedEventsListener);
|
||||
installContentListener();
|
||||
});
|
||||
|
||||
Disposer.register(parentDisposable, this);
|
||||
}
|
||||
|
||||
@@ -33,10 +33,7 @@ import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.util.messages.Topic;
|
||||
import com.intellij.vcs.log.data.VcsLogData;
|
||||
import com.intellij.vcs.log.ui.VcsLogUiImpl;
|
||||
import org.jetbrains.annotations.CalledInAny;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@@ -75,6 +72,7 @@ public class VcsProjectLog implements Disposable {
|
||||
return Arrays.asList(ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots());
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
void setMainUi(@NotNull VcsLogUiImpl ui) {
|
||||
myUi = ui;
|
||||
}
|
||||
@@ -97,9 +95,11 @@ public class VcsProjectLog implements Disposable {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
disposeLog();
|
||||
|
||||
if (hasDvcsRoots()) {
|
||||
createLog();
|
||||
}
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||
if (hasDvcsRoots()) {
|
||||
createLog();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -130,19 +130,21 @@ public class VcsProjectLog implements Disposable {
|
||||
myLogManager.drop();
|
||||
}
|
||||
|
||||
@CalledInAwt
|
||||
@CalledInBackground
|
||||
public void createLog() {
|
||||
VcsLogManager logManager = myLogManager.getValue();
|
||||
|
||||
if (logManager.isLogVisible()) {
|
||||
logManager.scheduleInitialization();
|
||||
}
|
||||
else if (PostponableLogRefresher.keepUpToDate()) {
|
||||
VcsLogCachesInvalidator invalidator = CachesInvalidator.EP_NAME.findExtension(VcsLogCachesInvalidator.class);
|
||||
if (invalidator.isValid()) {
|
||||
HeavyAwareExecutor.executeOutOfHeavyProcessLater(logManager::scheduleInitialization, 5000);
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
if (logManager.isLogVisible()) {
|
||||
logManager.scheduleInitialization();
|
||||
}
|
||||
}
|
||||
else if (PostponableLogRefresher.keepUpToDate()) {
|
||||
VcsLogCachesInvalidator invalidator = CachesInvalidator.EP_NAME.findExtension(VcsLogCachesInvalidator.class);
|
||||
if (invalidator.isValid()) {
|
||||
HeavyAwareExecutor.executeOutOfHeavyProcessLater(logManager::scheduleInitialization, 5000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean hasDvcsRoots() {
|
||||
@@ -162,17 +164,18 @@ public class VcsProjectLog implements Disposable {
|
||||
@Nullable private VcsLogManager myValue;
|
||||
|
||||
@NotNull
|
||||
@CalledInAwt
|
||||
@CalledInBackground
|
||||
public synchronized VcsLogManager getValue() {
|
||||
if (myValue == null) {
|
||||
myValue = compute();
|
||||
myMessageBus.syncPublisher(VCS_PROJECT_LOG_CHANGED).logCreated(myValue);
|
||||
VcsLogManager value = compute();
|
||||
myValue = value;
|
||||
ApplicationManager.getApplication().invokeLater(() -> myMessageBus.syncPublisher(VCS_PROJECT_LOG_CHANGED).logCreated(value));
|
||||
}
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@CalledInAwt
|
||||
@CalledInBackground
|
||||
protected synchronized VcsLogManager compute() {
|
||||
return new VcsLogManager(myProject, myUiProperties, getVcsRoots(), false, VcsProjectLog.this::recreateOnError);
|
||||
}
|
||||
@@ -202,7 +205,7 @@ public class VcsProjectLog implements Disposable {
|
||||
MessageBusConnection connection = project.getMessageBus().connect(project);
|
||||
connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, projectLog::recreateLog);
|
||||
if (projectLog.hasDvcsRoots()) {
|
||||
ApplicationManager.getApplication().invokeLater(projectLog::createLog);
|
||||
projectLog.createLog();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user