diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontConfigurable.java
index 53059ebd94c2..a2c4d024ee75 100644
--- a/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontConfigurable.java
+++ b/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontConfigurable.java
@@ -55,6 +55,7 @@ public class AppEditorFontConfigurable implements SearchableConfigurable {
@Override
public boolean isModified() {
+ getFontPanel().getOptionsPanel().updateWarning();
return !getStoredPreferences().equals(getUIFontPreferences());
}
@@ -75,7 +76,9 @@ public class AppEditorFontConfigurable implements SearchableConfigurable {
@Override
public void reset() {
getStoredPreferences().copyTo(getUIFontPreferences());
- getFontPanel().getOptionsPanel().updateOptionsList();
+ AppEditorFontOptionsPanel optionsPanel = getFontPanel().getOptionsPanel();
+ optionsPanel.updateWarning();
+ optionsPanel.updateOptionsList();
}
@NotNull
diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontOptionsPanel.java b/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontOptionsPanel.java
index 3efd658b415d..e18127ea1bb7 100644
--- a/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontOptionsPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/editor/fonts/AppEditorFontOptionsPanel.java
@@ -16,18 +16,73 @@
package com.intellij.application.options.editor.fonts;
import com.intellij.application.options.colors.AbstractFontOptionsPanel;
+import com.intellij.application.options.colors.ColorAndFontOptions;
+import com.intellij.icons.AllIcons;
+import com.intellij.ide.DataManager;
+import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.intellij.openapi.editor.colors.FontPreferences;
+import com.intellij.openapi.options.Configurable;
+import com.intellij.openapi.options.ex.Settings;
+import com.intellij.ui.HoverHyperlinkLabel;
+import com.intellij.ui.JBColor;
+import com.intellij.util.ui.JBUI;
import org.jetbrains.annotations.NotNull;
+import javax.swing.*;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+import java.awt.*;
+
public class AppEditorFontOptionsPanel extends AbstractFontOptionsPanel {
private final EditorColorsScheme myScheme;
+ private JPanel myWarningPanel;
+ private JLabel myEditorFontLabel;
protected AppEditorFontOptionsPanel(EditorColorsScheme scheme) {
myScheme = scheme;
updateOptionsList();
}
+ @Override
+ protected JComponent createControls() {
+ JPanel topPanel = new JPanel(new GridBagLayout());
+ GridBagConstraints c = new GridBagConstraints();
+ c.insets = JBUI.emptyInsets();
+ c.gridx = 0;
+ c.gridy = 0;
+ c.anchor = GridBagConstraints.WEST;
+ myWarningPanel = createMessagePanel();
+ topPanel.add(myWarningPanel, c);
+ c.gridy = 1;
+ topPanel.add(createFontSettingsPanel(), c);
+ return topPanel;
+ }
+
+ private JPanel createMessagePanel() {
+ JPanel messagePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ messagePanel.add(new JLabel(AllIcons.General.BalloonWarning));
+ myEditorFontLabel = createHyperlinkLabel();
+ messagePanel.add(myEditorFontLabel);
+ JLabel commentLabel = new JLabel(ApplicationBundle.message("settings.editor.font.defined.in.color.scheme.message"));
+ commentLabel.setForeground(JBColor.GRAY);
+ messagePanel.add(commentLabel);
+ return messagePanel;
+ }
+
+ public void updateWarning() {
+ EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
+ if (!scheme.isUseAppFontPreferencesInEditor()) {
+ myEditorFontLabel.setText(
+ ApplicationBundle.message("settings.editor.font.overridden.message", scheme.getEditorFontName(), scheme.getEditorFontSize()));
+ myWarningPanel.setVisible(true);
+ }
+ else {
+ myWarningPanel.setVisible(false);
+ }
+ }
+
@Override
protected boolean isReadOnly() {
return false;
@@ -58,4 +113,32 @@ public class AppEditorFontOptionsPanel extends AbstractFontOptionsPanel {
protected void setCurrentLineSpacing(float lineSpacing) {
myScheme.setLineSpacing(lineSpacing);
}
+
+ @NotNull
+ private JLabel createHyperlinkLabel() {
+ HoverHyperlinkLabel label = new HoverHyperlinkLabel("");
+ label.addHyperlinkListener(new HyperlinkListener() {
+ @Override
+ public void hyperlinkUpdate(HyperlinkEvent e) {
+ if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+ navigateToColorSchemeFontConfigurable();
+ }
+ }
+ });
+ return label;
+ }
+
+ protected void navigateToColorSchemeFontConfigurable() {
+ Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(getPanel()));
+ if (allSettings != null) {
+ final Configurable colorSchemeConfigurable = allSettings.find(ColorAndFontOptions.ID);
+ if (colorSchemeConfigurable instanceof ColorAndFontOptions) {
+ Configurable fontOptions =
+ ((ColorAndFontOptions)colorSchemeConfigurable).findSubConfigurable(ColorAndFontOptions.FONT_CONFIGURABLE_NAME);
+ if (fontOptions != null) {
+ allSettings.select(fontOptions);
+ }
+ }
+ }
+ }
}
diff --git a/platform/platform-resources-en/src/messages/ApplicationBundle.properties b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
index bd3dd33b3a27..8ac50a622962 100644
--- a/platform/platform-resources-en/src/messages/ApplicationBundle.properties
+++ b/platform/platform-resources-en/src/messages/ApplicationBundle.properties
@@ -549,6 +549,8 @@ secondary.font=Fallback font:
use.ligatures=Enable font ligatures
ligatures.jre.warning=The JRE you are running {0} with
is known to have performance issues
related to ligatures support.
Use JetBrains Runtime instead to enable ligatures.
settings.editor.font.none=
+settings.editor.font.overridden.message=Current editor font: {0}, {1}
+settings.editor.font.defined.in.color.scheme.message= \u2014 defined in the color scheme
editbox.enter.tag.name=Enter tag name:
title.tag.name=Tag Name
title.xml=XML