IDEA-145925 diff: do not open multiple "Go To Change" popups

This commit is contained in:
Aleksey Pivovarov
2015-10-05 16:19:55 +03:00
parent efc550635b
commit 1ff1cc37d5
@@ -19,10 +19,9 @@ import com.intellij.diff.chains.DiffRequestChain;
import com.intellij.diff.chains.DiffRequestProducer;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.popup.JBPopup;
import com.intellij.openapi.ui.popup.JBPopupFactory;
import com.intellij.openapi.ui.popup.PopupStep;
import com.intellij.openapi.ui.popup.*;
import com.intellij.openapi.ui.popup.util.BaseListPopupStep;
import com.intellij.openapi.util.Key;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
@@ -31,6 +30,8 @@ import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
public class GoToChangePopupBuilder {
private static final Key<JBPopup> POPUP_KEY = Key.create("Diff.RequestChainGoToPopup");
public interface Chain extends DiffRequestChain {
@NotNull
AnAction createGoToChangeAction(@NotNull Consumer<Integer> onSelected);
@@ -65,7 +66,22 @@ public class GoToChangePopupBuilder {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
JBPopup popup = createPopup(e);
JBPopup oldPopup = myChain.getUserData(POPUP_KEY);
if (oldPopup != null && oldPopup.isVisible()) {
oldPopup.cancel();
}
final JBPopup popup = createPopup(e);
myChain.putUserData(POPUP_KEY, popup);
popup.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
if (myChain.getUserData(POPUP_KEY) == popup) {
myChain.putUserData(POPUP_KEY, null);
}
}
});
InputEvent event = e.getInputEvent();
if (event instanceof MouseEvent) {