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
add clickable link to Confluence page about JetBrains Runtime Environment
This commit is contained in:
@@ -18,6 +18,7 @@ package com.intellij.application.options.colors;
|
||||
|
||||
import com.intellij.application.options.EditorFontsConstants;
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.ide.IdeTooltipManager;
|
||||
import com.intellij.ide.ui.AntialiasingType;
|
||||
import com.intellij.ide.ui.UISettings;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
@@ -27,10 +28,7 @@ import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.editor.colors.FontPreferences;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.ui.FontComboBox;
|
||||
import com.intellij.ui.FontInfoRenderer;
|
||||
import com.intellij.ui.IdeBorderFactory;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.components.JBCheckBox;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -105,7 +103,11 @@ public class FontOptions extends JPanel implements OptionsPanel{
|
||||
myEnableLigaturesCheckbox.setBorder(null);
|
||||
panel.add(myEnableLigaturesCheckbox);
|
||||
JLabel warningIcon = new JLabel(AllIcons.General.BalloonWarning);
|
||||
warningIcon.setToolTipText(ApplicationBundle.message("ligatures.jre.warning", ApplicationNamesInfo.getInstance().getFullProductName()));
|
||||
IdeTooltipManager.getInstance().setCustomTooltip(
|
||||
warningIcon,
|
||||
new TooltipWithClickableLinks.ForBrowser(warningIcon,
|
||||
ApplicationBundle.message("ligatures.jre.warning",
|
||||
ApplicationNamesInfo.getInstance().getFullProductName())));
|
||||
warningIcon.setBorder(JBUI.Borders.emptyLeft(5));
|
||||
updateWarningIconVisibility(warningIcon);
|
||||
panel.add(warningIcon);
|
||||
|
||||
@@ -38,6 +38,7 @@ 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.ObjectUtils;
|
||||
import com.intellij.util.ui.Html;
|
||||
import com.intellij.util.ui.JBInsets;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
@@ -57,6 +58,7 @@ import java.awt.event.AWTEventListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class IdeTooltipManager implements ApplicationComponent, AWTEventListener {
|
||||
private static final String CUSTOM_TOOLTIP = "custom.tooltip";
|
||||
public static final String IDE_TOOLTIP_PLACE = "IdeTooltip";
|
||||
|
||||
public static final Color GRAPHITE_COLOR = new Color(100, 100, 100, 230);
|
||||
@@ -177,7 +179,7 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
}
|
||||
|
||||
String tooltipText = comp.getToolTipText(me);
|
||||
if (tooltipText == null || tooltipText.trim().isEmpty()) return;
|
||||
if ((tooltipText == null || tooltipText.trim().isEmpty()) && getCustomTooltip(comp) == null) return;
|
||||
|
||||
|
||||
boolean centerDefault = Boolean.TRUE.equals(comp.getClientProperty(UIUtil.CENTER_TOOLTIP_DEFAULT));
|
||||
@@ -199,29 +201,40 @@ public class IdeTooltipManager implements ApplicationComponent, AWTEventListener
|
||||
}
|
||||
|
||||
private void queueShow(final JComponent c, final MouseEvent me, final boolean toCenter, int shift, int posChangeX, int posChangeY) {
|
||||
String aText = String.valueOf(c.getToolTipText(me));
|
||||
final IdeTooltip tooltip = new IdeTooltip(c, me.getPoint(), null, /*new Object()*/c, aText) {
|
||||
@Override
|
||||
protected boolean beforeShow() {
|
||||
myCurrentEvent = me;
|
||||
IdeTooltip tooltip = getCustomTooltip(c);
|
||||
if (tooltip == null) {
|
||||
String aText = String.valueOf(c.getToolTipText(me));
|
||||
tooltip = new IdeTooltip(c, me.getPoint(), null, /*new Object()*/c, aText) {
|
||||
@Override
|
||||
protected boolean beforeShow() {
|
||||
myCurrentEvent = me;
|
||||
|
||||
if (!c.isShowing()) return false;
|
||||
if (!c.isShowing()) return false;
|
||||
|
||||
String text = c.getToolTipText(myCurrentEvent);
|
||||
if (text == null || text.trim().isEmpty()) return false;
|
||||
String text = c.getToolTipText(myCurrentEvent);
|
||||
if (text == null || text.trim().isEmpty()) return false;
|
||||
|
||||
JLayeredPane layeredPane = UIUtil.getParentOfType(JLayeredPane.class, c);
|
||||
JLayeredPane layeredPane = UIUtil.getParentOfType(JLayeredPane.class, c);
|
||||
|
||||
final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane);
|
||||
final Wrapper wrapper = new Wrapper(pane);
|
||||
setTipComponent(wrapper);
|
||||
return true;
|
||||
}
|
||||
}.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top);
|
||||
final JEditorPane pane = initPane(text, new HintHint(me).setAwtTooltip(true), layeredPane);
|
||||
final Wrapper wrapper = new Wrapper(pane);
|
||||
setTipComponent(wrapper);
|
||||
return true;
|
||||
}
|
||||
}.setToCenter(toCenter).setCalloutShift(shift).setPositionChangeShift(posChangeX, posChangeY).setLayer(Balloon.Layer.top);
|
||||
}
|
||||
|
||||
show(tooltip, false);
|
||||
}
|
||||
|
||||
public void setCustomTooltip(JComponent component, IdeTooltip tooltip) {
|
||||
component.putClientProperty(CUSTOM_TOOLTIP, tooltip);
|
||||
}
|
||||
|
||||
public IdeTooltip getCustomTooltip(JComponent component) {
|
||||
return ObjectUtils.tryCast(component.getClientProperty(CUSTOM_TOOLTIP), IdeTooltip.class);
|
||||
}
|
||||
|
||||
public IdeTooltip show(final IdeTooltip tooltip, boolean now) {
|
||||
return show(tooltip, now, true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
package com.intellij.ui;
|
||||
|
||||
import com.intellij.ide.BrowserUtil;
|
||||
import com.intellij.ide.IdeTooltip;
|
||||
import com.intellij.ide.IdeTooltipManager;
|
||||
import com.intellij.ide.TooltipEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.HyperlinkEvent;
|
||||
import javax.swing.event.HyperlinkListener;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Custom tooltip implementation which supports clickable links in HTML text
|
||||
*
|
||||
* @see IdeTooltipManager#setCustomTooltip(JComponent, IdeTooltip)
|
||||
*/
|
||||
public class TooltipWithClickableLinks extends IdeTooltip {
|
||||
public TooltipWithClickableLinks(JComponent component, String htmlText, HyperlinkListener hyperlinkListener) {
|
||||
super(component, new Point(), createTipComponent(htmlText, hyperlinkListener), component, htmlText);
|
||||
}
|
||||
|
||||
private static JComponent createTipComponent(String text, HyperlinkListener hyperlinkListener) {
|
||||
JEditorPane pane = IdeTooltipManager.initPane(text, new HintHint().setAwtTooltip(true), null);
|
||||
pane.addHyperlinkListener(hyperlinkListener);
|
||||
return pane;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canAutohideOn(TooltipEvent event) {
|
||||
return !event.isIsEventInsideBalloon();
|
||||
}
|
||||
|
||||
public static class ForBrowser extends TooltipWithClickableLinks {
|
||||
public ForBrowser(JComponent component, String htmlText) {
|
||||
super(component, htmlText, new HyperlinkAdapter() {
|
||||
@Override
|
||||
protected void hyperlinkActivated(HyperlinkEvent e) {
|
||||
BrowserUtil.browse(e.getURL());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -533,7 +533,7 @@ checkbox.show.only.monospaced.fonts=Show only monospaced fonts
|
||||
primary.font=Primary font:
|
||||
secondary.font=Secondary font:
|
||||
use.ligatures=Enable font ligatures
|
||||
ligatures.jre.warning=The JRE you are running {0} with might have\nfunctional and performance issues related to ligatures support.\nTo avoid such issues, run IntelliJ IDEA with the bundled JRE.
|
||||
ligatures.jre.warning=<html>The JRE you are running {0} with might have<br>functional and performance issues related to ligatures support.<br>To avoid such issues, run {0} with <a href="https://confluence.jetbrains.com/display/IDEADEV/JetBrains+Runtime+Environment">JetBrains Runtime</a>.
|
||||
editbox.enter.tag.name=Enter tag name:
|
||||
title.tag.name=Tag Name
|
||||
title.xml=XML
|
||||
|
||||
Reference in New Issue
Block a user