From c5d480b226e1e6cb9e4da0cc1f0c8f2f756daa0e Mon Sep 17 00:00:00 2001 From: Olga Strizhenko Date: Mon, 25 Dec 2017 15:00:08 +0300 Subject: [PATCH] Spellchecker: now dictionary panel is for bundled only --- .../settings/SpellCheckerSettingsPane.form | 2 +- .../settings/SpellCheckerSettingsPane.java | 46 ++++--------------- .../util/SpellCheckerBundle.properties | 4 +- 3 files changed, 12 insertions(+), 40 deletions(-) diff --git a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.form b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.form index 8a33412d3ba6..4f426acaae67 100644 --- a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.form +++ b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.form @@ -82,7 +82,7 @@ - + diff --git a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java index 70e4225ff062..fc797d43c750 100644 --- a/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java +++ b/spellchecker/src/com/intellij/spellchecker/settings/SpellCheckerSettingsPane.java @@ -50,7 +50,7 @@ public class SpellCheckerSettingsPane implements Disposable { private JPanel myPanelForCustomDictionaries; private OptionalChooserComponent myBundledDictionariesChooserComponent; private final CustomDictionariesPanel myDictionariesPanel; - private final List> allDictionaries = new ArrayList<>(); + private final List> bundledDictionaries = new ArrayList<>(); private final WordsPanel wordsPanel; private final SpellCheckerManager manager; private final SpellCheckerSettings settings; @@ -75,24 +75,16 @@ public class SpellCheckerSettingsPane implements Disposable { linkContainer.add(link); // Fill in all the dictionaries folders (not implemented yet) and enabled dictionaries - fillAllDictionaries(); + fillBundledDictionaries(); myDictionariesPanel = new CustomDictionariesPanel(settings, project); myPanelForCustomDictionaries.setLayout(new BorderLayout()); myPanelForCustomDictionaries.add(myDictionariesPanel, BorderLayout.CENTER); - myBundledDictionariesChooserComponent = new OptionalChooserComponent(allDictionaries) { + myBundledDictionariesChooserComponent = new OptionalChooserComponent(bundledDictionaries) { @Override public JCheckBox createCheckBox(String path, boolean checked) { - if (isUserDictionary(path)) { - path = FileUtil.toSystemIndependentName(path); - final int i = path.lastIndexOf('/'); - if (i != -1) { - final String name = path.substring(i + 1); - return new JCheckBox("[user] " + name, checked); - } - } - return new JCheckBox("[bundled] " + FileUtil.toSystemDependentName(path), checked); + return new JCheckBox(FileUtil.toSystemDependentName(path), checked); } }; @@ -126,48 +118,28 @@ public class SpellCheckerSettingsPane implements Disposable { myBundledDictionariesChooserComponent.apply(); myDictionariesPanel.apply(); - final HashSet disabledDictionaries = new HashSet<>(); final HashSet bundledDisabledDictionaries = new HashSet<>(); - for (Pair pair : allDictionaries) { + for (Pair pair : bundledDictionaries) { if (!pair.second) { - final String scriptPath = pair.first; - if (isUserDictionary(scriptPath)) { - disabledDictionaries.add(scriptPath); - } - else { - bundledDisabledDictionaries.add(scriptPath); - } + bundledDisabledDictionaries.add(pair.first); } } - settings.setDisabledDictionariesPaths(disabledDictionaries); settings.setBundledDisabledDictionariesPaths(bundledDisabledDictionaries); manager.updateBundledDictionaries(myDictionariesPanel.getRemovedDictionaries()); } - private boolean isUserDictionary(final String dictionary) { - boolean isUserDictionary = false; - for (String dictionaryFolder : myDictionariesPanel.getValues()) { - if (FileUtil.toSystemIndependentName(dictionary).startsWith(dictionaryFolder)) { - isUserDictionary = true; - break; - } - } - return isUserDictionary; - - } - public void reset() { myDictionariesPanel.reset(); myBundledDictionariesChooserComponent.reset(); } - private void fillAllDictionaries() { - allDictionaries.clear(); + private void fillBundledDictionaries() { + bundledDictionaries.clear(); for (String dictionary : SpellCheckerManager.getBundledDictionaries()) { - allDictionaries.add(Pair.create(dictionary, !settings.getBundledDisabledDictionariesPaths().contains(dictionary))); + bundledDictionaries.add(Pair.create(dictionary, !settings.getBundledDisabledDictionariesPaths().contains(dictionary))); } } diff --git a/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties b/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties index ad5fa58fbbd2..05e7c15f11a6 100644 --- a/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties +++ b/spellchecker/src/com/intellij/spellchecker/util/SpellCheckerBundle.properties @@ -27,8 +27,8 @@ link.to.inspection.settings=Configure 'Spelling' inspection exact.rename.to=Typo: Rename to ''{0}'' custom.dictionaries.title=Custom Dictionaries add.dictionary.description=Add custom dictionaries (plaintext word lists) -dictionaries.panel.title=Dictionaries -dictionaries.panel.description=Enable/disable dictionaries for your project +bundled.dictionaries.title=Bundled Dictionaries +dictionaries.panel.description=Enable/disable bundled dictionaries for your project custom.dictionary.title=Custom Dictionary add.custom.dictionaries=Add custom dictionaries edit.custom.dictionary=Edit custom dictionary