mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-CR-46148: start actions delayed till ExternalProjectsManager initialized in edt
This commit is contained in:
+8
-6
@@ -170,7 +170,7 @@ public class ExternalProjectsManagerImpl implements ExternalProjectsManager, Per
|
||||
|
||||
synchronized (isInitializationFinished) {
|
||||
isInitializationFinished.set(true);
|
||||
ApplicationManager.getApplication().executeOnPooledThread(() -> {
|
||||
invokeLater(() -> {
|
||||
myPostInitializationActivities.run();
|
||||
myPostInitializationActivities.clear();
|
||||
});
|
||||
@@ -183,14 +183,11 @@ public class ExternalProjectsManagerImpl implements ExternalProjectsManager, Per
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runWhenInitialized(Runnable action) {
|
||||
public void runWhenInitialized(@NotNull Runnable runnable) {
|
||||
if (isDisposed.get()) return;
|
||||
synchronized (isInitializationFinished) {
|
||||
Runnable runnable = () -> {
|
||||
if (!isDisposed.get()) action.run();
|
||||
};
|
||||
if (isInitializationFinished.get()) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(runnable);
|
||||
invokeLater(runnable);
|
||||
}
|
||||
else {
|
||||
myPostInitializationActivities.add(runnable);
|
||||
@@ -198,6 +195,10 @@ public class ExternalProjectsManagerImpl implements ExternalProjectsManager, Per
|
||||
}
|
||||
}
|
||||
|
||||
private void invokeLater(@NotNull Runnable runnable) {
|
||||
ApplicationManager.getApplication().invokeLater(runnable, o -> myProject.isDisposed() || isDisposed.get());
|
||||
}
|
||||
|
||||
public void updateExternalProjectData(ExternalProjectInfo externalProject) {
|
||||
// update external projects data
|
||||
ExternalProjectsDataStorage.getInstance(myProject).update(externalProject);
|
||||
@@ -302,6 +303,7 @@ public class ExternalProjectsManagerImpl implements ExternalProjectsManager, Per
|
||||
@Override
|
||||
public void dispose() {
|
||||
if (isDisposed.getAndSet(true)) return;
|
||||
myPostInitializationActivities.clear();
|
||||
myProjectsViews.clear();
|
||||
myRunManagerListener.detach();
|
||||
if (myWatcher != null) {
|
||||
|
||||
+2
-5
@@ -1,11 +1,9 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.externalSystem.service.task.ui;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemBundle;
|
||||
import com.intellij.openapi.externalSystem.view.ExternalProjectsViewImpl;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -36,14 +34,13 @@ public abstract class AbstractExternalSystemToolWindowFactory implements ToolWin
|
||||
|
||||
contentManager.addContent(new ContentImpl(createInitializingLabel(), "", false));
|
||||
|
||||
ExternalProjectsManager.getInstance(project).runWhenInitialized(
|
||||
() -> ApplicationManager.getApplication().invokeLater(() -> {
|
||||
ExternalProjectsManager.getInstance(project).runWhenInitialized(() -> {
|
||||
final ExternalProjectsViewImpl projectsView = new ExternalProjectsViewImpl(project, (ToolWindowEx)toolWindow, myExternalSystemId);
|
||||
ExternalProjectsManagerImpl.getInstance(project).registerView(projectsView);
|
||||
ContentImpl tasksContent = new ContentImpl(projectsView, "", true);
|
||||
contentManager.removeAllContents(true);
|
||||
contentManager.addContent(tasksContent);
|
||||
}, project.getDisposed()));
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user