mirror of
https://github.com/igniterealtime/Spark.git
synced 2025-10-29 11:47:01 +00:00
SpellcheckChatRoomDecorator, SpellcheckerPreferenceDialog, LanguagePlugin: refactor usage of locale.getDisplayLanguage()
Add generics. Use for each. The locale.getDisplayLanguage will never return null and not needed to be trimmed.
This commit is contained in:
parent
0f6bf8565f
commit
0861b9252c
@ -84,9 +84,8 @@ public class LanguagePlugin implements Plugin {
|
||||
}
|
||||
};
|
||||
String label = locale.getDisplayLanguage(locale);
|
||||
if (locale.getDisplayCountry(locale) != null &&
|
||||
locale.getDisplayCountry(locale).trim().length() > 0) {
|
||||
label = label + "-" + locale.getDisplayCountry(locale).trim();
|
||||
if (!locale.getDisplayCountry(locale).isEmpty()) {
|
||||
label = label + "-" + locale.getDisplayCountry(locale);
|
||||
}
|
||||
action.putValue(Action.NAME, label);
|
||||
languageMenu.add(action);
|
||||
|
||||
@ -43,7 +43,7 @@ public class SpellcheckChatRoomDecorator implements ActionListener,
|
||||
private JTextComponentSpellChecker _sc;
|
||||
private RolloverButton _spellingButton;
|
||||
private ChatRoom _room;
|
||||
private JComboBox _languageSelection = new JComboBox();
|
||||
private JComboBox<String> _languageSelection = new JComboBox<>();
|
||||
private Map<String, String> _languages;
|
||||
|
||||
public SpellcheckChatRoomDecorator(ChatRoom room) {
|
||||
@ -141,26 +141,22 @@ public class SpellcheckChatRoomDecorator implements ActionListener,
|
||||
private void languagestoLocales()
|
||||
{
|
||||
String spellLanguage = SpellcheckManager.getInstance().getSpellcheckerPreference().getPreferences().getSpellLanguage();
|
||||
_languages = new HashMap<String, String>();
|
||||
_languages = new HashMap<>();
|
||||
Locale[] locales = Locale.getAvailableLocales();
|
||||
ArrayList<String> languages = SpellcheckManager.getInstance().getSupportedLanguages();
|
||||
for (int i = 0; i < languages.size(); i++) {
|
||||
for (String language : languages) {
|
||||
for (final Locale locale : locales) {
|
||||
if (locale.toString().equals(languages.get(i))) {
|
||||
String label = locale.getDisplayLanguage(Locale
|
||||
.getDefault());
|
||||
if (locale.getDisplayCountry(locale) != null
|
||||
&& locale.getDisplayCountry(locale).trim().length() > 0) {
|
||||
label = label + "-"
|
||||
+ locale.getDisplayCountry(locale).trim();
|
||||
if (locale.toString().equals(language)) {
|
||||
String label = locale.getDisplayLanguage(Locale.getDefault());
|
||||
if (!locale.getDisplayCountry(locale).isEmpty()) {
|
||||
label = label + "-" + locale.getDisplayCountry(locale);
|
||||
}
|
||||
_languages.put(label, languages.get(i));
|
||||
_languages.put(label, language);
|
||||
_languageSelection.addItem(label);
|
||||
if (languages.get(i).equals(spellLanguage))
|
||||
{
|
||||
if (language.equals(spellLanguage)) {
|
||||
_languageSelection.setSelectedItem(label);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class SpellcheckerPreferenceDialog extends JPanel implements
|
||||
|
||||
private JCheckBox spellcheckingEnabled;
|
||||
private JCheckBox autospellcheckingEnabled;
|
||||
private JComboBox spellLanguages;
|
||||
private JComboBox<String> spellLanguages;
|
||||
private JCheckBox ignoreCase;
|
||||
private JCheckBox showLanguages;
|
||||
private JPanel spellPanel;
|
||||
@ -52,7 +52,7 @@ public class SpellcheckerPreferenceDialog extends JPanel implements
|
||||
spellPanel = new JPanel();
|
||||
spellcheckingEnabled = new JCheckBox();
|
||||
autospellcheckingEnabled = new JCheckBox();
|
||||
spellLanguages = new JComboBox();
|
||||
spellLanguages = new JComboBox<>();
|
||||
showLanguages = new JCheckBox();
|
||||
spellPanel.setLayout(new GridBagLayout());
|
||||
|
||||
@ -72,20 +72,17 @@ public class SpellcheckerPreferenceDialog extends JPanel implements
|
||||
|
||||
// autospellcheckingEnabled.setText(SpellcheckerResource.getString("preference.autoSpellcheckingEnabled"));
|
||||
|
||||
for (int i = 0; i < languages.size(); i++) {
|
||||
for (final Locale locale : locales) {
|
||||
if (locale.toString().equals(languages.get(i))) {
|
||||
String label = locale.getDisplayLanguage(Locale
|
||||
.getDefault());
|
||||
if (locale.getDisplayCountry(locale) != null
|
||||
&& locale.getDisplayCountry(locale).trim().length() > 0) {
|
||||
label = label + "-"
|
||||
+ locale.getDisplayCountry(locale).trim();
|
||||
}
|
||||
spellLanguages.addItem(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String language : languages) {
|
||||
for (final Locale locale : locales) {
|
||||
if (locale.toString().equals(language)) {
|
||||
String label = locale.getDisplayLanguage(Locale.getDefault());
|
||||
if (!locale.getDisplayCountry(locale).isEmpty()) {
|
||||
label = label + "-" + locale.getDisplayCountry(locale);
|
||||
}
|
||||
spellLanguages.addItem(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spellPanel.add(spellcheckingEnabled, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||
spellPanel.add(autospellcheckingEnabled, new GridBagConstraints(0, 1, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user