mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Show a warning on editor font overridden by the color scheme
This commit is contained in:
+4
-1
@@ -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
|
||||
|
||||
+83
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -549,6 +549,8 @@ secondary.font=Fallback font:
|
||||
use.ligatures=Enable font ligatures
|
||||
ligatures.jre.warning=<html>The JRE you are running {0} with<br>is known to have performance issues<br>related to ligatures support.<br>Use <a href="https://confluence.jetbrains.com/display/IDEADEV/JetBrains+Runtime+Environment">JetBrains Runtime</a> instead to enable ligatures.
|
||||
settings.editor.font.none=<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
|
||||
|
||||
Reference in New Issue
Block a user