From 0b69adbbc93859be433d72c63216dceb62802b35 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Tue, 10 Nov 2015 13:13:37 +0000 Subject: [PATCH] * Fix: PresetEditor doesn't restore Language combo box @see https://www.filebot.net/forums/viewtopic.php?f=6&t=3164 --- source/net/filebot/ui/rename/Preset.java | 4 ++-- source/net/filebot/ui/rename/PresetEditor.java | 11 +++++++++++ source/net/filebot/ui/rename/RenamePanel.java | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/net/filebot/ui/rename/Preset.java b/source/net/filebot/ui/rename/Preset.java index d6e8aab4..1be1733d 100644 --- a/source/net/filebot/ui/rename/Preset.java +++ b/source/net/filebot/ui/rename/Preset.java @@ -145,8 +145,8 @@ public class Preset { } } - public Locale getLanguage() { - return language == null || language.isEmpty() ? null : new Locale(language); + public Language getLanguage() { + return language == null || language.isEmpty() ? null : Language.getLanguage(language); } public StandardRenameAction getRenameAction() { diff --git a/source/net/filebot/ui/rename/PresetEditor.java b/source/net/filebot/ui/rename/PresetEditor.java index 618fae13..9b637a22 100644 --- a/source/net/filebot/ui/rename/PresetEditor.java +++ b/source/net/filebot/ui/rename/PresetEditor.java @@ -12,6 +12,7 @@ import java.awt.event.ActionEvent; import java.io.File; import java.util.EnumSet; import java.util.List; +import java.util.Locale; import java.util.logging.Level; import javax.swing.AbstractAction; @@ -169,6 +170,16 @@ public class PresetEditor extends JDialog { matchModeCombo.setSelectedItem(p.getMatchMode() == null ? RenamePanel.MATCH_MODE_OPPORTUNISTIC : p.getMatchMode()); actionCombo.setSelectedItem(p.getRenameAction() == null ? StandardRenameAction.MOVE : p.getRenameAction()); + // ugly hack, since Language objects only do object equality + if (p.getLanguage() != null && !p.getLanguage().getCode().equals(((Language) languageCombo.getSelectedItem()).getCode())) { + for (int i = 0; i < languageCombo.getModel().getSize(); i++) { + if (p.getLanguage().getCode().equals(languageCombo.getModel().getElementAt(i).getCode())) { + languageCombo.setSelectedIndex(i); + break; + } + } + } + selectRadio.setSelected(p.getInputFolder() != null); updateComponentStates(); } diff --git a/source/net/filebot/ui/rename/RenamePanel.java b/source/net/filebot/ui/rename/RenamePanel.java index b461f24c..8e5676a5 100644 --- a/source/net/filebot/ui/rename/RenamePanel.java +++ b/source/net/filebot/ui/rename/RenamePanel.java @@ -722,7 +722,7 @@ public class RenamePanel extends JComponent { @Override public Locale getLocale(ActionEvent evt) { - return preset.getLanguage() != null ? preset.getLanguage() : super.getLocale(evt); + return preset.getLanguage() != null ? preset.getLanguage().getLocale() : super.getLocale(evt); } @Override