From dcd4684684e510a6fdc0cc5774317ede0291d9b7 Mon Sep 17 00:00:00 2001 From: Vladimir Krivosheev Date: Mon, 30 Jan 2017 17:27:36 +0100 Subject: [PATCH] =?UTF-8?q?UISettings=20=E2=80=94=20use=20smart=20state=20?= =?UTF-8?q?class=20(stored=20properties),=20part=203?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/com/intellij/ide/ui/UISettings.kt | 10 +++--- .../intellij/openapi/wm/ToolWindowAnchor.java | 6 ++-- .../ide/ui/AppearanceConfigurable.java | 24 ++++++------- .../openapi/wm/impl/ToolWindowsPane.java | 36 +++++++++---------- 4 files changed, 39 insertions(+), 37 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 510a8c99bb49..3e844cc3f3a5 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 @@ -64,16 +64,18 @@ class UISettings : BaseState(), PersistentStateComponent { @Suppress("unused") @Deprecated("Use hideToolStripes", replaceWith = ReplaceWith("hideToolStripes")) - @JvmField var HIDE_TOOL_STRIPES = true + @JvmField + @Transient + var HIDE_TOOL_STRIPES = true @get:OptionTag("REUSE_NOT_MODIFIED_TABS") var reuseNotModifiedTabs by storedProperty(false) @get:OptionTag("ANIMATE_WINDOWS") var animateWindows by storedProperty(true) @get:OptionTag("SHOW_TOOL_WINDOW_NUMBERS") var showToolWindowsNumbers by storedProperty(true) @get:OptionTag("HIDE_TOOL_STRIPES") var hideToolStripes by storedProperty(true) + @get:OptionTag("WIDESCREEN_SUPPORT") var wideScreenSupport by storedProperty(false) + @get:OptionTag("LEFT_HORIZONTAL_SPLIT") var leftGorizontalSplit by storedProperty(false) + @get:OptionTag("RIGHT_HORIZONTAL_SPLIT") var rightGorizontalSplit by storedProperty(false) - @JvmField var WIDESCREEN_SUPPORT = false - @JvmField var LEFT_HORIZONTAL_SPLIT = false - @JvmField var RIGHT_HORIZONTAL_SPLIT = false @JvmField var SHOW_EDITOR_TOOLTIP = true @JvmField var SHOW_MEMORY_INDICATOR = false @JvmField var ALLOW_MERGE_BUTTONS = true diff --git a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowAnchor.java b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowAnchor.java index 88f544d237de..6d76a9d588a7 100644 --- a/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowAnchor.java +++ b/platform/platform-api/src/com/intellij/openapi/wm/ToolWindowAnchor.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. @@ -59,8 +59,8 @@ public final class ToolWindowAnchor { } public boolean isSplitVertically() { - return this == LEFT && !UISettings.getInstance().LEFT_HORIZONTAL_SPLIT - || this == RIGHT && !UISettings.getInstance().RIGHT_HORIZONTAL_SPLIT; + return this == LEFT && !UISettings.getInstance().getLeftGorizontalSplit() + || this == RIGHT && !UISettings.getInstance().getRightGorizontalSplit(); } @NotNull 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 0a613c8ead46..86fec0434cab 100644 --- a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java +++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java @@ -213,14 +213,14 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab update |= settings.USE_SMALL_LABELS_ON_TABS != myComponent.myUseSmallLabelsOnTabs.isSelected(); settings.USE_SMALL_LABELS_ON_TABS = myComponent.myUseSmallLabelsOnTabs.isSelected(); - update |= settings.WIDESCREEN_SUPPORT != myComponent.myWidescreenLayoutCheckBox.isSelected(); - settings.WIDESCREEN_SUPPORT = myComponent.myWidescreenLayoutCheckBox.isSelected(); + update |= settings.getWideScreenSupport() != myComponent.myWidescreenLayoutCheckBox.isSelected(); + settings.setWideScreenSupport(myComponent.myWidescreenLayoutCheckBox.isSelected()); - update |= settings.LEFT_HORIZONTAL_SPLIT != myComponent.myLeftLayoutCheckBox.isSelected(); - settings.LEFT_HORIZONTAL_SPLIT = myComponent.myLeftLayoutCheckBox.isSelected(); + update |= settings.getLeftGorizontalSplit() != myComponent.myLeftLayoutCheckBox.isSelected(); + settings.setLeftGorizontalSplit(myComponent.myLeftLayoutCheckBox.isSelected()); - update |= settings.RIGHT_HORIZONTAL_SPLIT != myComponent.myRightLayoutCheckBox.isSelected(); - settings.RIGHT_HORIZONTAL_SPLIT = myComponent.myRightLayoutCheckBox.isSelected(); + update |= settings.getRightGorizontalSplit() != myComponent.myRightLayoutCheckBox.isSelected(); + settings.setRightGorizontalSplit(myComponent.myRightLayoutCheckBox.isSelected()); update |= settings.NAVIGATE_TO_PREVIEW != (myComponent.myNavigateToPreviewCheckBox.isVisible() && myComponent.myNavigateToPreviewCheckBox.isSelected()); settings.NAVIGATE_TO_PREVIEW = myComponent.myNavigateToPreviewCheckBox.isSelected(); @@ -351,9 +351,9 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab myComponent.myOverrideLAFFonts.setSelected(settings.OVERRIDE_NONIDEA_LAF_FONTS); myComponent.myDisableMnemonics.setSelected(settings.DISABLE_MNEMONICS); myComponent.myUseSmallLabelsOnTabs.setSelected(settings.USE_SMALL_LABELS_ON_TABS); - myComponent.myWidescreenLayoutCheckBox.setSelected(settings.WIDESCREEN_SUPPORT); - myComponent.myLeftLayoutCheckBox.setSelected(settings.LEFT_HORIZONTAL_SPLIT); - myComponent.myRightLayoutCheckBox.setSelected(settings.RIGHT_HORIZONTAL_SPLIT); + myComponent.myWidescreenLayoutCheckBox.setSelected(settings.getWideScreenSupport()); + myComponent.myLeftLayoutCheckBox.setSelected(settings.getLeftGorizontalSplit()); + myComponent.myRightLayoutCheckBox.setSelected(settings.getRightGorizontalSplit()); myComponent.myNavigateToPreviewCheckBox.setSelected(settings.NAVIGATE_TO_PREVIEW); myComponent.myNavigateToPreviewCheckBox.setVisible(false);//disabled for a while myComponent.myColorBlindnessPanel.setColorBlindness(settings.COLOR_BLINDNESS); @@ -416,9 +416,9 @@ public class AppearanceConfigurable extends BaseConfigurable implements Searchab isModified |= myComponent.myDisableMnemonicInControlsCheckBox.isSelected() != settings.DISABLE_MNEMONICS_IN_CONTROLS; isModified |= myComponent.myUseSmallLabelsOnTabs.isSelected() != settings.USE_SMALL_LABELS_ON_TABS; - isModified |= myComponent.myWidescreenLayoutCheckBox.isSelected() != settings.WIDESCREEN_SUPPORT; - isModified |= myComponent.myLeftLayoutCheckBox.isSelected() != settings.LEFT_HORIZONTAL_SPLIT; - isModified |= myComponent.myRightLayoutCheckBox.isSelected() != settings.RIGHT_HORIZONTAL_SPLIT; + isModified |= myComponent.myWidescreenLayoutCheckBox.isSelected() != settings.getWideScreenSupport(); + isModified |= myComponent.myLeftLayoutCheckBox.isSelected() != settings.getLeftGorizontalSplit(); + isModified |= myComponent.myRightLayoutCheckBox.isSelected() != settings.getRightGorizontalSplit(); isModified |= myComponent.myNavigateToPreviewCheckBox.isSelected() != settings.NAVIGATE_TO_PREVIEW; isModified |= myComponent.myColorBlindnessPanel.getColorBlindness() != settings.COLOR_BLINDNESS; diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java index dcebeb4b859f..6bad473f78cd 100644 --- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java +++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/ToolWindowsPane.java @@ -111,9 +111,9 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi myHorizontalSplitter.setDividerWidth(0); myHorizontalSplitter.setDividerMouseZoneSize(Registry.intValue("ide.splitter.mouseZone")); myHorizontalSplitter.setBackground(Color.gray); - myWidescreen = UISettings.getInstance().WIDESCREEN_SUPPORT; - myLeftHorizontalSplit = UISettings.getInstance().LEFT_HORIZONTAL_SPLIT; - myRightHorizontalSplit = UISettings.getInstance().RIGHT_HORIZONTAL_SPLIT; + myWidescreen = UISettings.getInstance().getWideScreenSupport(); + myLeftHorizontalSplit = UISettings.getInstance().getLeftGorizontalSplit(); + myRightHorizontalSplit = UISettings.getInstance().getRightGorizontalSplit(); if (myWidescreen) { myHorizontalSplitter.setInnerComponent(myVerticalSplitter); } @@ -577,9 +577,10 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi } private void updateLayout() { - if (myWidescreen != UISettings.getInstance().WIDESCREEN_SUPPORT) { + UISettings uiSettings = UISettings.getInstance(); + if (myWidescreen != uiSettings.getWideScreenSupport()) { JComponent documentComponent = (myWidescreen ? myVerticalSplitter : myHorizontalSplitter).getInnerComponent(); - myWidescreen = UISettings.getInstance().WIDESCREEN_SUPPORT; + myWidescreen = uiSettings.getWideScreenSupport(); if (myWidescreen) { myVerticalSplitter.setInnerComponent(null); myHorizontalSplitter.setInnerComponent(myVerticalSplitter); @@ -592,7 +593,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi myLayeredPane.add(myWidescreen ? myHorizontalSplitter : myVerticalSplitter, DEFAULT_LAYER); setDocumentComponent(documentComponent); } - if (myLeftHorizontalSplit != UISettings.getInstance().LEFT_HORIZONTAL_SPLIT) { + if (myLeftHorizontalSplit != uiSettings.getLeftGorizontalSplit()) { JComponent component = getComponentAt(ToolWindowAnchor.LEFT); if (component instanceof Splitter) { Splitter splitter = (Splitter)component; @@ -602,9 +603,9 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi ? first.getWindowInfo().getWeight() : first.getWindowInfo().getWeight() + second.getWindowInfo().getWeight()); } - myLeftHorizontalSplit = UISettings.getInstance().LEFT_HORIZONTAL_SPLIT; + myLeftHorizontalSplit = uiSettings.getLeftGorizontalSplit(); } - if (myRightHorizontalSplit != UISettings.getInstance().RIGHT_HORIZONTAL_SPLIT) { + if (myRightHorizontalSplit != uiSettings.getRightGorizontalSplit()) { JComponent component = getComponentAt(ToolWindowAnchor.RIGHT); if (component instanceof Splitter) { Splitter splitter = (Splitter)component; @@ -614,7 +615,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi ? first.getWindowInfo().getWeight() : first.getWindowInfo().getWeight() + second.getWindowInfo().getWeight()); } - myRightHorizontalSplit = UISettings.getInstance().RIGHT_HORIZONTAL_SPLIT; + myRightHorizontalSplit = uiSettings.getRightGorizontalSplit(); } } @@ -803,10 +804,10 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi @Override public void uiSettingsChanged(UISettings uiSettings) { if (anchor == ToolWindowAnchor.LEFT) { - setOrientation(!uiSettings.LEFT_HORIZONTAL_SPLIT); + setOrientation(!uiSettings.getLeftGorizontalSplit()); } else if (anchor == ToolWindowAnchor.RIGHT) { - setOrientation(!uiSettings.RIGHT_HORIZONTAL_SPLIT); + setOrientation(!uiSettings.getRightGorizontalSplit()); } } } @@ -819,14 +820,14 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi boolean isSplitterHorizontalNow = !splitter.isVertical(); UISettings settings = UISettings.getInstance(); if (anchor == ToolWindowAnchor.LEFT) { - if (settings.LEFT_HORIZONTAL_SPLIT != isSplitterHorizontalNow) { - settings.LEFT_HORIZONTAL_SPLIT = isSplitterHorizontalNow; + if (settings.getLeftGorizontalSplit() != isSplitterHorizontalNow) { + settings.setLeftGorizontalSplit(isSplitterHorizontalNow); settings.fireUISettingsChanged(); } } if (anchor == ToolWindowAnchor.RIGHT) { - if (settings.RIGHT_HORIZONTAL_SPLIT != isSplitterHorizontalNow) { - settings.RIGHT_HORIZONTAL_SPLIT = isSplitterHorizontalNow; + if (settings.getRightGorizontalSplit() != isSplitterHorizontalNow) { + settings.setRightGorizontalSplit(isSplitterHorizontalNow); settings.fireUISettingsChanged(); } } @@ -896,8 +897,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi public final void run() { try { // Show component. - final UISettings uiSettings = UISettings.getInstance(); - if (!myDirtyMode && uiSettings.getAnimateWindows() && !RemoteDesktopDetector.isRemoteSession()) { + if (!myDirtyMode && UISettings.getInstance().getAnimateWindows() && !RemoteDesktopDetector.isRemoteSession()) { // Prepare top image. This image is scrolling over bottom image. final Image topImage = myLayeredPane.getTopImage(); final Graphics topGraphics = topImage.getGraphics(); @@ -927,7 +927,7 @@ public final class ToolWindowsPane extends JBLayeredPane implements UISettingsLi bottomGraphics.dispose(); } // Start animation. - final Surface surface = new Surface(topImage, bottomImage, 1, myInfo.getAnchor(), uiSettings.ANIMATION_DURATION); + final Surface surface = new Surface(topImage, bottomImage, 1, myInfo.getAnchor(), UISettings.ANIMATION_DURATION); myLayeredPane.add(surface, JLayeredPane.PALETTE_LAYER); surface.setBounds(bounds); myLayeredPane.validate();