diff --git a/source/net/filebot/ui/rename/FormatDialog.java b/source/net/filebot/ui/rename/FormatDialog.java index 522ad23e..f062aa12 100644 --- a/source/net/filebot/ui/rename/FormatDialog.java +++ b/source/net/filebot/ui/rename/FormatDialog.java @@ -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 persistentFormatHistory() { return Settings.forPackage(FormatDialog.class).node("format.recent." + key()).asList(); } + + public String getDefaultFormatExpression() { + return getSampleExpressions().iterator().next(); + } + + public Iterable getSampleExpressions() { + ResourceBundle bundle = ResourceBundle.getBundle(FormatDialog.class.getName()); + Map examples = new TreeMap(); + + // 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"); - content.add(new JButton(switchEditModeAction), "tag left"); + 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 examples = new TreeMap(); - - // 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 diff --git a/source/net/filebot/ui/rename/FormatDialog.properties b/source/net/filebot/ui/rename/FormatDialog.properties index a1aa10c3..c709f690 100644 --- a/source/net/filebot/ui/rename/FormatDialog.properties +++ b/source/net/filebot/ui/rename/FormatDialog.properties @@ -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]}