From 913b68a5a0bd55011655425b275411dbd6bd147c Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 30 Jan 2017 17:36:03 +0100 Subject: [PATCH] =?UTF-8?q?UISettings=20=E2=80=94=20use=20smart=20state=20?= =?UTF-8?q?class=20(stored=20properties),=20part=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/intellij/ide/ui/UISettings.kt | 2 +- .../ide/ui/AppearanceConfigurable.java | 8 ++++---- .../intellij/openapi/wm/impl/IdeRootPane.java | 20 ++++++++++++++++--- .../edu/PyCharmEduInitialConfigurator.java | 4 ++-- .../python/PyCharmInitialConfigurator.java | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) 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 864f60841c59..8f98ff1d7f6b 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 @@ -76,8 +76,8 @@ class UISettings : BaseState(), PersistentStateComponent { @get:OptionTag("LEFT_HORIZONTAL_SPLIT") var leftGorizontalSplit by storedProperty(false) @get:OptionTag("RIGHT_HORIZONTAL_SPLIT") var rightGorizontalSplit by storedProperty(false) @get:OptionTag("SHOW_EDITOR_TOOLTIP") var showEditorToolTip by storedProperty(true) + @get:OptionTag("SHOW_MEMORY_INDICATOR") var showMemoryIndicator by storedProperty(false) - @JvmField var SHOW_MEMORY_INDICATOR = false @JvmField var ALLOW_MERGE_BUTTONS = true @JvmField var SHOW_MAIN_TOOLBAR = false @JvmField var SHOW_STATUS_BAR = true diff --git a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java index 86fec0434cab..87938feb4f97 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java @@ -192,8 +192,8 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab settings.setHideToolStripes(!myComponent.myShowToolStripesCheckBox.isSelected()); update |= settings.SHOW_ICONS_IN_MENUS != myComponent.myCbDisplayIconsInMenu.isSelected(); settings.SHOW_ICONS_IN_MENUS = myComponent.myCbDisplayIconsInMenu.isSelected(); - update |= settings.SHOW_MEMORY_INDICATOR != myComponent.myShowMemoryIndicatorCheckBox.isSelected(); - settings.SHOW_MEMORY_INDICATOR = myComponent.myShowMemoryIndicatorCheckBox.isSelected(); + update |= settings.getShowMemoryIndicator() != myComponent.myShowMemoryIndicatorCheckBox.isSelected(); + settings.setShowMemoryIndicator(myComponent.myShowMemoryIndicatorCheckBox.isSelected()); update |= settings.ALLOW_MERGE_BUTTONS != myComponent.myAllowMergeButtons.isSelected(); settings.ALLOW_MERGE_BUTTONS = myComponent.myAllowMergeButtons.isSelected(); update |= settings.CYCLE_SCROLLING != myComponent.myCycleScrollingCheckBox.isSelected(); @@ -339,7 +339,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab myComponent.myWindowShortcutsCheckBox.setSelected(settings.getShowToolWindowsNumbers()); myComponent.myShowToolStripesCheckBox.setSelected(!settings.getHideToolStripes()); myComponent.myCbDisplayIconsInMenu.setSelected(settings.SHOW_ICONS_IN_MENUS); - myComponent.myShowMemoryIndicatorCheckBox.setSelected(settings.SHOW_MEMORY_INDICATOR); + myComponent.myShowMemoryIndicatorCheckBox.setSelected(settings.getShowMemoryIndicator()); myComponent.myAllowMergeButtons.setSelected(settings.ALLOW_MERGE_BUTTONS); myComponent.myCycleScrollingCheckBox.setSelected(settings.CYCLE_SCROLLING); @@ -406,7 +406,7 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab isModified |= myComponent.myWindowShortcutsCheckBox.isSelected() != settings.getShowToolWindowsNumbers(); isModified |= myComponent.myShowToolStripesCheckBox.isSelected() == settings.getHideToolStripes(); isModified |= myComponent.myCbDisplayIconsInMenu.isSelected() != settings.SHOW_ICONS_IN_MENUS; - isModified |= myComponent.myShowMemoryIndicatorCheckBox.isSelected() != settings.SHOW_MEMORY_INDICATOR; + isModified |= myComponent.myShowMemoryIndicatorCheckBox.isSelected() != settings.getShowMemoryIndicator(); isModified |= myComponent.myAllowMergeButtons.isSelected() != settings.ALLOW_MERGE_BUTTONS; isModified |= myComponent.myCycleScrollingCheckBox.isSelected() != settings.CYCLE_SCROLLING; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java index 4bd295c8ff5b..20208f0238b8 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.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. @@ -153,6 +153,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { /** * Invoked when enclosed frame is being shown. */ + @Override public final void addNotify(){ super.addNotify(); } @@ -160,6 +161,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { /** * Invoked when enclosed frame is being disposed. */ + @Override public final void removeNotify(){ if (ScreenUtil.isStandardAddRemoveNotify(this)) { if (!myStatusBarDisposed) { @@ -191,6 +193,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { contentPane.revalidate(); } + @Override protected JLayeredPane createLayeredPane() { JLayeredPane p = new JBLayeredPane(); p.setName(this.getName()+".layeredPane"); @@ -204,6 +207,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { super.setLayout(mgr); } + @Override protected final Container createContentPane(){ return myContentPane = new IdePanePanel(new BorderLayout()); } @@ -262,22 +266,27 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { for (final StatusBarCustomComponentFactory componentFactory : myStatusBarCustomComponentFactories) { final JComponent c = componentFactory.createComponent(myStatusBar); myStatusBar.addWidget(new CustomStatusBarWidget() { + @Override public JComponent getComponent() { return c; } + @Override @NotNull public String ID() { return c.getClass().getSimpleName(); } + @Override public WidgetPresentation getPresentation(@NotNull PlatformType type) { return null; } + @Override public void install(@NotNull StatusBar statusBar) { } + @Override public void dispose() { componentFactory.disposeComponent(myStatusBar, c); } @@ -288,7 +297,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { myStatusBar.addWidget(myMemoryWidget); myStatusBar.addWidget(new IdeMessagePanel(frame, MessagePool.getInstance()), "before " + MemoryUsagePanel.WIDGET_ID); - setMemoryIndicatorVisible(UISettings.getInstance().SHOW_MEMORY_INDICATOR); + setMemoryIndicatorVisible(UISettings.getInstance().getShowMemoryIndicator()); } void setMemoryIndicatorVisible(final boolean visible) { @@ -342,8 +351,9 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { return null; } + @Override public void uiSettingsChanged(UISettings uiSettings) { - setMemoryIndicatorVisible(uiSettings.SHOW_MEMORY_INDICATOR); + setMemoryIndicatorVisible(uiSettings.getShowMemoryIndicator()); updateToolbarVisibility(); updateStatusBarVisibility(); for (IdeRootPaneNorthExtension component : myNorthComponents) { @@ -359,6 +369,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { } private class MyRootLayout extends RootLayout { + @Override public Dimension preferredLayoutSize(Container parent) { Dimension rd, mbd; Insets i = getInsets(); @@ -379,6 +390,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { rd.height + mbd.height + i.top + i.bottom); } + @Override public Dimension minimumLayoutSize(Container parent) { Dimension rd, mbd; Insets i = getInsets(); @@ -398,6 +410,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { rd.height + mbd.height + i.top + i.bottom); } + @Override public Dimension maximumLayoutSize(Container target) { Dimension rd, mbd; Insets i = getInsets(); @@ -418,6 +431,7 @@ public class IdeRootPane extends JRootPane implements UISettingsListener { rd.height + mbd.height + i.top + i.bottom); } + @Override public void layoutContainer(Container parent) { Rectangle b = parent.getBounds(); Insets i = getInsets(); diff --git a/python/educational-python/src/com/jetbrains/python/edu/PyCharmEduInitialConfigurator.java b/python/educational-python/src/com/jetbrains/python/edu/PyCharmEduInitialConfigurator.java index 14c81d8c6e43..49e1a8bfb9f9 100644 --- a/python/educational-python/src/com/jetbrains/python/edu/PyCharmEduInitialConfigurator.java +++ b/python/educational-python/src/com/jetbrains/python/edu/PyCharmEduInitialConfigurator.java @@ -164,7 +164,7 @@ public class PyCharmEduInitialConfigurator { propertiesComponent.setValue("toolwindow.stripes.buttons.info.shown", "true"); uiSettings.setHideToolStripes(false); - uiSettings.SHOW_MEMORY_INDICATOR = false; + uiSettings.setShowMemoryIndicator(false); uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true; uiSettings.SHOW_MAIN_TOOLBAR = false; @@ -178,7 +178,7 @@ public class PyCharmEduInitialConfigurator { settings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; settings.getCommonSettings(PythonLanguage.getInstance()).ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true; uiSettings.SHOW_DIRECTORY_FOR_NON_UNIQUE_FILENAMES = true; - uiSettings.SHOW_MEMORY_INDICATOR = false; + uiSettings.setShowMemoryIndicator(false); final String ignoredFilesList = fileTypeManager.getIgnoredFilesList(); ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> FileTypeManager.getInstance().setIgnoredFilesList(ignoredFilesList + ";*$py.class"))); PyCodeInsightSettings.getInstance().SHOW_IMPORT_POPUP = false; diff --git a/python/src/com/jetbrains/python/PyCharmInitialConfigurator.java b/python/src/com/jetbrains/python/PyCharmInitialConfigurator.java index 19e20ba20e75..1614a1adef64 100644 --- a/python/src/com/jetbrains/python/PyCharmInitialConfigurator.java +++ b/python/src/com/jetbrains/python/PyCharmInitialConfigurator.java @@ -55,7 +55,7 @@ public final class PyCharmInitialConfigurator { } if (!propertiesComponent.getBoolean("PyCharm.InitialConfiguration.V3")) { propertiesComponent.setValue("PyCharm.InitialConfiguration.V3", "true"); - UISettings.getInstance().SHOW_MEMORY_INDICATOR = false; + UISettings.getInstance().setShowMemoryIndicator(false); final String ignoredFilesList = fileTypeManager.getIgnoredFilesList(); ApplicationManager.getApplication().invokeLater(() -> ApplicationManager.getApplication().runWriteAction(() -> FileTypeManager.getInstance().setIgnoredFilesList(ignoredFilesList + ";*$py.class"))); }