mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
Refactoring: remove popup menu state tracker and rely on automatic toggling button detection
IJ-CR-105123 GitOrigin-RevId: d3f5fa6c5c6dede62639f2b89e8acd52b8b84961
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d6d26a8fbc
commit
03cb68db5d
@@ -29,7 +29,6 @@ import com.intellij.openapi.keymap.KeymapUtil
|
||||
import com.intellij.openapi.project.DumbAwareAction
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.SimpleToolWindowPanel
|
||||
import com.intellij.openapi.ui.popup.JBPopup
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.ui.popup.PopupChooserBuilder
|
||||
import com.intellij.openapi.util.NlsActions
|
||||
@@ -41,7 +40,6 @@ import com.intellij.ui.EditorTextField
|
||||
import com.intellij.ui.JBColor
|
||||
import com.intellij.ui.components.*
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel
|
||||
import com.intellij.ui.popup.PopupState
|
||||
import com.intellij.util.ui.JBInsets
|
||||
import com.intellij.util.ui.JBUI
|
||||
import com.intellij.util.ui.UIUtil
|
||||
@@ -369,13 +367,9 @@ internal abstract class JsonPathEvaluateView(protected val project: Project) : S
|
||||
|
||||
private inner class ShowHistoryAction : DumbAwareAction(FindBundle.message("find.search.history"), null,
|
||||
AllIcons.Actions.SearchWithHistory) {
|
||||
private val popupState: PopupState<JBPopup?> = PopupState.forPopup()
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
if (popupState.isRecentlyHidden) return
|
||||
|
||||
val historyList = JBList(getExpressionHistory())
|
||||
showCompletionPopup(searchWrapper, historyList, searchTextField, popupState)
|
||||
showCompletionPopup(searchWrapper, historyList, searchTextField)
|
||||
}
|
||||
|
||||
init {
|
||||
@@ -384,8 +378,7 @@ internal abstract class JsonPathEvaluateView(protected val project: Project) : S
|
||||
|
||||
private fun showCompletionPopup(toolbarComponent: JComponent?,
|
||||
list: JList<String>,
|
||||
textField: EditorTextField,
|
||||
popupState: PopupState<JBPopup?>) {
|
||||
textField: EditorTextField) {
|
||||
val builder: PopupChooserBuilder<*> = JBPopupFactory.getInstance().createListPopupBuilder(list)
|
||||
val popup = builder
|
||||
.setMovable(false)
|
||||
@@ -400,7 +393,6 @@ internal abstract class JsonPathEvaluateView(protected val project: Project) : S
|
||||
})
|
||||
.createPopup()
|
||||
|
||||
popupState.prepareToShow(popup)
|
||||
if (toolbarComponent != null) {
|
||||
popup.showUnderneathOf(toolbarComponent)
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import com.intellij.openapi.keymap.KeymapUtil;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.LightEditActionFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -28,7 +27,6 @@ import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.components.JBPanel;
|
||||
import com.intellij.ui.components.JBScrollPane;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
@@ -326,8 +324,6 @@ public class SearchTextArea extends JBPanel<SearchTextArea> implements PropertyC
|
||||
public void setInfoText(@SuppressWarnings("unused") String info) {}
|
||||
|
||||
private class ShowHistoryAction extends DumbAwareAction implements LightEditCompatible {
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
|
||||
ShowHistoryAction() {
|
||||
super(FindBundle.message(mySearchMode ? "find.search.history" : "find.replace.history"),
|
||||
FindBundle.message(mySearchMode ? "find.search.history" : "find.replace.history"),
|
||||
@@ -338,7 +334,7 @@ public class SearchTextArea extends JBPanel<SearchTextArea> implements PropertyC
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (myPopupState.isRecentlyHidden() || project == null) return; // do not show new popup
|
||||
if (project == null) return;
|
||||
FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(project);
|
||||
String[] recent = mySearchMode ? findInProjectSettings.getRecentFindStrings()
|
||||
: findInProjectSettings.getRecentReplaceStrings();
|
||||
@@ -346,7 +342,7 @@ public class SearchTextArea extends JBPanel<SearchTextArea> implements PropertyC
|
||||
Dimension size = historyList.getPreferredSize();
|
||||
size.width = Math.min(size.width, getWidth() + 200);
|
||||
historyList.setPreferredSize(size);
|
||||
Utils.showCompletionPopup(SearchTextArea.this, historyList, null, myTextArea, null, myPopupState);
|
||||
Utils.showCompletionPopup(SearchTextArea.this, historyList, null, myTextArea, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,11 +12,9 @@ import com.intellij.openapi.ui.popup.PopupChooserBuilder;
|
||||
import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
@@ -31,8 +29,7 @@ public final class Utils {
|
||||
JList<String> list,
|
||||
@NlsContexts.PopupTitle String title,
|
||||
JTextComponent textField,
|
||||
@NlsContexts.PopupAdvertisement String ad,
|
||||
@Nullable PopupState<JBPopup> popupState) {
|
||||
@NlsContexts.PopupAdvertisement String ad) {
|
||||
|
||||
final Runnable callback = () -> {
|
||||
String selectedValue = list.getSelectedValue();
|
||||
@@ -57,7 +54,6 @@ public final class Utils {
|
||||
popup.setAdText(ad, SwingConstants.LEFT);
|
||||
}
|
||||
|
||||
if (popupState != null) popupState.prepareToShow(popup);
|
||||
JComponent parent = toolbarComponent != null ? toolbarComponent : textField;
|
||||
AlignedPopup.showUnderneathWithoutAlignment(popup, parent);
|
||||
}
|
||||
|
||||
@@ -6,13 +6,11 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.codeStyle.NameUtil;
|
||||
import com.intellij.psi.impl.cache.impl.id.IdTableBuilding;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.components.JBList;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.util.ArrayUtilRt;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.text.Matcher;
|
||||
@@ -29,7 +27,6 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class VariantsCompletionAction extends DumbAwareAction implements LightEditCompatible {
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
private final JTextComponent myTextField;
|
||||
|
||||
public VariantsCompletionAction(JTextComponent textField) {
|
||||
@@ -42,7 +39,6 @@ public class VariantsCompletionAction extends DumbAwareAction implements LightEd
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull final AnActionEvent e) {
|
||||
if (myPopupState.isRecentlyHidden()) return; // do not show new popup
|
||||
final Editor editor = e.getData(CommonDataKeys.EDITOR_EVEN_IF_INACTIVE);
|
||||
if (editor == null) return;
|
||||
final String prefix = myTextField.getText().substring(0, myTextField.getCaretPosition());
|
||||
@@ -65,7 +61,7 @@ public class VariantsCompletionAction extends DumbAwareAction implements LightEd
|
||||
|
||||
Utils.showCompletionPopup(
|
||||
e.getInputEvent() instanceof MouseEvent ? myTextField: null,
|
||||
list, null, myTextField, null, myPopupState);
|
||||
list, null, myTextField, null);
|
||||
}
|
||||
|
||||
private static String[] calcWords(final String prefix, Editor editor) {
|
||||
|
||||
@@ -63,7 +63,6 @@ import com.intellij.ui.components.*;
|
||||
import com.intellij.ui.dsl.gridLayout.builders.RowBuilder;
|
||||
import com.intellij.ui.hover.TableHoverListener;
|
||||
import com.intellij.ui.mac.touchbar.Touchbar;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.popup.list.SelectablePanel;
|
||||
import com.intellij.ui.render.RendererPanelsUtilsKt;
|
||||
import com.intellij.ui.render.RenderingUtil;
|
||||
@@ -1869,7 +1868,6 @@ public class FindPopupPanel extends JBPanel<FindPopupPanel> implements FindUI, D
|
||||
}
|
||||
|
||||
private class MyShowFilterPopupAction extends DumbAwareAction {
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
private final DefaultActionGroup mySwitchContextGroup;
|
||||
|
||||
MyShowFilterPopupAction() {
|
||||
@@ -1891,11 +1889,9 @@ public class FindPopupPanel extends JBPanel<FindPopupPanel> implements FindUI, D
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
if (e.getData(PlatformCoreDataKeys.CONTEXT_COMPONENT) == null) return;
|
||||
if (myPopupState.isRecentlyHidden()) return;
|
||||
|
||||
ListPopup listPopup =
|
||||
JBPopupFactory.getInstance().createActionGroupPopup(null, mySwitchContextGroup, e.getDataContext(), false, null, 10);
|
||||
myPopupState.prepareToShow(listPopup);
|
||||
listPopup.showUnderneathOf(myFilterContextButton);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.intellij.openapi.ui.popup.IPopupChooserBuilder;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -25,7 +24,6 @@ import java.util.function.Function;
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
@Deprecated(forRemoval = true)
|
||||
public class DropDownLink<T> extends LinkLabel<Object> {
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
private T chosenItem;
|
||||
|
||||
public DropDownLink(@NotNull T value, @NotNull Runnable clickAction) {
|
||||
@@ -39,10 +37,8 @@ public class DropDownLink<T> extends LinkLabel<Object> {
|
||||
chosenItem = value;
|
||||
|
||||
setListener((linkLabel, d) -> {
|
||||
if (myPopupState.isRecentlyHidden()) return; // do not show new popup
|
||||
JBPopup popup = popupBuilder.apply((DropDownLink)linkLabel);
|
||||
Point showPoint = new Point(0, getHeight() + JBUIScale.scale(4));
|
||||
myPopupState.prepareToShow(popup);
|
||||
popup.show(new RelativePoint(this, showPoint));
|
||||
}, null);
|
||||
|
||||
@@ -77,10 +73,6 @@ public class DropDownLink<T> extends LinkLabel<Object> {
|
||||
return chosenItem;
|
||||
}
|
||||
|
||||
public PopupState getPopupState() {
|
||||
return myPopupState;
|
||||
}
|
||||
|
||||
private static final class LinkCellRenderer<T> extends JLabel implements ListCellRenderer<T> {
|
||||
private final JComponent owner;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.intellij.openapi.ui.popup.Balloon;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupListener;
|
||||
import com.intellij.openapi.ui.popup.LightweightWindowEvent;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -26,7 +27,13 @@ public abstract class PopupState<Popup> {
|
||||
private boolean hiddenLongEnough = true;
|
||||
private long timeHiddenAt;
|
||||
|
||||
|
||||
/**
|
||||
* Do not use it for simple cases: {@link com.intellij.ui.popup.AbstractPopup} will automatically store the pressed button
|
||||
* from the last input event and so in most cases the "closing" click on that button will not invoke the popup.
|
||||
* <p>
|
||||
* In case of asynchronous popup creation, it may be possible to store the pressed button to the popup manually via
|
||||
* {@link PopupUtil#setPopupToggleComponent} API.
|
||||
*/
|
||||
public static @NotNull PopupState<JBPopup> forPopup() {
|
||||
return new JBPopupState();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.BadgeIconSupplier;
|
||||
import com.intellij.ui.ExperimentalUI;
|
||||
import com.intellij.ui.IconManager;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.popup.list.ListPopupImpl;
|
||||
import com.intellij.ui.popup.list.PopupListElementRenderer;
|
||||
import com.intellij.util.Consumer;
|
||||
@@ -50,7 +49,6 @@ public final class SettingsEntryPointAction extends DumbAwareAction implements R
|
||||
IconManager.getInstance().withIconBadge(AllIcons.General.GearPlain, JBUI.CurrentTheme.IconBadge.NEW_UI);
|
||||
private static final BadgeIconSupplier IDE_UPDATE_ICON = new BadgeIconSupplier(AllIcons.Ide.Notification.IdeUpdate);
|
||||
private static final BadgeIconSupplier PLUGIN_UPDATE_ICON = new BadgeIconSupplier(AllIcons.Ide.Notification.PluginUpdate);
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
|
||||
public SettingsEntryPointAction() {
|
||||
super(IdeBundle.messagePointer("settings.entry.point.tooltip"));
|
||||
@@ -60,11 +58,8 @@ public final class SettingsEntryPointAction extends DumbAwareAction implements R
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
resetActionIcon();
|
||||
|
||||
if (myPopupState.isHidden() && !myPopupState.isRecentlyHidden()) {
|
||||
ListPopup popup = createMainPopup(e.getDataContext(), e.getInputEvent().getComponent());
|
||||
myPopupState.prepareToShow(popup);
|
||||
PopupUtil.showForActionButtonEvent(popup, e);
|
||||
}
|
||||
ListPopup popup = createMainPopup(e.getDataContext(), e.getInputEvent().getComponent());
|
||||
PopupUtil.showForActionButtonEvent(popup, e);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -322,7 +317,6 @@ public final class SettingsEntryPointAction extends DumbAwareAction implements R
|
||||
}
|
||||
|
||||
private static final class MyStatusBarWidget implements StatusBarWidget, StatusBarWidget.IconPresentation {
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
private StatusBar myStatusBar;
|
||||
|
||||
@Override
|
||||
@@ -351,13 +345,8 @@ public final class SettingsEntryPointAction extends DumbAwareAction implements R
|
||||
resetActionIcon();
|
||||
myStatusBar.updateWidget(WIDGET_ID);
|
||||
|
||||
if (!myPopupState.isHidden() || myPopupState.isRecentlyHidden()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Component component = event.getComponent();
|
||||
ListPopup popup = createMainPopup(DataManager.getInstance().getDataContext(component), component);
|
||||
myPopupState.prepareToShow(popup);
|
||||
popup.addListener(new JBPopupListener() {
|
||||
@Override
|
||||
public void beforeShown(@NotNull LightweightWindowEvent event) {
|
||||
|
||||
@@ -23,7 +23,6 @@ import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.DropDownLink;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.IJSwingUtilities;
|
||||
@@ -54,7 +53,6 @@ final class TrafficLightPopup {
|
||||
private final JPanel myContent = new JPanel(new GridBagLayout());
|
||||
private final Map<String, JProgressBar> myProgressBarMap = new HashMap<>();
|
||||
private final AncestorListener myAncestorListener;
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
private final Alarm popupAlarm = new Alarm();
|
||||
private final List<DropDownLink<?>> levelLinks = new ArrayList<>();
|
||||
|
||||
@@ -118,7 +116,7 @@ final class TrafficLightPopup {
|
||||
|
||||
private void showPopup(@NotNull InputEvent event, @NotNull AnalyzerStatus analyzerStatus) {
|
||||
hidePopup();
|
||||
if (myPopupState.isRecentlyHidden() || analyzerStatus.isEmpty()) return; // do not show new popup
|
||||
if (analyzerStatus.isEmpty()) return; // do not show new popup
|
||||
|
||||
updateContentPanel(analyzerStatus);
|
||||
|
||||
@@ -136,7 +134,6 @@ final class TrafficLightPopup {
|
||||
|
||||
myPopup = myPopupBuilder.createPopup();
|
||||
myPopup.addListener(myPopupListener);
|
||||
myPopupState.prepareToShow(myPopup);
|
||||
myEditor.getComponent().addAncestorListener(myAncestorListener);
|
||||
|
||||
JComponent owner = (JComponent)event.getComponent();
|
||||
|
||||
@@ -4,11 +4,9 @@ package com.intellij.openapi.wm.impl.content;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.rd.GraphicsExKt;
|
||||
import com.intellij.openapi.ui.popup.ActiveIcon;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.ui.ExperimentalUI;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.content.Content;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.scale.JBUIScale;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -27,8 +25,6 @@ import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
final class ContentComboLabel extends ContentLabel {
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
|
||||
private final ActiveIcon myComboIcon = new ActiveIcon(ExperimentalUI.isNewUI()
|
||||
? AllIcons.General.LinkDropTriangle
|
||||
: AllIcons.General.ArrowDown);
|
||||
@@ -71,8 +67,7 @@ final class ContentComboLabel extends ContentLabel {
|
||||
if (findHoveredIcon() != null) return;
|
||||
|
||||
if (UIUtil.isActionClick(e)) {
|
||||
if (myPopupState.isRecentlyHidden()) return; // do not show new popup
|
||||
ToolWindowContentUi.toggleContentPopup(myUi, myUi.getContentManager(), myPopupState);
|
||||
ToolWindowContentUi.toggleContentPopup(myUi, myUi.getContentManager());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.ui.ThreeComponentsSplitter;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
@@ -37,7 +36,6 @@ import com.intellij.ui.content.tabs.PinToolwindowTabAction;
|
||||
import com.intellij.ui.content.tabs.TabbedContentAction;
|
||||
import com.intellij.ui.layout.migLayout.MigLayoutUtilKt;
|
||||
import com.intellij.ui.layout.migLayout.patched.MigLayout;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.ui.tabs.impl.MorePopupAware;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ContentUtilEx;
|
||||
@@ -757,12 +755,6 @@ public final class ToolWindowContentUi implements ContentUI, DataProvider {
|
||||
}
|
||||
|
||||
public static void toggleContentPopup(@NotNull ToolWindowContentUi content, @NotNull ContentManager contentManager) {
|
||||
toggleContentPopup(content, contentManager, null);
|
||||
}
|
||||
|
||||
static void toggleContentPopup(@NotNull ToolWindowContentUi content,
|
||||
@NotNull ContentManager contentManager,
|
||||
@Nullable PopupState<JBPopup> popupState) {
|
||||
SelectContentStep step = new SelectContentStep(contentManager.getContents());
|
||||
Content selectedContent = contentManager.getSelectedContent();
|
||||
if (selectedContent != null) {
|
||||
@@ -770,7 +762,6 @@ public final class ToolWindowContentUi implements ContentUI, DataProvider {
|
||||
}
|
||||
|
||||
ListPopup popup = JBPopupFactory.getInstance().createListPopup(step);
|
||||
if (popupState != null) popupState.prepareToShow(popup);
|
||||
content.getCurrentLayout().showContentPopup(popup);
|
||||
|
||||
if (selectedContent instanceof TabbedContent) {
|
||||
|
||||
@@ -7,7 +7,9 @@ import com.intellij.ide.DataManager
|
||||
import com.intellij.internal.statistic.service.fus.collectors.StatusBarPopupShown
|
||||
import com.intellij.openapi.actionSystem.DataContext
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil
|
||||
import com.intellij.openapi.application.*
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.EDT
|
||||
import com.intellij.openapi.application.readAction
|
||||
import com.intellij.openapi.editor.Document
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.EditorFactory
|
||||
@@ -34,7 +36,6 @@ import com.intellij.openapi.wm.StatusBarWidget.WidgetPresentation
|
||||
import com.intellij.openapi.wm.impl.status.TextPanel.WithIconAndArrows
|
||||
import com.intellij.ui.ClickListener
|
||||
import com.intellij.ui.awt.RelativePoint
|
||||
import com.intellij.ui.popup.PopupState
|
||||
import com.intellij.util.cancelOnDispose
|
||||
import com.intellij.util.concurrency.annotations.RequiresBackgroundThread
|
||||
import com.intellij.util.indexing.IndexingBundle
|
||||
@@ -67,8 +68,6 @@ abstract class EditorBasedStatusBarPopup(
|
||||
@Suppress("DEPRECATION")
|
||||
constructor(project: Project, isWriteableFileRequired: Boolean) : this(project, isWriteableFileRequired, project.coroutineScope)
|
||||
|
||||
private val popupState = PopupState.forPopup()
|
||||
|
||||
private val component: Lazy<JPanel> = lazy {
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode) {
|
||||
EDT.assertIsEdt()
|
||||
@@ -207,7 +206,7 @@ abstract class EditorBasedStatusBarPopup(
|
||||
}
|
||||
|
||||
private fun showPopup(e: MouseEvent) {
|
||||
if (!isActionEnabled || popupState.isRecentlyHidden) {
|
||||
if (!isActionEnabled) {
|
||||
// do not show popup
|
||||
return
|
||||
}
|
||||
@@ -216,7 +215,6 @@ abstract class EditorBasedStatusBarPopup(
|
||||
val popup = createPopup(dataContext) ?: return
|
||||
val dimension = popup.content.preferredSize
|
||||
val at = Point(0, -dimension.height)
|
||||
popupState.prepareToShow(popup)
|
||||
popup.show(RelativePoint(e.component, at))
|
||||
// destroy popup on unexpected project close
|
||||
Disposer.register(this, popup)
|
||||
|
||||
@@ -46,7 +46,6 @@ import com.intellij.ui.awt.RelativeRectangle
|
||||
import com.intellij.ui.border.name
|
||||
import com.intellij.ui.popup.AbstractPopup
|
||||
import com.intellij.ui.popup.NotificationPopup
|
||||
import com.intellij.ui.popup.PopupState
|
||||
import com.intellij.util.EventDispatcher
|
||||
import com.intellij.util.childScope
|
||||
import com.intellij.util.concurrency.annotations.RequiresEdt
|
||||
@@ -857,19 +856,11 @@ private class MultipleTextValues(private val presentation: MultipleTextValuesPre
|
||||
setTextAlignment(CENTER_ALIGNMENT)
|
||||
border = JBUI.CurrentTheme.StatusBar.Widget.border()
|
||||
object : ClickListener() {
|
||||
val myPopupState = PopupState.forPopup()
|
||||
|
||||
override fun onClick(event: MouseEvent, clickCount: Int): Boolean {
|
||||
if (myPopupState.isRecentlyHidden) {
|
||||
// do not show new popup
|
||||
return false
|
||||
}
|
||||
|
||||
val popup = presentation.getPopup() ?: return false
|
||||
StatusBarPopupShown.log(presentation::class.java)
|
||||
val dimension = getSizeFor(popup)
|
||||
val at = Point(0, -dimension.height)
|
||||
myPopupState.prepareToShow(popup)
|
||||
popup.show(RelativePoint(event.component, at))
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -13,11 +13,9 @@ import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.ex.TooltipDescriptionProvider;
|
||||
import com.intellij.openapi.options.ShowSettingsUtil;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.util.ui.JBRectangle;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -39,7 +37,6 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
private BalloonImpl.ActionButton myMoreButton;
|
||||
private BalloonImpl.ActionButton myCloseButton;
|
||||
private List<BalloonImpl.ActionButton> myActions;
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
|
||||
private static final Rectangle CloseHoverBounds = new JBRectangle(5, 5, 12, 10);
|
||||
|
||||
@@ -51,8 +48,6 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
myBalloon = balloon;
|
||||
myRepaintPanel = repaintPanel;
|
||||
myNotification = notification;
|
||||
|
||||
Disposer.register(balloon, () -> myPopupState.hidePopup());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -129,10 +124,6 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
}
|
||||
|
||||
private void showMorePopup() {
|
||||
if (!myPopupState.isHidden() || myPopupState.isRecentlyHidden()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DefaultActionGroup group = new MyActionGroup();
|
||||
|
||||
if (NotificationsConfigurationImpl.getInstanceImpl().isRegistered(myNotification.getGroupId())) {
|
||||
@@ -162,7 +153,7 @@ public class NotificationBalloonActionProvider implements BalloonImpl.ActionProv
|
||||
|
||||
ListPopup popup = JBPopupFactory.getInstance()
|
||||
.createActionGroupPopup(null, group, DataManager.getInstance().getDataContext(myMoreButton), true, null, -1);
|
||||
myPopupState.prepareToShow(popup);
|
||||
Disposer.register(myBalloon, popup);
|
||||
popup.showUnderneathOf(myMoreButton);
|
||||
}
|
||||
|
||||
|
||||
@@ -488,9 +488,6 @@ internal open class RowImpl(private val dialogPanelConfig: DialogPanelConfig,
|
||||
}
|
||||
|
||||
private class PopupActionGroup(private val actions: Array<AnAction>): ActionGroup(), DumbAware {
|
||||
|
||||
private val popupState = PopupState.forPopup()
|
||||
|
||||
init {
|
||||
isPopup = true
|
||||
templatePresentation.isPerformGroup = actions.isNotEmpty()
|
||||
@@ -499,13 +496,8 @@ private class PopupActionGroup(private val actions: Array<AnAction>): ActionGrou
|
||||
override fun getChildren(e: AnActionEvent?): Array<AnAction> = actions
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
if (popupState.isRecentlyHidden) {
|
||||
return
|
||||
}
|
||||
|
||||
val popup = JBPopupFactory.getInstance().createActionGroupPopup(null, this, e.dataContext,
|
||||
JBPopupFactory.ActionSelectionAid.MNEMONICS, true)
|
||||
popupState.prepareToShow(popup)
|
||||
PopupUtil.showForActionButtonEvent(popup, e)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,19 +7,15 @@ import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
import com.intellij.openapi.ui.popup.ListPopup;
|
||||
import com.intellij.openapi.ui.popup.util.PopupUtil;
|
||||
import com.intellij.ui.popup.PopupState;
|
||||
import com.intellij.vcs.log.VcsLogDataKeys;
|
||||
import com.intellij.vcs.log.VcsLogUi;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class VcsLogToolbarPopupActionGroup extends DefaultActionGroup implements DumbAware {
|
||||
|
||||
private final PopupState<JBPopup> myPopupState = PopupState.forPopup();
|
||||
|
||||
@Override
|
||||
public @NotNull ActionUpdateThread getActionUpdateThread() {
|
||||
return ActionUpdateThread.BGT;
|
||||
@@ -27,12 +23,10 @@ public class VcsLogToolbarPopupActionGroup extends DefaultActionGroup implements
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
if (myPopupState.isRecentlyHidden()) return; // do not show new popup
|
||||
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, this, e.getDataContext(),
|
||||
JBPopupFactory.ActionSelectionAid.MNEMONICS, true,
|
||||
ActionPlaces.VCS_LOG_TOOLBAR_POPUP_PLACE);
|
||||
popup.setShowSubmenuOnHover(true);
|
||||
myPopupState.prepareToShow(popup);
|
||||
PopupUtil.showForActionButtonEvent(popup, e);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,21 +7,16 @@ import com.intellij.openapi.actionSystem.ActionGroupUtil
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import com.intellij.openapi.ui.popup.ListPopup
|
||||
import com.intellij.openapi.util.NlsContexts
|
||||
import com.intellij.ui.popup.PopupState
|
||||
import com.intellij.util.ui.FilterComponent
|
||||
import java.util.function.Supplier
|
||||
|
||||
internal abstract class VcsLogPopupComponent(displayName: Supplier<@NlsContexts.Label String>) : FilterComponent(displayName) {
|
||||
private val myPopupState = PopupState.forPopup()
|
||||
|
||||
init {
|
||||
setShowPopupAction(Runnable { showPopupMenu() })
|
||||
}
|
||||
|
||||
fun showPopupMenu() {
|
||||
if (myPopupState.isRecentlyHidden) return // do not show new popup
|
||||
val popup = createPopupMenu()
|
||||
myPopupState.prepareToShow(popup)
|
||||
popup.showUnderneathOf(this)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user