mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 22:08:01 -05:00
* update bindings sample dialog
This commit is contained in:
parent
e6331f1116
commit
a2a897843b
@ -1,7 +1,5 @@
|
|||||||
|
|
||||||
package net.sourceforge.filebot.ui.rename;
|
package net.sourceforge.filebot.ui.rename;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.MediaTypes.*;
|
import static net.sourceforge.filebot.MediaTypes.*;
|
||||||
import static net.sourceforge.filebot.Settings.*;
|
import static net.sourceforge.filebot.Settings.*;
|
||||||
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
||||||
@ -66,7 +64,6 @@ import net.sourceforge.filebot.mediainfo.MediaInfoException;
|
|||||||
import net.sourceforge.tuned.DefaultThreadFactory;
|
import net.sourceforge.tuned.DefaultThreadFactory;
|
||||||
import net.sourceforge.tuned.ui.LazyDocumentListener;
|
import net.sourceforge.tuned.ui.LazyDocumentListener;
|
||||||
|
|
||||||
|
|
||||||
class BindingDialog extends JDialog {
|
class BindingDialog extends JDialog {
|
||||||
|
|
||||||
private final JTextField infoTextField = new JTextField();
|
private final JTextField infoTextField = new JTextField();
|
||||||
@ -77,8 +74,7 @@ class BindingDialog extends JDialog {
|
|||||||
|
|
||||||
private boolean submit = false;
|
private boolean submit = false;
|
||||||
|
|
||||||
|
public BindingDialog(Window owner, String title, Format infoObjectFormat, boolean editable) {
|
||||||
public BindingDialog(Window owner, String title, Format infoObjectFormat) {
|
|
||||||
super(owner, title, ModalityType.DOCUMENT_MODAL);
|
super(owner, title, ModalityType.DOCUMENT_MODAL);
|
||||||
this.infoObjectFormat = infoObjectFormat;
|
this.infoObjectFormat = infoObjectFormat;
|
||||||
|
|
||||||
@ -138,13 +134,11 @@ class BindingDialog extends JDialog {
|
|||||||
mediaInfoAction.setEnabled(getMediaFile() != null && getMediaFile().isFile());
|
mediaInfoAction.setEnabled(getMediaFile() != null && getMediaFile().isFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeUpdate(DocumentEvent e) {
|
public void removeUpdate(DocumentEvent e) {
|
||||||
changedUpdate(e);
|
changedUpdate(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertUpdate(DocumentEvent e) {
|
public void insertUpdate(DocumentEvent e) {
|
||||||
changedUpdate(e);
|
changedUpdate(e);
|
||||||
@ -160,12 +154,15 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mediaFileTextField.setEditable(editable);
|
||||||
|
infoTextField.setEditable(editable);
|
||||||
|
selectFileAction.setEnabled(editable);
|
||||||
|
|
||||||
// initialize window properties
|
// initialize window properties
|
||||||
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
|
||||||
setSize(420, 520);
|
setSize(420, 520);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private JTable createBindingTable(TableModel model) {
|
private JTable createBindingTable(TableModel model) {
|
||||||
JTable table = new JTable(model);
|
JTable table = new JTable(model);
|
||||||
table.setAutoCreateRowSorter(true);
|
table.setAutoCreateRowSorter(true);
|
||||||
@ -212,18 +209,15 @@ class BindingDialog extends JDialog {
|
|||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<String> getSampleExpressions() {
|
private List<String> getSampleExpressions() {
|
||||||
ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName());
|
ResourceBundle bundle = ResourceBundle.getBundle(getClass().getName());
|
||||||
return Arrays.asList(bundle.getString("expressions").split(","));
|
return Arrays.asList(bundle.getString("expressions").split(","));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean submit() {
|
public boolean submit() {
|
||||||
return submit;
|
return submit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void finish(boolean submit) {
|
private void finish(boolean submit) {
|
||||||
this.submit = submit;
|
this.submit = submit;
|
||||||
|
|
||||||
@ -234,23 +228,19 @@ class BindingDialog extends JDialog {
|
|||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setInfoObject(Object info) {
|
public void setInfoObject(Object info) {
|
||||||
infoTextField.putClientProperty("model", info);
|
infoTextField.putClientProperty("model", info);
|
||||||
infoTextField.setText(info == null ? "" : infoObjectFormat.format(info));
|
infoTextField.setText(info == null ? "" : infoObjectFormat.format(info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setMediaFile(File mediaFile) {
|
public void setMediaFile(File mediaFile) {
|
||||||
mediaFileTextField.setText(mediaFile == null ? "" : mediaFile.getAbsolutePath());
|
mediaFileTextField.setText(mediaFile == null ? "" : mediaFile.getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object getInfoObject() {
|
public Object getInfoObject() {
|
||||||
return infoTextField.getClientProperty("model");
|
return infoTextField.getClientProperty("model");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public File getMediaFile() {
|
public File getMediaFile() {
|
||||||
File file = new File(mediaFileTextField.getText());
|
File file = new File(mediaFileTextField.getText());
|
||||||
|
|
||||||
@ -306,7 +296,6 @@ class BindingDialog extends JDialog {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
Map<StreamKind, List<Map<String, String>>> mediaInfo = getMediaInfo(getMediaFile());
|
Map<StreamKind, List<Map<String, String>>> mediaInfo = getMediaInfo(getMediaFile());
|
||||||
@ -408,24 +397,20 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
private static class Evaluator extends SwingWorker<String, Void> {
|
private static class Evaluator extends SwingWorker<String, Void> {
|
||||||
|
|
||||||
private final String expression;
|
private final String expression;
|
||||||
private final Object bindingBean;
|
private final Object bindingBean;
|
||||||
|
|
||||||
|
|
||||||
private Evaluator(String expression, Object bindingBean) {
|
private Evaluator(String expression, Object bindingBean) {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
this.bindingBean = bindingBean;
|
this.bindingBean = bindingBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public String getExpression() {
|
public String getExpression() {
|
||||||
return expression;
|
return expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground() throws Exception {
|
protected String doInBackground() throws Exception {
|
||||||
ExpressionFormat format = new ExpressionFormat(expression) {
|
ExpressionFormat format = new ExpressionFormat(expression) {
|
||||||
@ -448,7 +433,6 @@ class BindingDialog extends JDialog {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
try {
|
try {
|
||||||
@ -459,14 +443,12 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class BindingTableModel extends AbstractTableModel {
|
private static class BindingTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
private final List<Evaluator> model = new ArrayList<Evaluator>();
|
private final List<Evaluator> model = new ArrayList<Evaluator>();
|
||||||
|
|
||||||
private final ExecutorService executor = Executors.newFixedThreadPool(2, new DefaultThreadFactory("Evaluator", Thread.MIN_PRIORITY));
|
private final ExecutorService executor = Executors.newFixedThreadPool(2, new DefaultThreadFactory("Evaluator", Thread.MIN_PRIORITY));
|
||||||
|
|
||||||
|
|
||||||
public void setModel(Collection<String> expressions, Object bindingBean) {
|
public void setModel(Collection<String> expressions, Object bindingBean) {
|
||||||
// cancel old workers and clear model
|
// cancel old workers and clear model
|
||||||
clear();
|
clear();
|
||||||
@ -491,7 +473,6 @@ class BindingDialog extends JDialog {
|
|||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
for (Evaluator evaluator : model) {
|
for (Evaluator evaluator : model) {
|
||||||
evaluator.cancel(true);
|
evaluator.cancel(true);
|
||||||
@ -503,7 +484,6 @@ class BindingDialog extends JDialog {
|
|||||||
fireTableDataChanged();
|
fireTableDataChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void fireTableCellUpdated(Evaluator element) {
|
public void fireTableCellUpdated(Evaluator element) {
|
||||||
int index = model.indexOf(element);
|
int index = model.indexOf(element);
|
||||||
|
|
||||||
@ -512,7 +492,6 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
@ -525,19 +504,16 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return model.size();
|
return model.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getColumnClass(int column) {
|
public Class<?> getColumnClass(int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
@ -550,7 +526,6 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
@ -564,29 +539,24 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class ParameterTableModel extends AbstractTableModel {
|
private static class ParameterTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
private final List<Entry<?, ?>> data;
|
private final List<Entry<?, ?>> data;
|
||||||
|
|
||||||
|
|
||||||
public ParameterTableModel(Map<?, ?> data) {
|
public ParameterTableModel(Map<?, ?> data) {
|
||||||
this.data = new ArrayList<Entry<?, ?>>(data.entrySet());
|
this.data = new ArrayList<Entry<?, ?>>(data.entrySet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getRowCount() {
|
public int getRowCount() {
|
||||||
return data.size();
|
return data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColumnCount() {
|
public int getColumnCount() {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
@ -599,7 +569,6 @@ class BindingDialog extends JDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
parameter.exclude: ^StreamKind|Count$
|
parameter.exclude: ^StreamKind|Count$
|
||||||
|
|
||||||
# preview expressions (keys are tagged so they can be sorted alphabetically)
|
# preview expressions (keys are tagged so they can be sorted alphabetically)
|
||||||
expressions: n,y,s,e,t,d,startdate,absolute,special,imdbid,episode,sxe,s00e00,movie,vc,ac,cf,vf,af,resolution,hpi,ws,sdhd,source,group,crc32,fn,ext,file,pi,pn,lang,actors,director,collection,genres,certification,rating,dim,info.runtime,info.status,imdb.rating,imdb.votes,media.title,media.durationString,media.overallBitRateString,video.codecID,video.frameRate,video.displayAspectRatioString,video.height,video.scanType,audio.format,audio.bitRateString,audio.language,text.codecInfo,text.language
|
expressions: n,y,s,e,es,sxe,s00e00,t,d,startdate,absolute,special,episode,series,primaryTitle,alias,movie,tmdbid,imdbid,music,artist,albumArtist,album,pi,pn,lang,actors,director,collection,genres,certification,rating,vc,ac,cf,vf,hpi,af,resolution,dim,ws,sdhd,source,group,original,fn,ext,file,file.name,folder,folder.name,crc32,info,info.runtime,info.status,imdb,imdb.rating,imdb.votes,duration,seconds,minutes,media,media.title,media.overallBitRateString,video,video.codecID,video.frameRate,video.displayAspectRatioString,video.scanType,audio,audio.bitRateString,audio.language,audios,audios.language,text,text.codecInfo,text.language,texts,texts.language
|
@ -88,11 +88,12 @@ import com.cedarsoftware.util.io.JsonWriter;
|
|||||||
public class FormatDialog extends JDialog {
|
public class FormatDialog extends JDialog {
|
||||||
|
|
||||||
private boolean submit = false;
|
private boolean submit = false;
|
||||||
|
|
||||||
private Mode mode;
|
|
||||||
private ExpressionFormat format;
|
private ExpressionFormat format;
|
||||||
|
|
||||||
private MediaBindingBean sample;
|
private Mode mode;
|
||||||
|
private boolean locked = false;
|
||||||
|
private MediaBindingBean sample = null;
|
||||||
|
|
||||||
private ExecutorService executor = createExecutor();
|
private ExecutorService executor = createExecutor();
|
||||||
private RunnableFuture<String> currentPreviewFuture;
|
private RunnableFuture<String> currentPreviewFuture;
|
||||||
|
|
||||||
@ -233,6 +234,7 @@ public class FormatDialog extends JDialog {
|
|||||||
|
|
||||||
public void setState(Mode mode, MediaBindingBean bindings, boolean locked) {
|
public void setState(Mode mode, MediaBindingBean bindings, boolean locked) {
|
||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
|
this.locked = locked;
|
||||||
|
|
||||||
if (locked) {
|
if (locked) {
|
||||||
this.setTitle(String.format("%s Format", mode));
|
this.setTitle(String.format("%s Format", mode));
|
||||||
@ -245,7 +247,6 @@ public class FormatDialog extends JDialog {
|
|||||||
|
|
||||||
switchEditModeAction.putValue(Action.NAME, String.format("Switch to %s Format", mode.next()));
|
switchEditModeAction.putValue(Action.NAME, String.format("Switch to %s Format", mode.next()));
|
||||||
switchEditModeAction.setEnabled(!locked);
|
switchEditModeAction.setEnabled(!locked);
|
||||||
changeSampleAction.setEnabled(!locked);
|
|
||||||
|
|
||||||
updateHelpPanel(mode);
|
updateHelpPanel(mode);
|
||||||
|
|
||||||
@ -606,7 +607,7 @@ public class FormatDialog extends JDialog {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
BindingDialog dialog = new BindingDialog(getWindow(evt.getSource()), String.format("%s Bindings", mode), mode.getFormat());
|
BindingDialog dialog = new BindingDialog(getWindow(evt.getSource()), String.format("%s Bindings", mode), mode.getFormat(), !locked);
|
||||||
|
|
||||||
dialog.setInfoObject(sample.getInfoObject());
|
dialog.setInfoObject(sample.getInfoObject());
|
||||||
dialog.setMediaFile(sample.getMediaFile());
|
dialog.setMediaFile(sample.getMediaFile());
|
||||||
|
Loading…
Reference in New Issue
Block a user