* include 3-letter language codes in Language config file
This commit is contained in:
parent
e1409b5c30
commit
b9f76c407c
|
@ -1,4 +1,4 @@
|
||||||
package net.sourceforge.filebot.ui;
|
package net.sourceforge.filebot;
|
||||||
|
|
||||||
import static java.util.Arrays.*;
|
import static java.util.Arrays.*;
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
|
@ -12,16 +12,26 @@ import java.util.Set;
|
||||||
|
|
||||||
public class Language {
|
public class Language {
|
||||||
|
|
||||||
private final String code;
|
private final String iso2;
|
||||||
|
private final String iso3;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
public Language(String code, String name) {
|
public Language(String iso2, String iso3, String name) {
|
||||||
this.code = code;
|
this.iso2 = iso2;
|
||||||
|
this.iso3 = iso3;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCode() {
|
public String getCode() {
|
||||||
return code;
|
return iso2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getISO2() {
|
||||||
|
return iso2;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getISO3() {
|
||||||
|
return iso3;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -39,7 +49,7 @@ public class Language {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Language clone() {
|
public Language clone() {
|
||||||
return new Language(code, name);
|
return new Language(iso2, iso3, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Comparator<Language> ALPHABETIC_ORDER = new Comparator<Language>() {
|
public static final Comparator<Language> ALPHABETIC_ORDER = new Comparator<Language>() {
|
||||||
|
@ -54,12 +64,14 @@ public class Language {
|
||||||
ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName());
|
ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return new Language(code, bundle.getString(code + ".name"));
|
String[] values = bundle.getString(code).split("\\t", 2);
|
||||||
|
return new Language(code, values[0], values[1]);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (code == null || code.isEmpty()) {
|
if (code == null || code.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Language(code, new Locale(code).getDisplayLanguage(Locale.ROOT));
|
Locale locale = new Locale(code);
|
||||||
|
return new Language(locale.getLanguage(), locale.getISO3Language(), locale.getDisplayLanguage(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +86,16 @@ public class Language {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Language getLanguage(Locale locale) {
|
public static Language getLanguage(Locale locale) {
|
||||||
return locale == null ? null : getLanguageByName(locale.getDisplayLanguage(Locale.ENGLISH));
|
if (locale == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
String code = locale.getLanguage();
|
||||||
|
for (Language it : availableLanguages()) {
|
||||||
|
if (it.getISO2().equals(code) || it.getISO3().equals(code)) {
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Language getLanguageByName(String name) {
|
public static Language getLanguageByName(String name) {
|
||||||
|
@ -87,16 +108,11 @@ public class Language {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getISO3LanguageCodeByName(String languageName) {
|
public static String getISO3LanguageCodeByName(String languageName) {
|
||||||
Language language = Language.getLanguageByName(languageName);
|
try {
|
||||||
if (language != null) {
|
return Language.getLanguageByName(languageName).getISO3();
|
||||||
try {
|
} catch (Exception e) {
|
||||||
return new Locale(language.getCode()).getISO3Language();
|
return null;
|
||||||
} catch (Exception e) {
|
|
||||||
return language.getCode();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Language> availableLanguages() {
|
public static List<Language> availableLanguages() {
|
|
@ -0,0 +1,45 @@
|
||||||
|
# available languages
|
||||||
|
languages.all = sq,ar,hy,pb,bg,ca,zh,hr,cs,da,nl,en,et,fi,fr,de,el,he,hi,hu,id,it,ja,ko,lv,lt,mk,ms,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sv,th,tr,vi
|
||||||
|
languages.common = en,de,fr,es,pt,ru,ja,zh
|
||||||
|
sq: sqi Albanian
|
||||||
|
ar: ara Arabic
|
||||||
|
hy: hye Armenian
|
||||||
|
pb: pob Brazilian
|
||||||
|
bg: bul Bulgarian
|
||||||
|
ca: cat Catalan
|
||||||
|
zh: zho Chinese
|
||||||
|
hr: hrv Croatian
|
||||||
|
cs: ces Czech
|
||||||
|
da: dan Danish
|
||||||
|
nl: nld Dutch
|
||||||
|
en: eng English
|
||||||
|
et: est Estonian
|
||||||
|
fi: fin Finnish
|
||||||
|
fr: fra French
|
||||||
|
de: deu German
|
||||||
|
el: ell Greek
|
||||||
|
he: heb Hebrew
|
||||||
|
hi: hin Hindi
|
||||||
|
hu: hun Hungarian
|
||||||
|
id: ind Indonesian
|
||||||
|
it: ita Italian
|
||||||
|
ja: jpn Japanese
|
||||||
|
ko: kor Korean
|
||||||
|
lv: lav Latvian
|
||||||
|
lt: lit Lithuanian
|
||||||
|
mk: mkd Macedonian
|
||||||
|
ms: msa Malay
|
||||||
|
no: nor Norwegian
|
||||||
|
fa: fas Persian
|
||||||
|
pl: pol Polish
|
||||||
|
pt: por Portuguese
|
||||||
|
ro: ron Romanian
|
||||||
|
ru: rus Russian
|
||||||
|
sr: srp Serbian
|
||||||
|
sk: slk Slovak
|
||||||
|
sl: slv Slovenian
|
||||||
|
es: spa Spanish
|
||||||
|
sv: swe Swedish
|
||||||
|
th: tha Thai
|
||||||
|
tr: tur Turkish
|
||||||
|
vi: vie Vietnamese
|
|
@ -57,7 +57,7 @@ import net.sourceforge.filebot.similarity.SeriesNameMatcher;
|
||||||
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
import net.sourceforge.filebot.similarity.SimilarityComparator;
|
||||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||||
import net.sourceforge.filebot.subtitle.SubtitleFormat;
|
import net.sourceforge.filebot.subtitle.SubtitleFormat;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.vfs.MemoryFile;
|
import net.sourceforge.filebot.vfs.MemoryFile;
|
||||||
import net.sourceforge.filebot.web.AudioTrack;
|
import net.sourceforge.filebot.web.AudioTrack;
|
||||||
import net.sourceforge.filebot.web.Episode;
|
import net.sourceforge.filebot.web.Episode;
|
||||||
|
|
|
@ -33,7 +33,7 @@ import net.sourceforge.filebot.similarity.MetricCascade;
|
||||||
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
|
import net.sourceforge.filebot.similarity.NameSimilarityMetric;
|
||||||
import net.sourceforge.filebot.similarity.SequenceMatchSimilarity;
|
import net.sourceforge.filebot.similarity.SequenceMatchSimilarity;
|
||||||
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
import net.sourceforge.filebot.similarity.SimilarityMetric;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.vfs.ArchiveType;
|
import net.sourceforge.filebot.vfs.ArchiveType;
|
||||||
import net.sourceforge.filebot.vfs.MemoryFile;
|
import net.sourceforge.filebot.vfs.MemoryFile;
|
||||||
import net.sourceforge.filebot.web.SearchResult;
|
import net.sourceforge.filebot.web.SearchResult;
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
# available languages
|
|
||||||
languages.all = sq,ar,hy,pb,bg,ca,zh,hr,cs,da,nl,en,et,fi,fr,de,el,he,hi,hu,id,it,ja,ko,lv,lt,mk,ms,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sv,th,tr,vi
|
|
||||||
languages.common = en,de,fr,es,pt,ru,ja,zh
|
|
||||||
sq.name: Albanian
|
|
||||||
ar.name: Arabic
|
|
||||||
hy.name: Armenian
|
|
||||||
pb.name: Brazilian
|
|
||||||
bg.name: Bulgarian
|
|
||||||
ca.name: Catalan
|
|
||||||
zh.name: Chinese
|
|
||||||
hr.name: Croatian
|
|
||||||
cs.name: Czech
|
|
||||||
da.name: Danish
|
|
||||||
nl.name: Dutch
|
|
||||||
en.name: English
|
|
||||||
et.name: Estonian
|
|
||||||
fi.name: Finnish
|
|
||||||
fr.name: French
|
|
||||||
de.name: German
|
|
||||||
el.name: Greek
|
|
||||||
he.name: Hebrew
|
|
||||||
hi.name: Hindi
|
|
||||||
hu.name: Hungarian
|
|
||||||
id.name: Indonesian
|
|
||||||
it.name: Italian
|
|
||||||
ja.name: Japanese
|
|
||||||
ko.name: Korean
|
|
||||||
lv.name: Latvian
|
|
||||||
lt.name: Lithuanian
|
|
||||||
mk.name: Macedonian
|
|
||||||
ms.name: Malay
|
|
||||||
no.name: Norwegian
|
|
||||||
fa.name: Persian
|
|
||||||
pl.name: Polish
|
|
||||||
pt.name: Portuguese
|
|
||||||
ro.name: Romanian
|
|
||||||
ru.name: Russian
|
|
||||||
sr.name: Serbian
|
|
||||||
sk.name: Slovak
|
|
||||||
sl.name: Slovenian
|
|
||||||
es.name: Spanish
|
|
||||||
sv.name: Swedish
|
|
||||||
th.name: Thai
|
|
||||||
tr.name: Turkish
|
|
||||||
vi.name: Vietnamese
|
|
|
@ -1,7 +1,7 @@
|
||||||
package net.sourceforge.filebot.ui;
|
package net.sourceforge.filebot.ui;
|
||||||
|
|
||||||
import static java.awt.event.ItemEvent.*;
|
import static java.awt.event.ItemEvent.*;
|
||||||
import static net.sourceforge.filebot.ui.Language.*;
|
import static net.sourceforge.filebot.Language.*;
|
||||||
|
|
||||||
import java.awt.event.ItemEvent;
|
import java.awt.event.ItemEvent;
|
||||||
import java.awt.event.ItemListener;
|
import java.awt.event.ItemListener;
|
||||||
|
@ -16,6 +16,7 @@ import javax.swing.JComboBox;
|
||||||
import javax.swing.event.PopupMenuEvent;
|
import javax.swing.event.PopupMenuEvent;
|
||||||
import javax.swing.event.PopupMenuListener;
|
import javax.swing.event.PopupMenuListener;
|
||||||
|
|
||||||
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.Settings;
|
import net.sourceforge.filebot.Settings;
|
||||||
|
|
||||||
public class LanguageComboBox extends JComboBox {
|
public class LanguageComboBox extends JComboBox {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.ui;
|
package net.sourceforge.filebot.ui;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
|
|
||||||
|
@ -12,10 +10,10 @@ import javax.swing.border.Border;
|
||||||
import javax.swing.border.CompoundBorder;
|
import javax.swing.border.CompoundBorder;
|
||||||
import javax.swing.border.EmptyBorder;
|
import javax.swing.border.EmptyBorder;
|
||||||
|
|
||||||
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.tuned.ui.DashedSeparator;
|
import net.sourceforge.tuned.ui.DashedSeparator;
|
||||||
|
|
||||||
|
|
||||||
public class LanguageComboBoxCellRenderer implements ListCellRenderer {
|
public class LanguageComboBoxCellRenderer implements ListCellRenderer {
|
||||||
|
|
||||||
private Border padding = new EmptyBorder(2, 2, 2, 2);
|
private Border padding = new EmptyBorder(2, 2, 2, 2);
|
||||||
|
@ -24,13 +22,11 @@ public class LanguageComboBoxCellRenderer implements ListCellRenderer {
|
||||||
|
|
||||||
private ListCellRenderer base;
|
private ListCellRenderer base;
|
||||||
|
|
||||||
|
|
||||||
public LanguageComboBoxCellRenderer(final ListCellRenderer base) {
|
public LanguageComboBoxCellRenderer(final ListCellRenderer base) {
|
||||||
this.base = base;
|
this.base = base;
|
||||||
this.padding = new CompoundBorder(padding, ((JLabel) base).getBorder());
|
this.padding = new CompoundBorder(padding, ((JLabel) base).getBorder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
JLabel c = (JLabel) base.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
JLabel c = (JLabel) base.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package net.sourceforge.filebot.ui;
|
package net.sourceforge.filebot.ui;
|
||||||
|
|
||||||
import static net.sourceforge.filebot.ui.Language.*;
|
import static net.sourceforge.filebot.Language.*;
|
||||||
|
|
||||||
import java.util.AbstractList;
|
import java.util.AbstractList;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -10,9 +10,11 @@ import java.util.Set;
|
||||||
import javax.swing.AbstractListModel;
|
import javax.swing.AbstractListModel;
|
||||||
import javax.swing.ComboBoxModel;
|
import javax.swing.ComboBoxModel;
|
||||||
|
|
||||||
|
import net.sourceforge.filebot.Language;
|
||||||
|
|
||||||
public class LanguageComboBoxModel extends AbstractListModel implements ComboBoxModel {
|
public class LanguageComboBoxModel extends AbstractListModel implements ComboBoxModel {
|
||||||
|
|
||||||
public static final Language ALL_LANGUAGES = new Language("undefined", "All Languages");
|
public static final Language ALL_LANGUAGES = new Language("", "", "All Languages");
|
||||||
|
|
||||||
private Language defaultLanguage;
|
private Language defaultLanguage;
|
||||||
private Language selection;
|
private Language selection;
|
||||||
|
|
|
@ -32,7 +32,7 @@ import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
||||||
import net.sourceforge.filebot.ui.FileBotList;
|
import net.sourceforge.filebot.ui.FileBotList;
|
||||||
import net.sourceforge.filebot.ui.FileBotListExportHandler;
|
import net.sourceforge.filebot.ui.FileBotListExportHandler;
|
||||||
import net.sourceforge.filebot.ui.FileBotTab;
|
import net.sourceforge.filebot.ui.FileBotTab;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.ui.LanguageComboBox;
|
import net.sourceforge.filebot.ui.LanguageComboBox;
|
||||||
import net.sourceforge.filebot.ui.SelectDialog;
|
import net.sourceforge.filebot.ui.SelectDialog;
|
||||||
import net.sourceforge.filebot.ui.transfer.ArrayTransferable;
|
import net.sourceforge.filebot.ui.transfer.ArrayTransferable;
|
||||||
|
|
|
@ -53,7 +53,7 @@ import net.sourceforge.filebot.StandardRenameAction;
|
||||||
import net.sourceforge.filebot.WebServices;
|
import net.sourceforge.filebot.WebServices;
|
||||||
import net.sourceforge.filebot.format.MediaBindingBean;
|
import net.sourceforge.filebot.format.MediaBindingBean;
|
||||||
import net.sourceforge.filebot.similarity.Match;
|
import net.sourceforge.filebot.similarity.Match;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.ui.rename.FormatDialog.Mode;
|
import net.sourceforge.filebot.ui.rename.FormatDialog.Mode;
|
||||||
import net.sourceforge.filebot.ui.rename.RenameModel.FormattedFuture;
|
import net.sourceforge.filebot.ui.rename.RenameModel.FormattedFuture;
|
||||||
import net.sourceforge.filebot.web.AudioTrack;
|
import net.sourceforge.filebot.web.AudioTrack;
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.ui.subtitle;
|
package net.sourceforge.filebot.ui.subtitle;
|
||||||
|
|
||||||
|
|
||||||
import static java.util.Collections.*;
|
import static java.util.Collections.*;
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
|
|
||||||
|
@ -20,14 +18,13 @@ import java.util.ResourceBundle;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.event.SwingPropertyChangeSupport;
|
import javax.swing.event.SwingPropertyChangeSupport;
|
||||||
|
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.vfs.ArchiveType;
|
import net.sourceforge.filebot.vfs.ArchiveType;
|
||||||
import net.sourceforge.filebot.vfs.MemoryFile;
|
import net.sourceforge.filebot.vfs.MemoryFile;
|
||||||
import net.sourceforge.filebot.web.SubtitleDescriptor;
|
import net.sourceforge.filebot.web.SubtitleDescriptor;
|
||||||
import net.sourceforge.filebot.web.SubtitleProvider;
|
import net.sourceforge.filebot.web.SubtitleProvider;
|
||||||
import net.sourceforge.tuned.FileUtilities;
|
import net.sourceforge.tuned.FileUtilities;
|
||||||
|
|
||||||
|
|
||||||
public class SubtitlePackage {
|
public class SubtitlePackage {
|
||||||
|
|
||||||
private final SubtitleProvider provider;
|
private final SubtitleProvider provider;
|
||||||
|
@ -35,13 +32,12 @@ public class SubtitlePackage {
|
||||||
private final Language language;
|
private final Language language;
|
||||||
private Download download;
|
private Download download;
|
||||||
|
|
||||||
|
|
||||||
public SubtitlePackage(SubtitleProvider provider, SubtitleDescriptor subtitle) {
|
public SubtitlePackage(SubtitleProvider provider, SubtitleDescriptor subtitle) {
|
||||||
this.provider = provider;
|
this.provider = provider;
|
||||||
this.subtitle = subtitle;
|
this.subtitle = subtitle;
|
||||||
|
|
||||||
// resolve language name
|
// resolve language name
|
||||||
this.language = new Language(languageCodeByName.get(subtitle.getLanguageName()), subtitle.getLanguageName());
|
this.language = new Language(languageCodeByName.get(subtitle.getLanguageName()), Language.getISO3LanguageCodeByName(subtitle.getLanguageName()), subtitle.getLanguageName());
|
||||||
|
|
||||||
// initialize download worker
|
// initialize download worker
|
||||||
download = new Download(subtitle);
|
download = new Download(subtitle);
|
||||||
|
@ -58,32 +54,26 @@ public class SubtitlePackage {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SubtitleProvider getProvider() {
|
public SubtitleProvider getProvider() {
|
||||||
return provider;
|
return provider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return subtitle.getName();
|
return subtitle.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Language getLanguage() {
|
public Language getLanguage() {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return subtitle.getType();
|
return subtitle.getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Download getDownload() {
|
public Download getDownload() {
|
||||||
return download;
|
return download;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
// cancel old download
|
// cancel old download
|
||||||
download.cancel(false);
|
download.cancel(false);
|
||||||
|
@ -101,47 +91,35 @@ public class SubtitlePackage {
|
||||||
pcs.firePropertyChange("download.phase", old.getPhase(), download.getPhase());
|
pcs.firePropertyChange("download.phase", old.getPhase(), download.getPhase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return subtitle.getName();
|
return subtitle.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final PropertyChangeSupport pcs = new SwingPropertyChangeSupport(this, true);
|
private final PropertyChangeSupport pcs = new SwingPropertyChangeSupport(this, true);
|
||||||
|
|
||||||
|
|
||||||
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
public void addPropertyChangeListener(PropertyChangeListener listener) {
|
||||||
pcs.addPropertyChangeListener(listener);
|
pcs.addPropertyChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
public void removePropertyChangeListener(PropertyChangeListener listener) {
|
||||||
pcs.removePropertyChangeListener(listener);
|
pcs.removePropertyChangeListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class Download extends SwingWorker<List<MemoryFile>, Void> {
|
public static class Download extends SwingWorker<List<MemoryFile>, Void> {
|
||||||
|
|
||||||
enum Phase {
|
enum Phase {
|
||||||
PENDING,
|
PENDING, WAITING, DOWNLOADING, EXTRACTING, DONE
|
||||||
WAITING,
|
|
||||||
DOWNLOADING,
|
|
||||||
EXTRACTING,
|
|
||||||
DONE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private final SubtitleDescriptor subtitle;
|
private final SubtitleDescriptor subtitle;
|
||||||
|
|
||||||
private Phase current = Phase.PENDING;
|
private Phase current = Phase.PENDING;
|
||||||
|
|
||||||
|
|
||||||
private Download(SubtitleDescriptor descriptor) {
|
private Download(SubtitleDescriptor descriptor) {
|
||||||
this.subtitle = descriptor;
|
this.subtitle = descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
setPhase(Phase.WAITING);
|
setPhase(Phase.WAITING);
|
||||||
|
|
||||||
|
@ -149,7 +127,6 @@ public class SubtitlePackage {
|
||||||
execute();
|
execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<MemoryFile> doInBackground() throws Exception {
|
protected List<MemoryFile> doInBackground() throws Exception {
|
||||||
setPhase(Phase.DOWNLOADING);
|
setPhase(Phase.DOWNLOADING);
|
||||||
|
@ -186,7 +163,6 @@ public class SubtitlePackage {
|
||||||
return vfs;
|
return vfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<MemoryFile> extract(ArchiveType archiveType, ByteBuffer data) throws IOException {
|
private List<MemoryFile> extract(ArchiveType archiveType, ByteBuffer data) throws IOException {
|
||||||
List<MemoryFile> vfs = new ArrayList<MemoryFile>();
|
List<MemoryFile> vfs = new ArrayList<MemoryFile>();
|
||||||
|
|
||||||
|
@ -208,13 +184,11 @@ public class SubtitlePackage {
|
||||||
return vfs;
|
return vfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
setPhase(Phase.DONE);
|
setPhase(Phase.DONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setPhase(Phase phase) {
|
private void setPhase(Phase phase) {
|
||||||
Phase old = current;
|
Phase old = current;
|
||||||
current = phase;
|
current = phase;
|
||||||
|
@ -222,24 +196,20 @@ public class SubtitlePackage {
|
||||||
firePropertyChange("phase", old, phase);
|
firePropertyChange("phase", old, phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isStarted() {
|
public boolean isStarted() {
|
||||||
return current != Phase.PENDING;
|
return current != Phase.PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Phase getPhase() {
|
public Phase getPhase() {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map english language name to language code.
|
* Map english language name to language code.
|
||||||
*/
|
*/
|
||||||
private static final Map<String, String> languageCodeByName = mapLanguageCodeByName();
|
private static final Map<String, String> languageCodeByName = mapLanguageCodeByName();
|
||||||
|
|
||||||
|
|
||||||
private static Map<String, String> mapLanguageCodeByName() {
|
private static Map<String, String> mapLanguageCodeByName() {
|
||||||
ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName(), Locale.ENGLISH);
|
ResourceBundle bundle = ResourceBundle.getBundle(Language.class.getName(), Locale.ENGLISH);
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.Settings;
|
import net.sourceforge.filebot.Settings;
|
||||||
import net.sourceforge.filebot.WebServices;
|
import net.sourceforge.filebot.WebServices;
|
||||||
import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
import net.sourceforge.filebot.ui.AbstractSearchPanel;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.ui.LanguageComboBox;
|
import net.sourceforge.filebot.ui.LanguageComboBox;
|
||||||
import net.sourceforge.filebot.ui.SelectDialog;
|
import net.sourceforge.filebot.ui.SelectDialog;
|
||||||
import net.sourceforge.filebot.web.OpenSubtitlesClient;
|
import net.sourceforge.filebot.web.OpenSubtitlesClient;
|
||||||
|
|
|
@ -52,7 +52,7 @@ import net.miginfocom.swing.MigLayout;
|
||||||
import net.sourceforge.filebot.Analytics;
|
import net.sourceforge.filebot.Analytics;
|
||||||
import net.sourceforge.filebot.ResourceManager;
|
import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.media.MediaDetection;
|
import net.sourceforge.filebot.media.MediaDetection;
|
||||||
import net.sourceforge.filebot.ui.Language;
|
import net.sourceforge.filebot.Language;
|
||||||
import net.sourceforge.filebot.ui.LanguageComboBox;
|
import net.sourceforge.filebot.ui.LanguageComboBox;
|
||||||
import net.sourceforge.filebot.ui.SelectDialog;
|
import net.sourceforge.filebot.ui.SelectDialog;
|
||||||
import net.sourceforge.filebot.web.Movie;
|
import net.sourceforge.filebot.web.Movie;
|
||||||
|
@ -423,7 +423,7 @@ public class SubtitleUploadDialog extends JDialog {
|
||||||
icon = ResourceManager.getIcon("database.ok");
|
icon = ResourceManager.getIcon("database.ok");
|
||||||
break;
|
break;
|
||||||
case Identifying:
|
case Identifying:
|
||||||
text = "Auto-detect missing information";
|
text = "Auto-detecting missing information";
|
||||||
icon = ResourceManager.getIcon("action.export");
|
icon = ResourceManager.getIcon("action.export");
|
||||||
break;
|
break;
|
||||||
case IdentificationRequired:
|
case IdentificationRequired:
|
||||||
|
|
Loading…
Reference in New Issue