diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java index dd47b401b2e8..29baac3308e4 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapPanel.java @@ -71,7 +71,8 @@ import static com.intellij.openapi.actionSystem.impl.ActionToolbarImpl.updateAll public class KeymapPanel extends JPanel implements SearchableConfigurable, Configurable.NoScroll, KeymapListener, Disposable { private JCheckBox preferKeyPositionOverCharOption; - private final KeymapSchemeManager myManager = new KeymapSelector(this::currentKeymapChanged, this).getManager(); + private final KeymapSelector myKeymapSelector = new KeymapSelector(this::currentKeymapChanged); + private final KeymapSchemeManager myManager = myKeymapSelector.getManager(); private final ActionsTree myActionsTree = new ActionsTree(); private FilterComponent myFilterComponent; private TreeExpansionMonitor myTreeExpansionMonitor; @@ -610,6 +611,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi @Override public JComponent createComponent() { + myKeymapSelector.attachKeymapListener(this); ApplicationManager.getApplication().getMessageBus().connect(this).subscribe(CHANGE_TOPIC, this); return this; } @@ -838,8 +840,7 @@ public class KeymapPanel extends JPanel implements SearchableConfigurable, Confi } else { if (manager == null) { - manager = new KeymapSelector(selectedKeymap -> { - }, null).getManager(); + manager = new KeymapSelector(selectedKeymap -> { }).getManager(); manager.reset(); } mutable = manager.getMutableKeymap(selected); diff --git a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapSelector.java b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapSelector.java index 17254df510c9..2347971a13c1 100644 --- a/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapSelector.java +++ b/platform/platform-impl/src/com/intellij/openapi/keymap/impl/ui/KeymapSelector.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-2019 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.keymap.impl.ui; import com.intellij.application.options.schemes.AbstractSchemeActions; @@ -46,30 +32,30 @@ final class KeymapSelector extends SimpleSchemesPanel { private boolean messageShown; private boolean internal; - KeymapSelector(Consumer consumer, @Nullable Disposable parentDisposable) { + KeymapSelector(Consumer consumer) { super(0); this.consumer = consumer; + } - if (parentDisposable != null) { - ApplicationManager.getApplication().getMessageBus().connect(parentDisposable).subscribe(KeymapManagerListener.TOPIC, new KeymapManagerListener() { - @Override - public void keymapAdded(@NotNull Keymap keymap) { - manager.handleKeymapAdded(keymap); - resetSchemes(manager.getSchemes()); - } + void attachKeymapListener(@NotNull Disposable parentDisposable) { + ApplicationManager.getApplication().getMessageBus().connect(parentDisposable).subscribe(KeymapManagerListener.TOPIC, new KeymapManagerListener() { + @Override + public void keymapAdded(@NotNull Keymap keymap) { + manager.handleKeymapAdded(keymap); + resetSchemes(manager.getSchemes()); + } - @Override - public void keymapRemoved(@NotNull Keymap keymap) { - manager.handleKeymapRemoved(keymap); - resetSchemes(manager.getSchemes()); - } + @Override + public void keymapRemoved(@NotNull Keymap keymap) { + manager.handleKeymapRemoved(keymap); + resetSchemes(manager.getSchemes()); + } - @Override - public void activeKeymapChanged(@Nullable Keymap keymap) { - manager.handleActiveKeymapChanged(keymap); - } - }); - } + @Override + public void activeKeymapChanged(@Nullable Keymap keymap) { + manager.handleActiveKeymapChanged(keymap); + } + }); } @NotNull