diff --git a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt index 5e54d488b7bb..f62e9d2d5389 100644 --- a/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt +++ b/platform/editor-ui-api/src/com/intellij/ide/ui/UISettings.kt @@ -55,13 +55,15 @@ class UISettings : BaseState(), PersistentStateComponent { @get:OptionTag("FONT_SIZE") var fontSize by storedProperty(0) - @Property(filter = FontFilter::class) private var FONT_SCALE: Float = 0.toFloat() + @get:Property(filter = FontFilter::class) + @get:OptionTag("FONT_SCALE") + private var fontScale by storedProperty(0f) @get:OptionTag("RECENT_FILES_LIMIT") var recentFilesLimit by storedProperty(50) @get:OptionTag("CONSOLE_COMMAND_HISTORY_LIMIT") var consoleCommandHistoryLimit by storedProperty(300) - @JvmField var OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = false - @JvmField var CONSOLE_CYCLE_BUFFER_SIZE_KB = 1024 - @JvmField var EDITOR_TAB_LIMIT = 10 + @get:OptionTag("OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE") var overrideConsoleCycleBufferSize by storedProperty(false) + @get:OptionTag("CONSOLE_CYCLE_BUFFER_SIZE_KB") var consoleCycleBufferSizeKb by storedProperty(1024) + @get:OptionTag("EDITOR_TAB_LIMIT") var editorTabLimit by storedProperty(10) @get:OptionTag("REUSE_NOT_MODIFIED_TABS") var reuseNotModifiedTabs by storedProperty(false) @get:OptionTag("ANIMATE_WINDOWS") var animateWindows by storedProperty(true) @@ -113,17 +115,12 @@ class UISettings : BaseState(), PersistentStateComponent { @get:OptionTag("SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES") var showDirectoryForNonUniqueFilenames by storedProperty(true) @get:OptionTag("NAVIGATE_TO_PREVIEW") var navigateToPreview by storedProperty(false) + @get:OptionTag("SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY") var sortLookupElementsLexicographically by storedProperty(false) + @get:OptionTag("MERGE_EQUAL_STACKTRACES") var mergeEqualStackTraces by storedProperty(true) + @get:OptionTag("SORT_BOOKMARKS") var sortBookmarks by storedProperty(false) + private val myTreeDispatcher = ComponentTreeEventDispatcher.create(UISettingsListener::class.java) - @get:OptionTag("SORT_LOOKUP_ELEMENTS_LEXICOGRAPHICALLY") - var sortLookupElementsLexicographically by storedProperty(false) - - @get:OptionTag("MERGE_EQUAL_STACKTRACES") - var mergeEqualStackTraces by storedProperty(true) - - @get:OptionTag("SORT_BOOKMARKS") - var sortBookmarks by storedProperty(false) - init { tweakPlatformDefaults() @@ -146,7 +143,6 @@ class UISettings : BaseState(), PersistentStateComponent { } } - @Suppress("DeprecatedCallableAddReplaceWith") @Deprecated("Please use {@link UISettingsListener#TOPIC}") fun addUISettingsListener(listener: UISettingsListener, parentDisposable: Disposable) { @@ -184,13 +180,16 @@ class UISettings : BaseState(), PersistentStateComponent { CONSOLE_COMMAND_HISTORY_LIMIT = consoleCommandHistoryLimit FONT_SIZE = fontSize FONT_FACE = fontFace + EDITOR_TAB_LIMIT = editorTabLimit + OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = overrideConsoleCycleBufferSize + CONSOLE_CYCLE_BUFFER_SIZE_KB = consoleCycleBufferSizeKb } private fun initDefFont() { val fontData = systemFontFaceAndSize if (fontFace == null) fontFace = fontData.first if (fontSize <= 0) fontSize = fontData.second - if (FONT_SCALE <= 0) FONT_SCALE = JBUI.scale(1f) + if (fontScale <= 0) fontScale = JBUI.scale(1f) } class FontFilter : SerializationFilter { @@ -201,7 +200,7 @@ class UISettings : BaseState(), PersistentStateComponent { return fontData.first != settings.fontFace } // store only in pair - return !(fontData.second == settings.fontSize && 1f == settings.FONT_SCALE) + return !(fontData.second == settings.fontSize && 1f == settings.fontScale) } } @@ -229,14 +228,14 @@ class UISettings : BaseState(), PersistentStateComponent { alphaModeRatio = 0.5f } - if (FONT_SCALE <= 0) { + if (fontScale <= 0) { // Reset font to default on switch from IDEA-managed HiDPI to JDK-managed HiDPI. Doesn't affect OSX. if (UIUtil.isJDKManagedHiDPI() && !SystemInfo.isMac) fontSize = UIUtil.DEF_SYSTEM_FONT_SIZE.toInt() } else { - fontSize = JBUI.scale(fontSize / FONT_SCALE).toInt() + fontSize = JBUI.scale(fontSize / fontScale).toInt() } - FONT_SCALE = JBUI.scale(1f) + fontScale = JBUI.scale(1f) initDefFont() // 1. Sometimes system font cannot display standard ASCII symbols. If so we have @@ -435,5 +434,23 @@ class UISettings : BaseState(), PersistentStateComponent { @JvmField @Transient var PRESENTATION_MODE_FONT_SIZE = 24 + + @Suppress("unused") + @Deprecated("Use editorTabLimit", replaceWith = ReplaceWith("editorTabLimit")) + @JvmField + @Transient + var EDITOR_TAB_LIMIT = editorTabLimit + + @Suppress("unused") + @Deprecated("Use overrideConsoleCycleBufferSize", replaceWith = ReplaceWith("overrideConsoleCycleBufferSize")) + @JvmField + @Transient + var OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = false + + @Suppress("unused") + @Deprecated("Use consoleCycleBufferSizeKb", replaceWith = ReplaceWith("consoleCycleBufferSizeKb")) + @JvmField + @Transient + var CONSOLE_CYCLE_BUFFER_SIZE_KB = consoleCycleBufferSizeKb // } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java index 7425c44b4877..18395871b9c1 100644 --- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java +++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorTabsConfigurable.java @@ -125,7 +125,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { myEditorTabPlacement.setSelectedItem(uiSettings.getEditorTabPlacement()); myHideKnownExtensions.setSelected(uiSettings.getHdeKnownExtensionInTabs()); myShowDirectoryInTabCheckBox.setSelected(uiSettings.getShowDirectoryForNonUniqueFilenames()); - myEditorTabLimitField.setText(Integer.toString(uiSettings.EDITOR_TAB_LIMIT)); + myEditorTabLimitField.setText(Integer.toString(uiSettings.getEditorTabLimit())); myReuseNotModifiedTabsCheckBox.setSelected(uiSettings.getReuseNotModifiedTabs()); myShowCloseButtonOnCheckBox.setSelected(uiSettings.getShowCloseButton()); @@ -184,9 +184,9 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { if (isModified(myReuseNotModifiedTabsCheckBox, uiSettings.getReuseNotModifiedTabs())) uiSettingsChanged = true; uiSettings.setReuseNotModifiedTabs(myReuseNotModifiedTabsCheckBox.isSelected()); - if (isModified(myEditorTabLimitField, uiSettings.EDITOR_TAB_LIMIT, EDITOR_TABS_RANGE)) uiSettingsChanged = true; + if (isModified(myEditorTabLimitField, uiSettings.getEditorTabLimit(), EDITOR_TABS_RANGE)) uiSettingsChanged = true; try { - uiSettings.EDITOR_TAB_LIMIT = EDITOR_TABS_RANGE.fit(Integer.parseInt(myEditorTabLimitField.getText().trim())); + uiSettings.setEditorTabLimit(EDITOR_TABS_RANGE.fit(Integer.parseInt(myEditorTabLimitField.getText().trim()))); } catch (NumberFormatException ignored) { } @@ -200,7 +200,7 @@ public class EditorTabsConfigurable implements EditorOptionsProvider { final UISettings uiSettings = UISettings.getInstance(); boolean isModified = isModified(myCbModifiedTabsMarkedWithAsterisk, uiSettings.getMarkModifiedTabsWithAsterisk()); isModified |= isModified(myShowTabsTooltipsCheckBox, uiSettings.getShowTabsTooltips()); - isModified |= isModified(myEditorTabLimitField, uiSettings.EDITOR_TAB_LIMIT); + isModified |= isModified(myEditorTabLimitField, uiSettings.getEditorTabLimit()); isModified |= isModified(myReuseNotModifiedTabsCheckBox, uiSettings.getReuseNotModifiedTabs()); int tabPlacement = ((Integer)myEditorTabPlacement.getSelectedItem()).intValue(); isModified |= tabPlacement != uiSettings.getEditorTabPlacement(); diff --git a/platform/lang-impl/src/com/intellij/execution/console/ConsoleConfigurable.java b/platform/lang-impl/src/com/intellij/execution/console/ConsoleConfigurable.java index a3fcf06fe5aa..58f868f0953b 100644 --- a/platform/lang-impl/src/com/intellij/execution/console/ConsoleConfigurable.java +++ b/platform/lang-impl/src/com/intellij/execution/console/ConsoleConfigurable.java @@ -110,10 +110,11 @@ public class ConsoleConfigurable implements SearchableConfigurable, Configurable boolean isModified = !ContainerUtil.newHashSet(myNegativePanel.getListItems()).equals(ContainerUtil.newHashSet(mySettings.getNegativePatterns())); isModified |= !ContainerUtil.newHashSet(myPositivePanel.getListItems()).equals(ContainerUtil.newHashSet(mySettings.getPositivePatterns())); isModified |= isModified(myCbUseSoftWrapsAtConsole, editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE)); - isModified |= isModified(myCommandsHistoryLimitField, UISettings.getInstance().getConsoleCommandHistoryLimit()); + UISettings uiSettings = UISettings.getInstance(); + isModified |= isModified(myCommandsHistoryLimitField, uiSettings.getConsoleCommandHistoryLimit()); if (ConsoleBuffer.useCycleBuffer()) { - isModified |= isModified(myCbOverrideConsoleCycleBufferSize, UISettings.getInstance().OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE); - isModified |= isModified(myConsoleCycleBufferSizeField, UISettings.getInstance().CONSOLE_CYCLE_BUFFER_SIZE_KB); + isModified |= isModified(myCbOverrideConsoleCycleBufferSize, uiSettings.getOverrideConsoleCycleBufferSize()); + isModified |= isModified(myConsoleCycleBufferSizeField, uiSettings.getConsoleCycleBufferSizeKb()); } return isModified; @@ -141,12 +142,12 @@ public class ConsoleConfigurable implements SearchableConfigurable, Configurable uiSettingsChanged = true; } if (ConsoleBuffer.useCycleBuffer()) { - if (isModified(myCbOverrideConsoleCycleBufferSize, uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE)) { - uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = myCbOverrideConsoleCycleBufferSize.isSelected(); + if (isModified(myCbOverrideConsoleCycleBufferSize, uiSettings.getOverrideConsoleCycleBufferSize())) { + uiSettings.setOverrideConsoleCycleBufferSize(myCbOverrideConsoleCycleBufferSize.isSelected()); uiSettingsChanged = true; } - if (isModified(myConsoleCycleBufferSizeField, uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB)) { - uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB = Math.max(0, Math.min(1024*100, Integer.parseInt(myConsoleCycleBufferSizeField.getText().trim()))); + if (isModified(myConsoleCycleBufferSizeField, uiSettings.getConsoleCycleBufferSizeKb())) { + uiSettings.setConsoleCycleBufferSizeKb(Math.max(0, Math.min(1024*100, Integer.parseInt(myConsoleCycleBufferSizeField.getText().trim())))); uiSettingsChanged = true; } } @@ -168,9 +169,9 @@ public class ConsoleConfigurable implements SearchableConfigurable, Configurable myCommandsHistoryLimitField.setText(Integer.toString(uiSettings.getConsoleCommandHistoryLimit())); myCbOverrideConsoleCycleBufferSize.setEnabled(ConsoleBuffer.useCycleBuffer()); - myCbOverrideConsoleCycleBufferSize.setSelected(uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE); - myConsoleCycleBufferSizeField.setEnabled(ConsoleBuffer.useCycleBuffer() && uiSettings.OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE); - myConsoleCycleBufferSizeField.setText(Integer.toString(uiSettings.CONSOLE_CYCLE_BUFFER_SIZE_KB)); + myCbOverrideConsoleCycleBufferSize.setSelected(uiSettings.getOverrideConsoleCycleBufferSize()); + myConsoleCycleBufferSizeField.setEnabled(ConsoleBuffer.useCycleBuffer() && uiSettings.getOverrideConsoleCycleBufferSize()); + myConsoleCycleBufferSizeField.setText(Integer.toString(uiSettings.getConsoleCycleBufferSizeKb())); myNegativePanel.resetFrom(mySettings.getNegativePatterns()); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java index fcfd2d11b4e5..9c86b44c63b1 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -24,8 +24,8 @@ public class ConsoleBuffer { } public static int getCycleBufferSize() { - if (UISettings.getInstance().OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE) { - return UISettings.getInstance().CONSOLE_CYCLE_BUFFER_SIZE_KB * 1024; + if (UISettings.getInstance().getOverrideConsoleCycleBufferSize()) { + return UISettings.getInstance().getConsoleCycleBufferSizeKb() * 1024; } return getLegacyCycleBufferSize(); } diff --git a/platform/lang-impl/src/com/intellij/ide/util/EditorHelper.java b/platform/lang-impl/src/com/intellij/ide/util/EditorHelper.java index ae22cafd724f..446b3a2d7dc9 100644 --- a/platform/lang-impl/src/com/intellij/ide/util/EditorHelper.java +++ b/platform/lang-impl/src/com/intellij/ide/util/EditorHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -29,11 +29,9 @@ import com.intellij.psi.PsiFile; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.List; - public class EditorHelper { public static void openFilesInEditor(@NotNull T[] elements) { - final int limit = UISettings.getInstance().EDITOR_TAB_LIMIT; + final int limit = UISettings.getInstance().getEditorTabLimit(); final int max = Math.min(limit, elements.length); for (int i = 0; i < max; i++) { openInEditor(elements[i], true); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java index 9b2c25aa86e8..ac971faced7d 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorWindow.java @@ -106,7 +106,7 @@ public class EditorWindow { private final Stack> myRemovedTabs = new Stack>() { @Override public void push(Pair pair) { - if (size() >= UISettings.getInstance().EDITOR_TAB_LIMIT) { + if (size() >= UISettings.getInstance().getEditorTabLimit()) { remove(0); } super.push(pair); @@ -675,7 +675,7 @@ public class EditorWindow { final VirtualFile file = editor.getFile(); final Icon template = AllIcons.FileTypes.Text; myTabbedPane.insertTab(file, EmptyIcon.create(template.getIconWidth(), template.getIconHeight()), new TComp(this, editor), null, indexToInsert); - trimToSize(UISettings.getInstance().EDITOR_TAB_LIMIT, file, false); + trimToSize(UISettings.getInstance().getEditorTabLimit(), file, false); if (selectEditor) { setSelectedEditor(editor, focusEditor); } @@ -959,7 +959,7 @@ public class EditorWindow { private void processSiblingEditor(final EditorWithProviderComposite siblingEditor) { if (myTabbedPane != null && - getTabCount() < UISettings.getInstance().EDITOR_TAB_LIMIT && + getTabCount() < UISettings.getInstance().getEditorTabLimit() && findFileComposite(siblingEditor.getFile()) == null || myTabbedPane == null && getTabCount() == 0) { setEditor(siblingEditor, true); } diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java index 1a8943c171de..1976613eda4c 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/EditorsSplitters.java @@ -805,7 +805,7 @@ public class EditorsSplitters extends IdePanePanel implements UISettingsListener final List children = new ArrayList<>(fileElements.size()); // trim to EDITOR_TAB_LIMIT, ignoring CLOSE_NON_MODIFIED_FILES_FIRST policy - int toRemove = fileElements.size() - UISettings.getInstance().EDITOR_TAB_LIMIT; + int toRemove = fileElements.size() - UISettings.getInstance().getEditorTabLimit(); for (Element fileElement : fileElements) { if (toRemove <= 0 || Boolean.valueOf(fileElement.getAttributeValue(PINNED)).booleanValue()) { children.add(fileElement); diff --git a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java index 8f5e60482854..ff1cf87acb48 100644 --- a/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/fileEditor/impl/FileEditorManagerImpl.java @@ -1870,7 +1870,7 @@ public class FileEditorManagerImpl extends FileEditorManagerEx implements Persis for (EditorsSplitters each : getAllSplitters()) { each.setTabsPlacement(uiSettings.getEditorTabPlacement()); - each.trimToSize(uiSettings.EDITOR_TAB_LIMIT); + each.trimToSize(uiSettings.getEditorTabLimit()); // Tab layout policy if (uiSettings.getScrollTabLayoutInEditor()) { diff --git a/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java b/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java index 05a35732aed0..588ba317a696 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java +++ b/platform/platform-tests/testSrc/com/intellij/execution/impl/ConsoleViewImplTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2016 JetBrains s.r.o. + * Copyright 2000-2017 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. @@ -251,11 +251,11 @@ public class ConsoleViewImplTest extends LightPlatformTestCase { } private static void withCycleConsole(int capacityKB, Consumer runnable) { - boolean oldUse = UISettings.getInstance().OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE; - int oldSize = UISettings.getInstance().CONSOLE_CYCLE_BUFFER_SIZE_KB; + boolean oldUse = UISettings.getInstance().getOverrideConsoleCycleBufferSize(); + int oldSize = UISettings.getInstance().getConsoleCycleBufferSizeKb(); - UISettings.getInstance().OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = true; - UISettings.getInstance().CONSOLE_CYCLE_BUFFER_SIZE_KB = capacityKB; + UISettings.getInstance().setOverrideConsoleCycleBufferSize(true); + UISettings.getInstance().setConsoleCycleBufferSizeKb(capacityKB); // create new to reflect changed buffer size ConsoleViewImpl console = createConsole(); try { @@ -267,8 +267,8 @@ public class ConsoleViewImplTest extends LightPlatformTestCase { } finally { Disposer.dispose(console); - UISettings.getInstance().OVERRIDE_CONSOLE_CYCLE_BUFFER_SIZE = oldUse; - UISettings.getInstance().CONSOLE_CYCLE_BUFFER_SIZE_KB = oldSize; + UISettings.getInstance().setOverrideConsoleCycleBufferSize(oldUse); + UISettings.getInstance().setConsoleCycleBufferSizeKb(oldSize); } } diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileEditorManagerTest.java b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileEditorManagerTest.java index b1d4235b21b3..1860864cd2a0 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileEditorManagerTest.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/fileEditor/FileEditorManagerTest.java @@ -52,16 +52,15 @@ public class FileEditorManagerTest extends FileEditorManagerTestCase { } public void testTabLimit() throws Exception { - - int limit = UISettings.getInstance().EDITOR_TAB_LIMIT; + int limit = UISettings.getInstance().getEditorTabLimit(); try { - UISettings.getInstance().EDITOR_TAB_LIMIT = 2; + UISettings.getInstance().setEditorTabLimit(2); openFiles(STRING); // note that foo.xml is pinned assertOpenFiles("foo.xml", "3.txt"); } finally { - UISettings.getInstance().EDITOR_TAB_LIMIT = limit; + UISettings.getInstance().setEditorTabLimit(limit); } }