From 232c07245a99770631e5a078d07ed07c3209c07a Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Tue, 22 May 2018 13:12:09 +0200 Subject: [PATCH] =?UTF-8?q?ExternalSystemRunManagerListener=20=E2=80=94=20?= =?UTF-8?q?do=20not=20call=20RunManager.getInstance()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExternalSystemRunManagerListener.java | 9 ++++++--- .../intellij/execution/impl/RunManagerImpl.kt | 3 +++ .../execution/RunManagerListener.java | 19 ++++--------------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalSystemRunManagerListener.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalSystemRunManagerListener.java index ef980a2eab5b..1fc171eecfa9 100644 --- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalSystemRunManagerListener.java +++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ExternalSystemRunManagerListener.java @@ -102,6 +102,12 @@ class ExternalSystemRunManagerListener implements RunManagerListener { } public void attach() { + eventDisposable = Disposer.newDisposable(); + myManager.getProject().getMessageBus().connect(eventDisposable).subscribe(RunManagerListener.TOPIC, this); + } + + @Override + public void stateLoaded() { myMap.clear(); for (ExternalSystemManager systemManager : ExternalSystemApiUtil.getAllManagers()) { @@ -114,9 +120,6 @@ class ExternalSystemRunManagerListener implements RunManagerListener { add(myMap, configurationSettings); } } - - eventDisposable = Disposer.newDisposable(); - myManager.getProject().getMessageBus().connect(eventDisposable).subscribe(RunManagerListener.TOPIC, this); } public void detach() { diff --git a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt index a61283f8c9b4..beefdc671746 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt +++ b/platform/lang-impl/src/com/intellij/execution/impl/RunManagerImpl.kt @@ -507,6 +507,7 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi isFirstLoadState.set(false) loadSharedRunConfigurations() runConfigurationFirstLoaded() + eventPublisher.stateLoaded() } override fun loadState(parentNode: Element) { @@ -585,6 +586,8 @@ open class RunManagerImpl(internal val project: Project) : RunManagerEx(), Persi if (!isFirstLoadState && oldSelectedConfigurationId != null && oldSelectedConfigurationId != selectedConfigurationId) { eventPublisher.runConfigurationSelected() } + + eventPublisher.stateLoaded() } private fun loadSharedRunConfigurations() { diff --git a/platform/platform-impl/src/com/intellij/execution/RunManagerListener.java b/platform/platform-impl/src/com/intellij/execution/RunManagerListener.java index 83c365970c98..dc215b941b14 100644 --- a/platform/platform-impl/src/com/intellij/execution/RunManagerListener.java +++ b/platform/platform-impl/src/com/intellij/execution/RunManagerListener.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// 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.execution; import com.intellij.util.messages.Topic; @@ -48,4 +34,7 @@ public interface RunManagerListener extends EventListener { default void endUpdate() { } + + default void stateLoaded() { + } }