mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
show warning in settings UI when user enables ligatures, and IDE is not launched using bundled JRE
correct checks whether tooltip is defined, make sure mouse events are generated for component with custom tooltip, not its parent
This commit is contained in:
@@ -35,14 +35,12 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.registry.RegistryValue;
|
||||
import com.intellij.openapi.util.registry.RegistryValueListener;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
import com.intellij.util.Alarm;
|
||||
import com.intellij.util.ui.Html;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -59,6 +57,7 @@ import java.awt.event.MouseEvent;
|
||||
|
||||
public class IdeTooltipManager implements ApplicationComponent, AWTEventListener {
|
||||
private static final Key<IdeTooltip> CUSTOM_TOOLTIP = Key.create("custom.tooltip");
|
||||
private static final MouseEventAdapter<Void> DUMMY_LISTENER = new MouseEventAdapter<Void>(null);
|
||||
public static final String IDE_TOOLTIP_PLACE = "IdeTooltip";
|
||||
|
||||
public static final Color GRAPHITE_COLOR = new Color(100, 100, 100, 230);
|
||||
@@ -143,7 +142,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
if (!myCurrentTipIsCentered) {
|
||||
myX = me.getX();
|
||||
myY = me.getY();
|
||||
if (c instanceof JComponent && ((JComponent)c).getToolTipText(me) == null && (myQueuedTooltip == null || !myQueuedTooltip.isHint())) {
|
||||
if (c instanceof JComponent && !isTooltipDefined((JComponent)c, me) && (myQueuedTooltip == null || !myQueuedTooltip.isHint())) {
|
||||
hideCurrent(me, null, null);//There is no tooltip or hint here, let's proceed it as MOUSE_EXITED
|
||||
}
|
||||
else {
|
||||
@@ -178,9 +177,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
if (JBPopupFactory.getInstance().isChildPopupFocused(wnd)) return;
|
||||
}
|
||||
|
||||
String tooltipText = comp.getToolTipText(me);
|
||||
if ((tooltipText == null || tooltipText.trim().isEmpty()) && getCustomTooltip(comp) == null) return;
|
||||
|
||||
if (!isTooltipDefined(comp, me)) return;
|
||||
|
||||
boolean centerDefault = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT));
|
||||
boolean centerStrict = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_STRICT));
|
||||
@@ -200,6 +197,10 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
queueShow(comp, me, centerStrict || centerDefault, shift, -shift, -shift);
|
||||
}
|
||||
|
||||
private boolean isTooltipDefined(JComponent comp, MouseEvent me) {
|
||||
return !StringUtil.isEmpty(comp.getToolTipText(me)) || getCustomTooltip(comp) != null;
|
||||
}
|
||||
|
||||
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) {
|
||||
IdeTooltip tooltip = getCustomTooltip(c);
|
||||
if (tooltip == null) {
|
||||
@@ -229,6 +230,13 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
|
||||
public void setCustomTooltip(JComponent component, IdeTooltip tooltip) {
|
||||
UIUtil.putClientProperty(component, CUSTOM_TOOLTIP, tooltip);
|
||||
// We need to register a dummy mouse listener to make sure events will be generated for this specific component, not its parent
|
||||
component.removeMouseListener(DUMMY_LISTENER);
|
||||
component.removeMouseMotionListener(DUMMY_LISTENER);
|
||||
if (tooltip != null) {
|
||||
component.addMouseListener(DUMMY_LISTENER);
|
||||
component.addMouseMotionListener(DUMMY_LISTENER);
|
||||
}
|
||||
}
|
||||
|
||||
public IdeTooltip getCustomTooltip(JComponent component) {
|
||||
|
||||
Reference in New Issue
Block a user