1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-16 14:25:02 -05:00

* more easy-to-understand default values for the noobs

This commit is contained in:
Reinhard Pointner 2014-08-18 08:50:00 +00:00
parent cd924f5fc5
commit b6358fa466
2 changed files with 29 additions and 25 deletions

View File

@ -27,6 +27,7 @@ import java.text.Format;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.TreeMap;
@ -118,14 +119,7 @@ public class FormatDialog extends JDialog {
public Mode next() {
// cycle through Episode -> Movie -> Music (but ignore generic File mode)
switch (this) {
case Episode:
return Movie;
case Movie:
return Music;
default:
return Episode;
}
return values()[(this.ordinal() + 1) % File.ordinal()];
}
public String key() {
@ -152,6 +146,23 @@ public class FormatDialog extends JDialog {
public PreferencesList<String> persistentFormatHistory() {
return Settings.forPackage(FormatDialog.class).node("format.recent." + key()).asList();
}
public String getDefaultFormatExpression() {
return getSampleExpressions().iterator().next();
}
public Iterable<String> getSampleExpressions() {
ResourceBundle bundle = ResourceBundle.getBundle(FormatDialog.class.getName());
Map<String, String> examples = new TreeMap<String, String>();
// extract all example entries and sort by key
String prefix = key() + ".example";
for (String key : bundle.keySet()) {
if (key.startsWith(prefix))
examples.put(key, bundle.getString(key));
}
return examples.values();
}
}
public FormatDialog(Window owner, Mode initMode, MediaBindingBean lockOnBinding) {
@ -192,7 +203,9 @@ public class FormatDialog extends JDialog {
content.add(help, "growx, wrap 25px:push");
if (lockOnBinding == null) {
content.add(new JButton(switchEditModeAction), "tag left");
}
content.add(new JButton(approveFormatAction), "tag apply");
content.add(new JButton(cancelAction), "tag cancel");
@ -271,7 +284,7 @@ public class FormatDialog extends JDialog {
sample = bindings;
// restore editor state
setFormatCode(mode.persistentFormatHistory().isEmpty() ? "" : mode.persistentFormatHistory().get(0));
setFormatCode(mode.persistentFormatHistory().isEmpty() ? mode.getDefaultFormatExpression() : mode.persistentFormatHistory().get(0));
// update examples
fireSampleChanged();
@ -359,16 +372,7 @@ public class FormatDialog extends JDialog {
panel.setBorder(createLineBorder(new Color(0xACA899)));
panel.setBackground(new Color(0xFFFFE1));
ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName());
TreeMap<String, String> examples = new TreeMap<String, String>();
// extract all example entries and sort by key
for (String key : bundle.keySet()) {
if (key.startsWith(mode.key() + ".example"))
examples.put(key, bundle.getString(key));
}
for (final String format : examples.values()) {
for (final String format : mode.getSampleExpressions()) {
LinkButton formatLink = new LinkButton(new AbstractAction(format) {
@Override

View File

@ -10,10 +10,10 @@ episode.sample: {"@type":"net.filebot.web.Episode","seriesName":"Firefly","serie
movie.sample: {"@type":"net.filebot.web.MoviePart","partIndex":1,"partCount":2,"year":2009,"imdbId":-1,"tmdbId":19995,"name":"Avatar","aliasNames":[]}
music.sample: {"@type":"net.filebot.web.AudioTrack","artist":"Leona Lewis","title":"I See You","album":"Avatar","albumArtist":"James Horner","trackTitle":null,"albumReleaseDate":{"year":2009,"month":12,"day":11},"mediumIndex":1,"mediumCount":1,"trackIndex":14,"trackCount":14}
# basic 1.01
episode.example[0]: {n} - {s}.{e} - {t}
# S01E01
episode.example[1]: {n} - {sxe} - {t}
# 1x01
episode.example[0]: {n} - {sxe} - {t}
# S00E00
episode.example[1]: {n} - {s00e00} - {t}
# airdate
episode.example[2]: {n} [{airdate}] {t}
# uglyfy name
@ -23,7 +23,7 @@ episode.example[4]: {n}/{'Season '+s.pad(2)}/{s00e00} - {t}
# simple name/year
movie.example[0]: {n} ({y}){' CD'+pi}{'.'+lang}
# media info name
# name/year and media info
movie.example[1]: {n} ({y}, {director}) {vf} {af}
# name/year and ratings
movie.example[2]: {n} {[y, certification, rating]}