1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* allow users to test custom file filter right away from within the Preset Editor

This commit is contained in:
Reinhard Pointner 2015-07-27 13:44:40 +00:00
parent f97b040dda
commit 034b47ccdb
2 changed files with 66 additions and 6 deletions

View File

@ -98,8 +98,12 @@ class BindingDialog extends JDialog {
root.add(new JLabel("Preview:"), "gap 5px, wrap 2px"); root.add(new JLabel("Preview:"), "gap 5px, wrap 2px");
root.add(new JScrollPane(createBindingTable(bindingModel)), "growx, wrap paragraph:push"); root.add(new JScrollPane(createBindingTable(bindingModel)), "growx, wrap paragraph:push");
if (editable) {
root.add(new JButton(approveAction), "tag apply"); root.add(new JButton(approveAction), "tag apply");
root.add(new JButton(cancelAction), "tag cancel"); root.add(new JButton(cancelAction), "tag cancel");
} else {
root.add(new JButton(okAction), "tag apply");
}
// update preview on change // update preview on change
DocumentListener changeListener = new LazyDocumentListener(1000) { DocumentListener changeListener = new LazyDocumentListener(1000) {
@ -244,6 +248,14 @@ class BindingDialog extends JDialog {
return file.isAbsolute() ? file : null; return file.isAbsolute() ? file : null;
} }
protected final Action hideAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
@Override
public void actionPerformed(ActionEvent evt) {
finish(true);
}
};
protected final Action approveAction = new AbstractAction("Use Bindings", ResourceManager.getIcon("dialog.continue")) { protected final Action approveAction = new AbstractAction("Use Bindings", ResourceManager.getIcon("dialog.continue")) {
@Override @Override
@ -262,7 +274,7 @@ class BindingDialog extends JDialog {
} }
}; };
protected final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) { protected final Action okAction = new AbstractAction("OK") {
@Override @Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
@ -270,6 +282,14 @@ class BindingDialog extends JDialog {
} }
}; };
protected final Action cancelAction = new AbstractAction("Cancel", ResourceManager.getIcon("dialog.cancel")) {
@Override
public void actionPerformed(ActionEvent evt) {
finish(false);
}
};
protected final Action mediaInfoAction = new AbstractAction("Open MediaInfo", ResourceManager.getIcon("action.properties")) { protected final Action mediaInfoAction = new AbstractAction("Open MediaInfo", ResourceManager.getIcon("action.properties")) {
private Map<StreamKind, List<Map<String, String>>> getMediaInfo(File file) { private Map<StreamKind, List<Map<String, String>>> getMediaInfo(File file) {

View File

@ -12,6 +12,7 @@ import java.awt.event.ActionEvent;
import java.io.File; import java.io.File;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import javax.swing.AbstractAction; import javax.swing.AbstractAction;
import javax.swing.Action; import javax.swing.Action;
@ -23,7 +24,9 @@ import javax.swing.JComponent;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JMenuItem;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.JTextField; import javax.swing.JTextField;
import javax.swing.ListCellRenderer; import javax.swing.ListCellRenderer;
@ -98,8 +101,9 @@ public class PresetEditor extends JDialog {
inputPanel.add(new JLabel("Input Folder:"), "gap indent"); inputPanel.add(new JLabel("Input Folder:"), "gap indent");
inputPanel.add(pathInput, "growx, gap rel"); inputPanel.add(pathInput, "growx, gap rel");
inputPanel.add(createImageButton(selectInputFolder), "gap 0px, wrap"); inputPanel.add(createImageButton(selectInputFolder), "gap 0px, wrap");
inputPanel.add(new JLabel("Includes:"), "gap indent, skip 1, split 2"); inputPanel.add(new JLabel("Includes:"), "gap indent, skip 1, split 3");
inputPanel.add(wrapEditor(filterEditor), "growx, gap rel, gap after 40px"); inputPanel.add(wrapEditor(filterEditor), "growx, gap rel");
inputPanel.add(createImageButton(listFiles), "gap rel");
JPanel inputGroup = createGroupPanel("Files"); JPanel inputGroup = createGroupPanel("Files");
inputGroup.add(selectRadio); inputGroup.add(selectRadio);
@ -361,6 +365,42 @@ public class PresetEditor extends JDialog {
} }
}; };
private final Action listFiles = new AbstractAction("List Files", ResourceManager.getIcon("action.list")) {
private JMenuItem createListItem(ActionEvent evt, File f) {
JMenuItem m = new JMenuItem(f.getPath());
m.addActionListener((e) -> {
BindingDialog dialog = new BindingDialog(getWindow(evt.getSource()), "File Bindings", FormatDialog.Mode.File.getFormat(), false);
dialog.setLocation(getOffsetLocation(getWindow(evt.getSource())));
dialog.setInfoObject(f);
dialog.setMediaFile(f);
dialog.setVisible(true);
});
return m;
}
@Override
public void actionPerformed(ActionEvent evt) {
try {
List<File> selectInputFiles = getPreset().selectInputFiles(evt);
JPopupMenu popup = new JPopupMenu();
if (selectInputFiles == null || selectInputFiles.isEmpty()) {
popup.add("No files selected").setEnabled(false);
} else {
for (File file : selectInputFiles) {
popup.add(createListItem(evt, file));
}
}
JComponent source = (JComponent) evt.getSource();
popup.show(source, -3, source.getHeight() + 4);
} catch (Exception e) {
UILogger.log(Level.WARNING, "Invalid preset settings: " + e.getMessage(), e);
}
}
};
private final Action ok = new AbstractAction("Preset", ResourceManager.getIcon("dialog.continue")) { private final Action ok = new AbstractAction("Preset", ResourceManager.getIcon("dialog.continue")) {
@Override @Override
@ -372,7 +412,7 @@ public class PresetEditor extends JDialog {
setVisible(false); setVisible(false);
} }
} catch (Exception e) { } catch (Exception e) {
UILogger.severe("Invalid preset settings: " + e.getMessage()); UILogger.log(Level.WARNING, "Invalid preset settings: " + e.getMessage(), e);
} }
} }
}; };