* manual force name via F2

This commit is contained in:
Reinhard Pointner 2014-02-19 21:07:41 +00:00
parent ae3ca48613
commit 408efd166d
1 changed files with 25 additions and 0 deletions

View File

@ -1,6 +1,8 @@
package net.sourceforge.filebot.ui.rename;
import static java.awt.event.KeyEvent.*;
import static javax.swing.JOptionPane.*;
import static javax.swing.KeyStroke.*;
import static javax.swing.SwingUtilities.*;
import static net.sourceforge.filebot.ui.NotificationLogging.*;
import static net.sourceforge.tuned.ExceptionUtilities.*;
@ -283,6 +285,26 @@ public class RenamePanel extends JComponent {
add(renameButton, "gapy 30px, sizegroupx button");
add(new LoadingOverlayPane(namesList, namesList, "32px", "30px"), "grow, sizegroupx list");
// manual force name via F2
installAction(namesList.getListComponent(), getKeyStroke(VK_F2, 0), new AbstractAction("Force Name") {
@Override
public void actionPerformed(ActionEvent evt) {
try {
int index = namesList.getListComponent().getSelectedIndex();
File file = (File) filesList.getListComponent().getModel().getElementAt(index);
String generatedName = namesList.getListComponent().getModel().getElementAt(index).toString();
String forcedName = showInputDialog("Enter Name:", generatedName, "Enter Name", RenamePanel.this);
if (forcedName != null && forcedName.length() > 0) {
renameModel.matches().set(index, new Match<Object, File>(forcedName, file));
}
} catch (Exception e) {
Logger.getLogger(RenamePanel.class.getName()).log(Level.WARNING, e.getMessage());
}
}
});
}
protected ActionPopup createFetchPopup() {
@ -405,6 +427,9 @@ public class RenamePanel extends JComponent {
initMode = Mode.Movie;
} else if (lockOnBinding.getInfoObject() instanceof AudioTrack) {
initMode = Mode.Music;
} else {
// illegal info object => ignore
return;
}
} else {
// restore previous mode