OC-15178 Automatically set some settings when user selects Xcode behaviour [Move everything to a single component, fix all the problems with default states, move manualOrder to global settings, change logic of setting autoscrollToSource to the modern one]

This commit is contained in:
Stanislav Dombrovsky
2017-11-09 17:19:12 +03:00
parent 1480def142
commit 296f0a37c6
6 changed files with 74 additions and 27 deletions
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.ui
import com.intellij.ide.WelcomeWizardUtil
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.*
@@ -127,23 +126,6 @@ class UISettings : BaseState(), PersistentStateComponent<UISettings> {
private val myTreeDispatcher = ComponentTreeEventDispatcher.create(UISettingsListener::class.java)
init {
WelcomeWizardUtil.getAutoScrollToSource()?.let {
defaultAutoScrollToSource = it
}
WelcomeWizardUtil.getTabsPlacement()?.let {
editorTabPlacement = it
}
WelcomeWizardUtil.getAppearanceFontSize()?.let {
overrideLafFonts = true
fontSize = it
}
WelcomeWizardUtil.getAppearanceFontFace()?.let {
overrideLafFonts = true
fontFace = it
}
}
private fun withDefFont(): UISettings {
initDefFont()
return this
@@ -16,7 +16,6 @@
package com.intellij.codeInsight;
import com.intellij.codeInsight.editorActions.SmartBackspaceMode;
import com.intellij.ide.WelcomeWizardUtil;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
@@ -62,10 +61,6 @@ public class CodeInsightSettings implements PersistentStateComponent<Element>, C
Registry.get("java.completion.argument.hints").setValue(false);
Registry.get("java.completion.argument.hints.internal").setValue(false);
}
if (WelcomeWizardUtil.getCompletionCaseSensitive() != null) {
//noinspection MagicConstant
COMPLETION_CASE_SENSITIVE = WelcomeWizardUtil.getCompletionCaseSensitive();
}
}
@Override
@@ -0,0 +1,62 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.ide.customize
import com.intellij.codeInsight.CodeInsightSettings
import com.intellij.ide.WelcomeWizardUtil
import com.intellij.ide.projectView.impl.ProjectViewSharedSettings
import com.intellij.ide.ui.LafManager
import com.intellij.ide.ui.UISettings
import com.intellij.lang.Language
import com.intellij.openapi.components.ApplicationComponent
import com.intellij.psi.codeStyle.*
class WelcomeWizardHelper : ApplicationComponent {
override fun initComponent() {
//Project View settings
WelcomeWizardUtil.getAutoScrollToSource()?.let {
ProjectViewSharedSettings.instance.autoscrollToSource = it
}
WelcomeWizardUtil.getManualOrder()?.let {
ProjectViewSharedSettings.instance.manualOrder = it
}
//Code insight settings
WelcomeWizardUtil.getCompletionCaseSensitive()?.let {
CodeInsightSettings.getInstance().COMPLETION_CASE_SENSITIVE = it
}
//Code style settings
WelcomeWizardUtil.getContinuationIndent()?.let {
Language.getRegisteredLanguages()
.map { CodeStyleSettingsManager.getInstance().currentSettings.getIndentOptions(it.associatedFileType) }
.filter { it.CONTINUATION_INDENT_SIZE > WelcomeWizardUtil.getContinuationIndent() }
.forEach { it.CONTINUATION_INDENT_SIZE = WelcomeWizardUtil.getContinuationIndent() }
}
//UI settings
WelcomeWizardUtil.getTabsPlacement()?.let {
UISettings.instance.editorTabPlacement = it
}
WelcomeWizardUtil.getAppearanceFontSize()?.let {
UISettings.instance.overrideLafFonts = true
UISettings.instance.fontSize = 12
}
WelcomeWizardUtil.getAppearanceFontFace()?.let {
UISettings.instance.overrideLafFonts = true
UISettings.instance.fontFace = it
}
LafManager.getInstance().updateUI()
}
}
@@ -94,7 +94,6 @@ import com.intellij.util.ui.UIUtil;
import com.intellij.util.ui.tree.TreeUtil;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import org.apache.commons.lang.BooleanUtils;
import org.jdom.Attribute;
import org.jdom.Element;
import org.jetbrains.annotations.NonNls;
@@ -125,7 +124,7 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
private final Map<String, Boolean> myShowMembers = new THashMap<>();
private static final boolean ourShowMembersDefaults = false;
private final Map<String, Boolean> myManualOrder = new THashMap<>();
private static final boolean ourManualOrderDefaults = BooleanUtils.toBooleanDefaultIfNull(WelcomeWizardUtil.getManualOrder(), false);
private static final boolean ourManualOrderDefaults = false;
private final Map<String, Boolean> mySortByType = new THashMap<>();
private static final boolean ourSortByTypeDefaults = false;
private final Map<String, Boolean> myShowModules = new THashMap<>();
@@ -1913,11 +1912,17 @@ public class ProjectViewImpl extends ProjectView implements PersistentStateCompo
@Override
public boolean isManualOrder(String paneId) {
if (isGlobalOptions()) {
return getGlobalOptions().getManualOrder();
}
return getPaneOptionValue(myManualOrder, paneId, ourManualOrderDefaults);
}
@Override
public void setManualOrder(@NotNull String paneId, final boolean enabled) {
if (isGlobalOptions()) {
getGlobalOptions().setAutoscrollToSource(enabled);
}
setPaneOption(myManualOrder, enabled, paneId, false);
final AbstractProjectViewPane pane = getProjectViewPaneById(paneId);
pane.installComparator();
@@ -15,7 +15,6 @@
*/
package com.intellij.ide.projectView.impl
import com.intellij.ide.ui.UISettings
import com.intellij.openapi.components.PersistentStateComponent
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.components.State
@@ -37,8 +36,9 @@ class ProjectViewSharedSettings : PersistentStateComponent<ProjectViewSharedSett
var hideEmptyPackages = true
var abbreviatePackages = false
var autoscrollFromSource = false
var autoscrollToSource = UISettings.instance.defaultAutoScrollToSource
var autoscrollToSource = false
var foldersAlwaysOnTop = true
var manualOrder = false
override fun getState(): ProjectViewSharedSettings? {
return this
@@ -145,6 +145,9 @@
<interface-class>org.jetbrains.ide.BuiltInServerManager</interface-class>
<implementation-class>org.jetbrains.ide.BuiltInServerManagerImpl</implementation-class>
</component>
<component>
<implementation-class>com.intellij.ide.customize.WelcomeWizardHelper</implementation-class>
</component>
</application-components>
<project-components>