mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WI-53664 Simplify spellchecker settings: use global for words saving by default for projects with empty project dict
GitOrigin-RevId: ff990d94014927f370a9e81c87b90bc5dc540ed1
This commit is contained in:
committed by
intellij-monorepo-bot
parent
e0e3d5fb28
commit
8b18a9aabc
@@ -14,6 +14,7 @@
|
||||
overrides="true"/>
|
||||
<fileType name="Dictionary" implementationClass="com.intellij.spellchecker.DictionaryFileType" extensions="dic"/>
|
||||
<projectService serviceImplementation="com.intellij.spellchecker.settings.SpellCheckerSettings"/>
|
||||
<postStartupActivity implementation="com.intellij.spellchecker.settings.SettingsTransferActivity"/>
|
||||
<projectService serviceImplementation="com.intellij.spellchecker.SpellCheckerManager"/>
|
||||
<projectConfigurable parentId="proofread" instance="com.intellij.spellchecker.settings.SpellCheckerSettingsManager" id="reference.settings.ide.settings.spelling" key="spelling" bundle="messages.SpellCheckerBundle" />
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.spellchecker.settings;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.startup.StartupActivity;
|
||||
import com.intellij.spellchecker.state.ProjectDictionaryState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static com.intellij.spellchecker.SpellCheckerManager.DictionaryLevel.APP;
|
||||
import static com.intellij.spellchecker.SpellCheckerManager.DictionaryLevel.PROJECT;
|
||||
|
||||
public class SettingsTransferActivity implements StartupActivity {
|
||||
|
||||
@Override
|
||||
public void runActivity(@NotNull Project project) {
|
||||
final SpellCheckerSettings settings = SpellCheckerSettings.getInstance(project);
|
||||
if (!settings.isSettingsTransferred() && settings.isUseSingleDictionaryToSave() && PROJECT.getName().equals(settings.getDictionaryToSave())) {
|
||||
if (ServiceManager.getService(project, ProjectDictionaryState.class).getProjectDictionary().getWords().isEmpty()) {
|
||||
settings.setDictionaryToSave(APP.getName());
|
||||
settings.setSettingsTransferred(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
private static final String DEFAULT_DICTIONARY_TO_SAVE = SpellCheckerManager.DictionaryLevel.PROJECT.getName();
|
||||
private static final String USE_SINGLE_DICT_ATTR_NAME = "UseSingleDictionary";
|
||||
private static final boolean DEFAULT_USE_SINGLE_DICT = true;
|
||||
private static final String SETTINGS_TRANSFERRED = "transferred";
|
||||
|
||||
// Paths
|
||||
private final List<String> myOldDictionaryFoldersPaths = new ArrayList<>();
|
||||
@@ -49,6 +50,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
private Set<String> myRuntimeDisabledDictionariesNames = new HashSet<>();
|
||||
private String myDictionaryToSave = DEFAULT_DICTIONARY_TO_SAVE;
|
||||
private boolean myUseSingleDictionaryToSave = DEFAULT_USE_SINGLE_DICT;
|
||||
private boolean mySettingsTransferred = false;
|
||||
|
||||
public String getDictionaryToSave() {
|
||||
return myDictionaryToSave;
|
||||
@@ -66,6 +68,14 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
this.myUseSingleDictionaryToSave = useSingleDictionaryToSave;
|
||||
}
|
||||
|
||||
public boolean isSettingsTransferred() {
|
||||
return mySettingsTransferred;
|
||||
}
|
||||
|
||||
public void setSettingsTransferred(boolean settingsTransferred) {
|
||||
mySettingsTransferred = settingsTransferred;
|
||||
}
|
||||
|
||||
public static @NotNull SpellCheckerSettings getInstance(Project project) {
|
||||
return ServiceManager.getService(project, SpellCheckerSettings.class);
|
||||
}
|
||||
@@ -140,6 +150,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
}
|
||||
element.setAttribute(DICTIONARY_TO_SAVE_ATTR_NAME, myDictionaryToSave);
|
||||
element.setAttribute(USE_SINGLE_DICT_ATTR_NAME, String.valueOf(myUseSingleDictionaryToSave));
|
||||
element.setAttribute(SETTINGS_TRANSFERRED, String.valueOf(mySettingsTransferred));
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -187,6 +198,7 @@ public class SpellCheckerSettings implements PersistentStateComponent<Element> {
|
||||
myDictionaryToSave = notNullize(element.getAttributeValue(DICTIONARY_TO_SAVE_ATTR_NAME), DEFAULT_DICTIONARY_TO_SAVE);
|
||||
myUseSingleDictionaryToSave =
|
||||
Boolean.parseBoolean(notNullize(element.getAttributeValue(USE_SINGLE_DICT_ATTR_NAME), String.valueOf(DEFAULT_USE_SINGLE_DICT)));
|
||||
mySettingsTransferred = Boolean.parseBoolean(notNullize(element.getAttributeValue(SETTINGS_TRANSFERRED), "false"));
|
||||
}
|
||||
catch (Exception ignored) {
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user