mirror of
https://github.com/mitb-archive/filebot
synced 2024-11-16 14:25:02 -05:00
* more messages to help users know what to do next if they're just clicking around trying to figure out things work
This commit is contained in:
parent
a054f08946
commit
20aef4e385
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
package net.sourceforge.filebot.ui.rename;
|
package net.sourceforge.filebot.ui.rename;
|
||||||
|
|
||||||
|
|
||||||
import static javax.swing.JOptionPane.*;
|
import static javax.swing.JOptionPane.*;
|
||||||
import static javax.swing.SwingUtilities.*;
|
import static javax.swing.SwingUtilities.*;
|
||||||
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
||||||
@ -71,71 +69,69 @@ import ca.odell.glazedlists.EventList;
|
|||||||
import ca.odell.glazedlists.ListSelection;
|
import ca.odell.glazedlists.ListSelection;
|
||||||
import ca.odell.glazedlists.swing.EventSelectionModel;
|
import ca.odell.glazedlists.swing.EventSelectionModel;
|
||||||
|
|
||||||
|
|
||||||
public class RenamePanel extends JComponent {
|
public class RenamePanel extends JComponent {
|
||||||
|
|
||||||
protected final RenameModel renameModel = new RenameModel();
|
protected final RenameModel renameModel = new RenameModel();
|
||||||
|
|
||||||
protected final RenameList<FormattedFuture> namesList = new RenameList<FormattedFuture>(renameModel.names());
|
protected final RenameList<FormattedFuture> namesList = new RenameList<FormattedFuture>(renameModel.names());
|
||||||
|
|
||||||
protected final RenameList<File> filesList = new RenameList<File>(renameModel.files());
|
protected final RenameList<File> filesList = new RenameList<File>(renameModel.files());
|
||||||
|
|
||||||
protected final MatchAction matchAction = new MatchAction(renameModel);
|
protected final MatchAction matchAction = new MatchAction(renameModel);
|
||||||
|
|
||||||
protected final RenameAction renameAction = new RenameAction(renameModel);
|
protected final RenameAction renameAction = new RenameAction(renameModel);
|
||||||
|
|
||||||
private static final PreferencesEntry<String> persistentEpisodeFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.episode");
|
private static final PreferencesEntry<String> persistentEpisodeFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.episode");
|
||||||
private static final PreferencesEntry<String> persistentMovieFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.movie");
|
private static final PreferencesEntry<String> persistentMovieFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.movie");
|
||||||
private static final PreferencesEntry<String> persistentMusicFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.music");
|
private static final PreferencesEntry<String> persistentMusicFormat = Settings.forPackage(RenamePanel.class).entry("rename.format.music");
|
||||||
private static final PreferencesEntry<String> persistentPreferredLanguage = Settings.forPackage(RenamePanel.class).entry("rename.language").defaultValue("en");
|
private static final PreferencesEntry<String> persistentPreferredLanguage = Settings.forPackage(RenamePanel.class).entry("rename.language").defaultValue("en");
|
||||||
private static final PreferencesEntry<String> persistentPreferredEpisodeOrder = Settings.forPackage(RenamePanel.class).entry("rename.episode.order").defaultValue("Airdate");
|
private static final PreferencesEntry<String> persistentPreferredEpisodeOrder = Settings.forPackage(RenamePanel.class).entry("rename.episode.order").defaultValue("Airdate");
|
||||||
|
|
||||||
|
|
||||||
public RenamePanel() {
|
public RenamePanel() {
|
||||||
namesList.setTitle("New Names");
|
namesList.setTitle("New Names");
|
||||||
namesList.setTransferablePolicy(new NamesListTransferablePolicy(renameModel.values()));
|
namesList.setTransferablePolicy(new NamesListTransferablePolicy(renameModel.values()));
|
||||||
|
|
||||||
filesList.setTitle("Original Files");
|
filesList.setTitle("Original Files");
|
||||||
filesList.setTransferablePolicy(new FilesListTransferablePolicy(renameModel.files()));
|
filesList.setTransferablePolicy(new FilesListTransferablePolicy(renameModel.files()));
|
||||||
|
|
||||||
// filename formatter
|
// filename formatter
|
||||||
renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension()));
|
renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension()));
|
||||||
|
|
||||||
// movie formatter
|
// movie formatter
|
||||||
renameModel.useFormatter(Movie.class, new MovieFormatter());
|
renameModel.useFormatter(Movie.class, new MovieFormatter());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// restore custom episode formatter
|
// restore custom episode formatter
|
||||||
renameModel.useFormatter(Episode.class, new ExpressionFormatter(persistentEpisodeFormat.getValue(), EpisodeFormat.SeasonEpisode, Episode.class));
|
renameModel.useFormatter(Episode.class, new ExpressionFormatter(persistentEpisodeFormat.getValue(), EpisodeFormat.SeasonEpisode, Episode.class));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// illegal format, ignore
|
// illegal format, ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// restore custom movie formatter
|
// restore custom movie formatter
|
||||||
renameModel.useFormatter(Movie.class, new ExpressionFormatter(persistentMovieFormat.getValue(), MovieFormat.NameYear, Movie.class));
|
renameModel.useFormatter(Movie.class, new ExpressionFormatter(persistentMovieFormat.getValue(), MovieFormat.NameYear, Movie.class));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// illegal format, ignore
|
// illegal format, ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel);
|
RenameListCellRenderer cellrenderer = new RenameListCellRenderer(renameModel);
|
||||||
|
|
||||||
namesList.getListComponent().setCellRenderer(cellrenderer);
|
namesList.getListComponent().setCellRenderer(cellrenderer);
|
||||||
filesList.getListComponent().setCellRenderer(cellrenderer);
|
filesList.getListComponent().setCellRenderer(cellrenderer);
|
||||||
|
|
||||||
EventSelectionModel<Match<Object, File>> selectionModel = new EventSelectionModel<Match<Object, File>>(renameModel.matches());
|
EventSelectionModel<Match<Object, File>> selectionModel = new EventSelectionModel<Match<Object, File>>(renameModel.matches());
|
||||||
selectionModel.setSelectionMode(ListSelection.SINGLE_SELECTION);
|
selectionModel.setSelectionMode(ListSelection.SINGLE_SELECTION);
|
||||||
|
|
||||||
// use the same selection model for both lists to synchronize selection
|
// use the same selection model for both lists to synchronize selection
|
||||||
namesList.getListComponent().setSelectionModel(selectionModel);
|
namesList.getListComponent().setSelectionModel(selectionModel);
|
||||||
filesList.getListComponent().setSelectionModel(selectionModel);
|
filesList.getListComponent().setSelectionModel(selectionModel);
|
||||||
|
|
||||||
// synchronize viewports
|
// synchronize viewports
|
||||||
new ScrollPaneSynchronizer(namesList, filesList);
|
new ScrollPaneSynchronizer(namesList, filesList);
|
||||||
|
|
||||||
// delete items from both lists
|
// delete items from both lists
|
||||||
Action removeAction = new AbstractAction("Remove") {
|
Action removeAction = new AbstractAction("Remove") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
JList list = ((RenameList) e.getSource()).getListComponent();
|
JList list = ((RenameList) e.getSource()).getListComponent();
|
||||||
@ -161,28 +157,29 @@ public class RenamePanel extends JComponent {
|
|||||||
};
|
};
|
||||||
namesList.setRemoveAction(removeAction);
|
namesList.setRemoveAction(removeAction);
|
||||||
filesList.setRemoveAction(removeAction);
|
filesList.setRemoveAction(removeAction);
|
||||||
|
|
||||||
// create Match button
|
// create Match button
|
||||||
JButton matchButton = new JButton(matchAction);
|
JButton matchButton = new JButton(matchAction);
|
||||||
matchButton.setVerticalTextPosition(SwingConstants.BOTTOM);
|
matchButton.setVerticalTextPosition(SwingConstants.BOTTOM);
|
||||||
matchButton.setHorizontalTextPosition(SwingConstants.CENTER);
|
matchButton.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
|
|
||||||
// create Rename button
|
// create Rename button
|
||||||
JButton renameButton = new JButton(renameAction);
|
JButton renameButton = new JButton(renameAction);
|
||||||
renameButton.setVerticalTextPosition(SwingConstants.BOTTOM);
|
renameButton.setVerticalTextPosition(SwingConstants.BOTTOM);
|
||||||
renameButton.setHorizontalTextPosition(SwingConstants.CENTER);
|
renameButton.setHorizontalTextPosition(SwingConstants.CENTER);
|
||||||
|
|
||||||
// create fetch popup
|
// create fetch popup
|
||||||
ActionPopup fetchPopup = createFetchPopup();
|
ActionPopup fetchPopup = createFetchPopup();
|
||||||
|
|
||||||
final Action fetchPopupAction = new ShowPopupAction("Fetch", ResourceManager.getIcon("action.fetch"));
|
final Action fetchPopupAction = new ShowPopupAction("Fetch", ResourceManager.getIcon("action.fetch"));
|
||||||
JButton fetchButton = createImageButton(fetchPopupAction);
|
JButton fetchButton = new JButton(fetchPopupAction);
|
||||||
|
filesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||||
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||||
fetchButton.setComponentPopupMenu(fetchPopup);
|
fetchButton.setComponentPopupMenu(fetchPopup);
|
||||||
matchButton.setComponentPopupMenu(fetchPopup);
|
matchButton.setComponentPopupMenu(fetchPopup);
|
||||||
namesList.getButtonPanel().add(fetchButton, "gap 0");
|
namesList.getButtonPanel().add(fetchButton, "gap 0");
|
||||||
matchButton.addActionListener(new ActionListener() {
|
matchButton.addActionListener(new ActionListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
// show popup on actionPerformed only when names list is empty
|
// show popup on actionPerformed only when names list is empty
|
||||||
@ -191,10 +188,10 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
namesList.getListComponent().setComponentPopupMenu(fetchPopup);
|
||||||
fetchButton.setComponentPopupMenu(fetchPopup);
|
fetchButton.setComponentPopupMenu(fetchPopup);
|
||||||
|
|
||||||
// settings popup and button
|
// settings popup and button
|
||||||
ActionPopup settingsPopup = createSettingsPopup();
|
ActionPopup settingsPopup = createSettingsPopup();
|
||||||
final Action settingsPopupAction = new ShowPopupAction("Settings", ResourceManager.getIcon("action.settings"));
|
final Action settingsPopupAction = new ShowPopupAction("Settings", ResourceManager.getIcon("action.settings"));
|
||||||
@ -202,14 +199,14 @@ public class RenamePanel extends JComponent {
|
|||||||
settingsButton.setComponentPopupMenu(settingsPopup);
|
settingsButton.setComponentPopupMenu(settingsPopup);
|
||||||
renameButton.setComponentPopupMenu(settingsPopup);
|
renameButton.setComponentPopupMenu(settingsPopup);
|
||||||
namesList.getButtonPanel().add(settingsButton, "gap indent");
|
namesList.getButtonPanel().add(settingsButton, "gap indent");
|
||||||
|
|
||||||
// open rename log button
|
// open rename log button
|
||||||
filesList.getButtonPanel().add(createImageButton(clearFilesAction), "gap 0");
|
filesList.getButtonPanel().add(new JButton(clearFilesAction), "gap 0");
|
||||||
filesList.getButtonPanel().add(createImageButton(openHistoryAction), "gap indent");
|
filesList.getButtonPanel().add(createImageButton(openHistoryAction), "gap indent");
|
||||||
|
|
||||||
// reveal file location on double click
|
// reveal file location on double click
|
||||||
filesList.getListComponent().addMouseListener(new MouseAdapter() {
|
filesList.getListComponent().addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent evt) {
|
public void mouseClicked(MouseEvent evt) {
|
||||||
if (evt.getClickCount() == 2) {
|
if (evt.getClickCount() == 2) {
|
||||||
@ -228,10 +225,10 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// reveal file location on double click
|
// reveal file location on double click
|
||||||
namesList.getListComponent().addMouseListener(new MouseAdapter() {
|
namesList.getListComponent().addMouseListener(new MouseAdapter() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseClicked(MouseEvent evt) {
|
public void mouseClicked(MouseEvent evt) {
|
||||||
if (evt.getClickCount() == 2) {
|
if (evt.getClickCount() == 2) {
|
||||||
@ -257,85 +254,84 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
|
setLayout(new MigLayout("fill, insets dialog, gapx 10px", "[fill][align center, pref!][fill]", "align 33%"));
|
||||||
add(filesList, "grow, sizegroupx list");
|
add(filesList, "grow, sizegroupx list");
|
||||||
|
|
||||||
// make buttons larger
|
// make buttons larger
|
||||||
matchButton.setMargin(new Insets(3, 14, 2, 14));
|
matchButton.setMargin(new Insets(3, 14, 2, 14));
|
||||||
renameButton.setMargin(new Insets(6, 11, 2, 11));
|
renameButton.setMargin(new Insets(6, 11, 2, 11));
|
||||||
|
|
||||||
add(matchButton, "split 2, flowy, sizegroupx button");
|
add(matchButton, "split 2, flowy, sizegroupx button");
|
||||||
add(renameButton, "gapy 30px, sizegroupx button");
|
add(renameButton, "gapy 30px, sizegroupx button");
|
||||||
|
|
||||||
add(new LoadingOverlayPane(namesList, namesList, "32px", "30px"), "grow, sizegroupx list");
|
add(new LoadingOverlayPane(namesList, namesList, "32px", "30px"), "grow, sizegroupx list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ActionPopup createFetchPopup() {
|
protected ActionPopup createFetchPopup() {
|
||||||
final ActionPopup actionPopup = new ActionPopup("Series / Movie Data", ResourceManager.getIcon("action.fetch"));
|
final ActionPopup actionPopup = new ActionPopup("Series / Movie Data", ResourceManager.getIcon("action.fetch"));
|
||||||
|
|
||||||
actionPopup.addDescription(new JLabel("Episode Mode:"));
|
actionPopup.addDescription(new JLabel("Episode Mode:"));
|
||||||
|
|
||||||
// create actions for match popup episode list completion
|
// create actions for match popup episode list completion
|
||||||
for (EpisodeListProvider provider : WebServices.getEpisodeListProviders()) {
|
for (EpisodeListProvider provider : WebServices.getEpisodeListProviders()) {
|
||||||
actionPopup.add(new AutoCompleteAction(provider.getName(), provider.getIcon(), new EpisodeListMatcher(provider)));
|
actionPopup.add(new AutoCompleteAction(provider.getName(), provider.getIcon(), new EpisodeListMatcher(provider)));
|
||||||
}
|
}
|
||||||
|
|
||||||
actionPopup.addSeparator();
|
actionPopup.addSeparator();
|
||||||
actionPopup.addDescription(new JLabel("Movie Mode:"));
|
actionPopup.addDescription(new JLabel("Movie Mode:"));
|
||||||
|
|
||||||
// create action for movie name completion
|
// create action for movie name completion
|
||||||
for (MovieIdentificationService it : WebServices.getMovieIdentificationServices()) {
|
for (MovieIdentificationService it : WebServices.getMovieIdentificationServices()) {
|
||||||
actionPopup.add(new AutoCompleteAction(it.getName(), it.getIcon(), new MovieHashMatcher(it)));
|
actionPopup.add(new AutoCompleteAction(it.getName(), it.getIcon(), new MovieHashMatcher(it)));
|
||||||
}
|
}
|
||||||
|
|
||||||
actionPopup.addSeparator();
|
actionPopup.addSeparator();
|
||||||
actionPopup.addDescription(new JLabel("Music Mode:"));
|
actionPopup.addDescription(new JLabel("Music Mode:"));
|
||||||
actionPopup.add(new AutoCompleteAction(WebServices.AcoustID.getName(), WebServices.AcoustID.getIcon(), new AudioFingerprintMatcher(WebServices.AcoustID)));
|
actionPopup.add(new AutoCompleteAction(WebServices.AcoustID.getName(), WebServices.AcoustID.getIcon(), new AudioFingerprintMatcher(WebServices.AcoustID)));
|
||||||
|
|
||||||
actionPopup.addSeparator();
|
actionPopup.addSeparator();
|
||||||
actionPopup.addDescription(new JLabel("Options:"));
|
actionPopup.addDescription(new JLabel("Options:"));
|
||||||
|
|
||||||
actionPopup.add(new AbstractAction("Edit Format", ResourceManager.getIcon("action.format")) {
|
actionPopup.add(new AbstractAction("Edit Format", ResourceManager.getIcon("action.format")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
FormatDialog dialog = new FormatDialog(getWindowAncestor(RenamePanel.this));
|
FormatDialog dialog = new FormatDialog(getWindowAncestor(RenamePanel.this));
|
||||||
dialog.setLocation(getOffsetLocation(dialog.getOwner()));
|
dialog.setLocation(getOffsetLocation(dialog.getOwner()));
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|
||||||
if (dialog.submit()) {
|
if (dialog.submit()) {
|
||||||
switch (dialog.getMode()) {
|
switch (dialog.getMode()) {
|
||||||
case Episode:
|
case Episode:
|
||||||
renameModel.useFormatter(Episode.class, new ExpressionFormatter(dialog.getFormat().getExpression(), EpisodeFormat.SeasonEpisode, Episode.class));
|
renameModel.useFormatter(Episode.class, new ExpressionFormatter(dialog.getFormat().getExpression(), EpisodeFormat.SeasonEpisode, Episode.class));
|
||||||
persistentEpisodeFormat.setValue(dialog.getFormat().getExpression());
|
persistentEpisodeFormat.setValue(dialog.getFormat().getExpression());
|
||||||
break;
|
break;
|
||||||
case Movie:
|
case Movie:
|
||||||
renameModel.useFormatter(Movie.class, new ExpressionFormatter(dialog.getFormat().getExpression(), MovieFormat.NameYear, Movie.class));
|
renameModel.useFormatter(Movie.class, new ExpressionFormatter(dialog.getFormat().getExpression(), MovieFormat.NameYear, Movie.class));
|
||||||
persistentMovieFormat.setValue(dialog.getFormat().getExpression());
|
persistentMovieFormat.setValue(dialog.getFormat().getExpression());
|
||||||
break;
|
break;
|
||||||
case Music:
|
case Music:
|
||||||
renameModel.useFormatter(AudioTrack.class, new ExpressionFormatter(dialog.getFormat().getExpression(), new AudioTrackFormat(), AudioTrack.class));
|
renameModel.useFormatter(AudioTrack.class, new ExpressionFormatter(dialog.getFormat().getExpression(), new AudioTrackFormat(), AudioTrack.class));
|
||||||
persistentMusicFormat.setValue(dialog.getFormat().getExpression());
|
persistentMusicFormat.setValue(dialog.getFormat().getExpression());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
actionPopup.add(new AbstractAction("Preferences", ResourceManager.getIcon("action.preferences")) {
|
actionPopup.add(new AbstractAction("Preferences", ResourceManager.getIcon("action.preferences")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
List<Language> languages = new ArrayList<Language>();
|
List<Language> languages = new ArrayList<Language>();
|
||||||
languages.addAll(Language.preferredLanguages()); // add preferred languages first
|
languages.addAll(Language.preferredLanguages()); // add preferred languages first
|
||||||
languages.addAll(Language.availableLanguages()); // then others
|
languages.addAll(Language.availableLanguages()); // then others
|
||||||
|
|
||||||
JComboBox orderCombo = new JComboBox(SortOrder.values());
|
JComboBox orderCombo = new JComboBox(SortOrder.values());
|
||||||
JList languageList = new JList(languages.toArray());
|
JList languageList = new JList(languages.toArray());
|
||||||
languageList.setCellRenderer(new DefaultListCellRenderer() {
|
languageList.setCellRenderer(new DefaultListCellRenderer() {
|
||||||
|
|
||||||
@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) {
|
||||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
@ -345,7 +341,7 @@ public class RenamePanel extends JComponent {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// pre-select current preferences
|
// pre-select current preferences
|
||||||
try {
|
try {
|
||||||
orderCombo.setSelectedItem(SortOrder.forName(persistentPreferredEpisodeOrder.getValue()));
|
orderCombo.setSelectedItem(SortOrder.forName(persistentPreferredEpisodeOrder.getValue()));
|
||||||
@ -358,48 +354,47 @@ public class RenamePanel extends JComponent {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JScrollPane spLanguageList = new JScrollPane(languageList);
|
JScrollPane spLanguageList = new JScrollPane(languageList);
|
||||||
spLanguageList.setBorder(new CompoundBorder(new TitledBorder("Preferred Language"), spLanguageList.getBorder()));
|
spLanguageList.setBorder(new CompoundBorder(new TitledBorder("Preferred Language"), spLanguageList.getBorder()));
|
||||||
JScrollPane spOrderCombo = new JScrollPane(orderCombo, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
JScrollPane spOrderCombo = new JScrollPane(orderCombo, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
spOrderCombo.setBorder(new CompoundBorder(new TitledBorder("Preferred Episode Order"), spOrderCombo.getBorder()));
|
spOrderCombo.setBorder(new CompoundBorder(new TitledBorder("Preferred Episode Order"), spOrderCombo.getBorder()));
|
||||||
|
|
||||||
JPanel message = new JPanel(new MigLayout("fill, flowy, insets 0"));
|
JPanel message = new JPanel(new MigLayout("fill, flowy, insets 0"));
|
||||||
message.add(spLanguageList, "grow");
|
message.add(spLanguageList, "grow");
|
||||||
message.add(spOrderCombo, "grow, hmin 24px");
|
message.add(spOrderCombo, "grow, hmin 24px");
|
||||||
JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, OK_CANCEL_OPTION);
|
JOptionPane pane = new JOptionPane(message, PLAIN_MESSAGE, OK_CANCEL_OPTION);
|
||||||
pane.createDialog(getWindowAncestor(RenamePanel.this), "Preferences").setVisible(true);
|
pane.createDialog(getWindowAncestor(RenamePanel.this), "Preferences").setVisible(true);
|
||||||
|
|
||||||
if (pane.getValue() != null && pane.getValue().equals(OK_OPTION)) {
|
if (pane.getValue() != null && pane.getValue().equals(OK_OPTION)) {
|
||||||
persistentPreferredLanguage.setValue(((Language) languageList.getSelectedValue()).getCode());
|
persistentPreferredLanguage.setValue(((Language) languageList.getSelectedValue()).getCode());
|
||||||
persistentPreferredEpisodeOrder.setValue(((SortOrder) orderCombo.getSelectedItem()).name());
|
persistentPreferredEpisodeOrder.setValue(((SortOrder) orderCombo.getSelectedItem()).name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return actionPopup;
|
return actionPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected ActionPopup createSettingsPopup() {
|
protected ActionPopup createSettingsPopup() {
|
||||||
ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.settings"));
|
ActionPopup actionPopup = new ActionPopup("Rename Options", ResourceManager.getIcon("action.settings"));
|
||||||
|
|
||||||
actionPopup.addDescription(new JLabel("Extension:"));
|
actionPopup.addDescription(new JLabel("Extension:"));
|
||||||
actionPopup.add(new SetRenameMode(false, "Preserve", ResourceManager.getIcon("action.extension.preserve")));
|
actionPopup.add(new SetRenameMode(false, "Preserve", ResourceManager.getIcon("action.extension.preserve")));
|
||||||
actionPopup.add(new SetRenameMode(true, "Override", ResourceManager.getIcon("action.extension.override")));
|
actionPopup.add(new SetRenameMode(true, "Override", ResourceManager.getIcon("action.extension.override")));
|
||||||
|
|
||||||
actionPopup.addSeparator();
|
actionPopup.addSeparator();
|
||||||
|
|
||||||
actionPopup.addDescription(new JLabel("Action:"));
|
actionPopup.addDescription(new JLabel("Action:"));
|
||||||
for (StandardRenameAction action : EnumSet.of(StandardRenameAction.MOVE, StandardRenameAction.COPY, StandardRenameAction.KEEPLINK, StandardRenameAction.SYMLINK, StandardRenameAction.HARDLINK)) {
|
for (StandardRenameAction action : EnumSet.of(StandardRenameAction.MOVE, StandardRenameAction.COPY, StandardRenameAction.KEEPLINK, StandardRenameAction.SYMLINK, StandardRenameAction.HARDLINK)) {
|
||||||
actionPopup.add(new SetRenameAction(action, action.getDisplayName(), ResourceManager.getIcon("rename.action." + action.toString().toLowerCase())));
|
actionPopup.add(new SetRenameAction(action, action.getDisplayName(), ResourceManager.getIcon("rename.action." + action.toString().toLowerCase())));
|
||||||
}
|
}
|
||||||
|
|
||||||
return actionPopup;
|
return actionPopup;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final Action clearFilesAction = new AbstractAction("Clear Files", ResourceManager.getIcon("action.clear")) {
|
protected final Action clearFilesAction = new AbstractAction("Clear", ResourceManager.getIcon("action.clear")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
if (isShiftOrAltDown(evt)) {
|
if (isShiftOrAltDown(evt)) {
|
||||||
@ -409,18 +404,18 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected final Action openHistoryAction = new AbstractAction("Open History", ResourceManager.getIcon("action.report")) {
|
protected final Action openHistoryAction = new AbstractAction("Open History", ResourceManager.getIcon("action.report")) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
try {
|
try {
|
||||||
History model = HistorySpooler.getInstance().getCompleteHistory();
|
History model = HistorySpooler.getInstance().getCompleteHistory();
|
||||||
|
|
||||||
HistoryDialog dialog = new HistoryDialog(getWindow(RenamePanel.this));
|
HistoryDialog dialog = new HistoryDialog(getWindow(RenamePanel.this));
|
||||||
dialog.setLocationRelativeTo(RenamePanel.this);
|
dialog.setLocationRelativeTo(RenamePanel.this);
|
||||||
dialog.setModel(model);
|
dialog.setModel(model);
|
||||||
|
|
||||||
// show and block
|
// show and block
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -428,15 +423,13 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected static class ShowPopupAction extends AbstractAction {
|
protected static class ShowPopupAction extends AbstractAction {
|
||||||
|
|
||||||
public ShowPopupAction(String name, Icon icon) {
|
public ShowPopupAction(String name, Icon icon) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
// display popup below component
|
// display popup below component
|
||||||
@ -444,43 +437,37 @@ public class RenamePanel extends JComponent {
|
|||||||
source.getComponentPopupMenu().show(source, -3, source.getHeight() + 4);
|
source.getComponentPopupMenu().show(source, -3, source.getHeight() + 4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
protected class SetRenameMode extends AbstractAction {
|
protected class SetRenameMode extends AbstractAction {
|
||||||
|
|
||||||
private final boolean activate;
|
private final boolean activate;
|
||||||
|
|
||||||
|
|
||||||
private SetRenameMode(boolean activate, String name, Icon icon) {
|
private SetRenameMode(boolean activate, String name, Icon icon) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
this.activate = activate;
|
this.activate = activate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
renameModel.setPreserveExtension(!activate);
|
renameModel.setPreserveExtension(!activate);
|
||||||
|
|
||||||
// use different file name formatter
|
// use different file name formatter
|
||||||
renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension()));
|
renameModel.useFormatter(File.class, new FileNameFormatter(renameModel.preserveExtension()));
|
||||||
|
|
||||||
// display changed state
|
// display changed state
|
||||||
filesList.repaint();
|
filesList.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected class SetRenameAction extends AbstractAction {
|
protected class SetRenameAction extends AbstractAction {
|
||||||
|
|
||||||
private final StandardRenameAction action;
|
private final StandardRenameAction action;
|
||||||
|
|
||||||
|
|
||||||
public SetRenameAction(StandardRenameAction action, String name, Icon icon) {
|
public SetRenameAction(StandardRenameAction action, String name, Icon icon) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
this.action = action;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
if (action == StandardRenameAction.MOVE) {
|
if (action == StandardRenameAction.MOVE) {
|
||||||
@ -492,21 +479,19 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected class AutoCompleteAction extends AbstractAction {
|
protected class AutoCompleteAction extends AbstractAction {
|
||||||
|
|
||||||
private final AutoCompleteMatcher matcher;
|
private final AutoCompleteMatcher matcher;
|
||||||
|
|
||||||
|
|
||||||
public AutoCompleteAction(String name, Icon icon, AutoCompleteMatcher matcher) {
|
public AutoCompleteAction(String name, Icon icon, AutoCompleteMatcher matcher) {
|
||||||
super(name, icon);
|
super(name, icon);
|
||||||
|
|
||||||
this.matcher = matcher;
|
this.matcher = matcher;
|
||||||
|
|
||||||
// disable action while episode list matcher is working
|
// disable action while episode list matcher is working
|
||||||
namesList.addPropertyChangeListener(LOADING_PROPERTY, new PropertyChangeListener() {
|
namesList.addPropertyChangeListener(LOADING_PROPERTY, new PropertyChangeListener() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
public void propertyChange(PropertyChangeEvent evt) {
|
||||||
// disable action while loading is in progress
|
// disable action while loading is in progress
|
||||||
@ -514,50 +499,48 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(final ActionEvent evt) {
|
public void actionPerformed(final ActionEvent evt) {
|
||||||
if (renameModel.files().isEmpty()) {
|
if (renameModel.files().isEmpty()) {
|
||||||
|
UILogger.info("Original Files is empty. Please add some files first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear names list
|
// clear names list
|
||||||
renameModel.values().clear();
|
renameModel.values().clear();
|
||||||
|
|
||||||
SwingWorker<List<Match<File, ?>>, Void> worker = new SwingWorker<List<Match<File, ?>>, Void>() {
|
SwingWorker<List<Match<File, ?>>, Void> worker = new SwingWorker<List<Match<File, ?>>, Void>() {
|
||||||
|
|
||||||
private final List<File> remainingFiles = new LinkedList<File>(renameModel.files());
|
private final List<File> remainingFiles = new LinkedList<File>(renameModel.files());
|
||||||
private final SortOrder order = SortOrder.forName(persistentPreferredEpisodeOrder.getValue());
|
private final SortOrder order = SortOrder.forName(persistentPreferredEpisodeOrder.getValue());
|
||||||
private final Locale locale = new Locale(persistentPreferredLanguage.getValue());
|
private final Locale locale = new Locale(persistentPreferredLanguage.getValue());
|
||||||
private final boolean autodetection = !isShiftOrAltDown(evt); // skip name auto-detection if SHIFT is pressed
|
private final boolean autodetection = !isShiftOrAltDown(evt); // skip name auto-detection if SHIFT is pressed
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<Match<File, ?>> doInBackground() throws Exception {
|
protected List<Match<File, ?>> doInBackground() throws Exception {
|
||||||
List<Match<File, ?>> matches = matcher.match(remainingFiles, order, locale, autodetection, getWindow(RenamePanel.this));
|
List<Match<File, ?>> matches = matcher.match(remainingFiles, order, locale, autodetection, getWindow(RenamePanel.this));
|
||||||
|
|
||||||
// remove matched files
|
// remove matched files
|
||||||
for (Match<File, ?> match : matches) {
|
for (Match<File, ?> match : matches) {
|
||||||
remainingFiles.remove(match.getValue());
|
remainingFiles.remove(match.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void done() {
|
protected void done() {
|
||||||
try {
|
try {
|
||||||
List<Match<Object, File>> matches = new ArrayList<Match<Object, File>>();
|
List<Match<Object, File>> matches = new ArrayList<Match<Object, File>>();
|
||||||
|
|
||||||
for (Match<File, ?> match : get()) {
|
for (Match<File, ?> match : get()) {
|
||||||
matches.add(new Match<Object, File>(match.getCandidate(), match.getValue()));
|
matches.add(new Match<Object, File>(match.getCandidate(), match.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
renameModel.clear();
|
renameModel.clear();
|
||||||
renameModel.addAll(matches);
|
renameModel.addAll(matches);
|
||||||
|
|
||||||
// add remaining file entries
|
// add remaining file entries
|
||||||
renameModel.files().addAll(remainingFiles);
|
renameModel.files().addAll(remainingFiles);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -568,12 +551,12 @@ public class RenamePanel extends JComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// auto-match in progress
|
// auto-match in progress
|
||||||
namesList.firePropertyChange(LOADING_PROPERTY, false, true);
|
namesList.firePropertyChange(LOADING_PROPERTY, false, true);
|
||||||
|
|
||||||
worker.execute();
|
worker.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1120,6 +1120,7 @@ iNSECTS
|
|||||||
iNSOMNi
|
iNSOMNi
|
||||||
iNSPiRED
|
iNSPiRED
|
||||||
InSubs
|
InSubs
|
||||||
|
iNT-TD
|
||||||
IntelliQ
|
IntelliQ
|
||||||
iNTERNAL
|
iNTERNAL
|
||||||
iNTiMiD
|
iNTiMiD
|
||||||
@ -2366,6 +2367,7 @@ zomg
|
|||||||
Zomg-Killerhurtalot
|
Zomg-Killerhurtalot
|
||||||
Zorori-Project
|
Zorori-Project
|
||||||
Zox
|
Zox
|
||||||
|
ZSiSO
|
||||||
Zurako
|
Zurako
|
||||||
Zuzuu
|
Zuzuu
|
||||||
ZZGtv
|
ZZGtv
|
||||||
|
@ -78,5 +78,10 @@
|
|||||||
"user": "Raydan",
|
"user": "Raydan",
|
||||||
"date": "2013-09-08",
|
"date": "2013-09-08",
|
||||||
"text": "I can really recommend using filebot for sorting, moving, deleting, subtitle searching... I just started the script once... and it was quite mindblowing to be honest."
|
"text": "I can really recommend using filebot for sorting, moving, deleting, subtitle searching... I just started the script once... and it was quite mindblowing to be honest."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"user": "Nitish Kumar",
|
||||||
|
"date": "2013-09-21",
|
||||||
|
"text": "FileBot is such an amazing piece of work. Been using it for TV Shows renaming but today tried over movies as well. Big time success!"
|
||||||
}
|
}
|
||||||
]
|
]
|
Loading…
Reference in New Issue
Block a user