Use message bus instead of PropertyChangeSupport for active lookup change notifications

GitOrigin-RevId: 650343c69ac523dbe1b7d7ec716c1b84d7f1f7e4
This commit is contained in:
Dmitry Jemerov
2020-06-10 22:55:08 +03:00
committed by intellij-monorepo-bot
parent 8c949bf595
commit 6429469c1b
3 changed files with 30 additions and 2 deletions
@@ -61,8 +61,20 @@ public abstract class LookupManager {
@NonNls public static final String PROP_ACTIVE_LOOKUP = "activeLookup";
/**
* @deprecated Use {@link LookupManagerListener.TOPIC}
*/
@Deprecated
public abstract void addPropertyChangeListener(@NotNull PropertyChangeListener listener);
/**
* @deprecated Use {@link LookupManagerListener.TOPIC}
*/
@Deprecated
public abstract void addPropertyChangeListener(@NotNull PropertyChangeListener listener, @NotNull Disposable disposable);
/**
* @deprecated Use {@link LookupManagerListener.TOPIC}
*/
@Deprecated
public abstract void removePropertyChangeListener(@NotNull PropertyChangeListener listener);
@NotNull
@@ -0,0 +1,11 @@
// Copyright 2000-2020 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.codeInsight.lookup;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.Nullable;
public interface LookupManagerListener {
void activeLookupChanged(@Nullable Lookup oldLookup, @Nullable Lookup newLookup);
Topic<LookupManagerListener> TOPIC = Topic.create("lookup manager listener", LookupManagerListener.class);
}
@@ -155,7 +155,7 @@ public class LookupManagerImpl extends LookupManager {
public void dispose() {
myActiveLookup = null;
myActiveLookupEditor = null;
myPropertyChangeSupport.firePropertyChange(PROP_ACTIVE_LOOKUP, lookup, null);
fireActiveLookupChanged(lookup, null);
}
});
@@ -170,10 +170,15 @@ public class LookupManagerImpl extends LookupManager {
alarm.cancelAllRequests(); // no items -> no doc
}
myPropertyChangeSupport.firePropertyChange(PROP_ACTIVE_LOOKUP, null, myActiveLookup);
fireActiveLookupChanged(null, myActiveLookup);
return lookup;
}
void fireActiveLookupChanged(LookupImpl oldLookup, LookupImpl newLookup) {
myPropertyChangeSupport.firePropertyChange(PROP_ACTIVE_LOOKUP, oldLookup, newLookup);
myProject.getMessageBus().syncPublisher(LookupManagerListener.TOPIC).activeLookupChanged(oldLookup, newLookup);
}
private void showJavadoc(LookupImpl lookup) {
if (myActiveLookup != lookup) return;