ExternalSystemRunManagerListener — do not call RunManager.getInstance()

This commit is contained in:
Vladimir Krivosheev
2018-05-22 13:50:01 +02:00
parent 8c7eef5a04
commit 232c07245a
3 changed files with 13 additions and 18 deletions
@@ -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() {
@@ -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() {
@@ -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() {
}
}