From 447dde40217c239e508fa1673f1151939d3f7ef0 Mon Sep 17 00:00:00 2001 From: Sergey Simonchik Date: Thu, 5 Sep 2019 15:56:55 +0300 Subject: [PATCH] terminal: restrict access, better names GitOrigin-RevId: 51c81633d2e72f1b00fce24ebe3805fcec0d6d04 --- .../intellij/terminal/JBTerminalPanel.java | 4 +- .../JBTerminalSystemSettingsProviderBase.java | 49 ++++++++++--------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java b/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java index 7d4335f3af21..c36499e7d7bc 100644 --- a/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java +++ b/platform/platform-impl/src/com/intellij/terminal/JBTerminalPanel.java @@ -301,7 +301,7 @@ public class JBTerminalPanel extends TerminalPanel implements FocusListener, Ter } public FontInfo fontForChar(final char c, @JdkConstants.FontStyle int style) { - return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorScheme().getConsoleFontPreferences(), null); + return ComplementaryFontsRegistry.getFontAbleToDisplay(c, style, mySettingsProvider.getColorsScheme().getConsoleFontPreferences(), null); } @Override @@ -327,7 +327,7 @@ public class JBTerminalPanel extends TerminalPanel implements FocusListener, Ter if (EditorSettingsExternalizable.getInstance().isWheelFontChangeEnabled() && EditorUtil.isChangeFontSize(e)) { int newFontSize = (int)mySettingsProvider.getTerminalFontSize() - e.getWheelRotation(); if (newFontSize >= MIN_FONT_SIZE) { - mySettingsProvider.getColorScheme().setConsoleFontSize(newFontSize); + mySettingsProvider.getColorsScheme().setConsoleFontSize(newFontSize); mySettingsProvider.fireFontChanged(); } return; diff --git a/platform/platform-impl/src/com/intellij/terminal/JBTerminalSystemSettingsProviderBase.java b/platform/platform-impl/src/com/intellij/terminal/JBTerminalSystemSettingsProviderBase.java index 6b384537372f..dd73f3e73eeb 100644 --- a/platform/platform-impl/src/com/intellij/terminal/JBTerminalSystemSettingsProviderBase.java +++ b/platform/platform-impl/src/com/intellij/terminal/JBTerminalSystemSettingsProviderBase.java @@ -49,26 +49,26 @@ import static com.intellij.openapi.keymap.KeymapUtil.getActiveKeymapShortcuts; * @author traff */ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsProvider implements Disposable { - protected final MyColorSchemeDelegate myColorScheme; + private final MyColorsSchemeDelegate myColorsScheme; private JBTerminalSchemeColorPalette myColorPalette; public JBTerminalSystemSettingsProviderBase() { - myColorScheme = createBoundColorSchemeDelegate(); + myColorsScheme = createBoundColorSchemeDelegate(); MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this); connection.subscribe(UISettingsListener.TOPIC, uiSettings -> { - int oldSize = myColorScheme.getConsoleFontSize(); - int newSize = consoleFontSize(myColorScheme); + int oldSize = myColorsScheme.getConsoleFontSize(); + int newSize = consoleFontSize(myColorsScheme); if (oldSize != newSize) { - myColorScheme.setConsoleFontSize(newSize); + myColorsScheme.setConsoleFontSize(newSize); fireFontChanged(); } }); connection.subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() { @Override public void globalSchemeChange(EditorColorsScheme scheme) { - myColorScheme.updateGlobalScheme(scheme); - myColorScheme.setConsoleFontSize(consoleFontSize(myColorScheme)); + myColorsScheme.updateGlobalScheme(scheme); + myColorsScheme.setConsoleFontSize(consoleFontSize(myColorsScheme)); myColorPalette = null; fireFontChanged(); } @@ -107,7 +107,7 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP public ColorPalette getTerminalColorPalette() { JBTerminalSchemeColorPalette colorPalette = myColorPalette; if (colorPalette == null) { - colorPalette = new JBTerminalSchemeColorPalette(myColorScheme); + colorPalette = new JBTerminalSchemeColorPalette(myColorsScheme); myColorPalette = colorPalette; } return colorPalette; @@ -158,7 +158,7 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP return getKeyStrokesByActionId("Terminal.MoveToolWindowTabLeft"); } - protected static int consoleFontSize(MyColorSchemeDelegate colorScheme) { + private static int consoleFontSize(@NotNull MyColorsSchemeDelegate colorScheme) { int size; if (UISettings.getInstance().getPresentationMode()) { size = UISettings.getInstance().getPresentationModeFontSize(); @@ -169,7 +169,7 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP return size; } - private static class MyColorSchemeDelegate implements EditorColorsScheme { + static class MyColorsSchemeDelegate implements EditorColorsScheme { private final FontPreferencesImpl myFontPreferences = new FontPreferencesImpl(); private final HashMap myOwnAttributes = new HashMap<>(); @@ -180,7 +180,7 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP private int myConsoleFontSize; - protected MyColorSchemeDelegate() { + protected MyColorsSchemeDelegate() { updateGlobalScheme(null); myConsoleFontSize = consoleFontSize(this); initFonts(); @@ -403,35 +403,36 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP } @NotNull - private static MyColorSchemeDelegate createBoundColorSchemeDelegate() { - return new MyColorSchemeDelegate(); + private static MyColorsSchemeDelegate createBoundColorSchemeDelegate() { + return new MyColorsSchemeDelegate(); } - public EditorColorsScheme getColorScheme() { - return myColorScheme; + @NotNull + MyColorsSchemeDelegate getColorsScheme() { + return myColorsScheme; } @Override public float getLineSpace() { - return myColorScheme.getConsoleLineSpacing(); + return myColorsScheme.getConsoleLineSpacing(); } @Override public TextStyle getSelectionColor() { - return new TextStyle(TerminalColor.awt(myColorScheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR)), - TerminalColor.awt(myColorScheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR))); + return new TextStyle(TerminalColor.awt(myColorsScheme.getColor(EditorColors.SELECTION_FOREGROUND_COLOR)), + TerminalColor.awt(myColorsScheme.getColor(EditorColors.SELECTION_BACKGROUND_COLOR))); } @Override public TextStyle getFoundPatternColor() { - return new TextStyle(TerminalColor.awt(myColorScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES).getForegroundColor()), - TerminalColor.awt(myColorScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES).getBackgroundColor())); + return new TextStyle(TerminalColor.awt(myColorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES).getForegroundColor()), + TerminalColor.awt(myColorsScheme.getAttributes(EditorColors.TEXT_SEARCH_RESULT_ATTRIBUTES).getBackgroundColor())); } @Override public TextStyle getHyperlinkColor() { - return new TextStyle(TerminalColor.awt(myColorScheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR).getForegroundColor()), - TerminalColor.awt(myColorScheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR).getBackgroundColor())); + return new TextStyle(TerminalColor.awt(myColorsScheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR).getForegroundColor()), + TerminalColor.awt(myColorsScheme.getAttributes(EditorColors.REFERENCE_HYPERLINK_COLOR).getBackgroundColor())); } @Override @@ -446,7 +447,7 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP } public String getFontName() { - List fonts = myColorScheme.getConsoleFontPreferences().getEffectiveFontFamilies(); + List fonts = myColorsScheme.getConsoleFontPreferences().getEffectiveFontFamilies(); if (fonts.size() > 0) { return fonts.get(0); @@ -457,7 +458,7 @@ public class JBTerminalSystemSettingsProviderBase extends DefaultTabbedSettingsP @Override public float getTerminalFontSize() { - return (float)myColorScheme.getConsoleFontSize(); + return (float)myColorsScheme.getConsoleFontSize(); } @Override