* fix labels
This commit is contained in:
parent
a268627acf
commit
3816572ebf
|
@ -20,8 +20,8 @@ import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.ResourceBundle;
|
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.ResourceBundle;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
@ -58,8 +58,8 @@ import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.format.ExpressionFormat;
|
import net.sourceforge.filebot.format.ExpressionFormat;
|
||||||
import net.sourceforge.filebot.format.MediaBindingBean;
|
import net.sourceforge.filebot.format.MediaBindingBean;
|
||||||
import net.sourceforge.filebot.mediainfo.MediaInfo;
|
import net.sourceforge.filebot.mediainfo.MediaInfo;
|
||||||
import net.sourceforge.filebot.mediainfo.MediaInfoException;
|
|
||||||
import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind;
|
import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ class BindingDialog extends JDialog {
|
||||||
|
|
||||||
private boolean submit = false;
|
private boolean submit = false;
|
||||||
|
|
||||||
|
|
||||||
public BindingDialog(Window owner, String title, Format infoObjectFormat) {
|
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;
|
||||||
|
@ -89,7 +89,7 @@ class BindingDialog extends JDialog {
|
||||||
JPanel inputPanel = new JPanel(new MigLayout("nogrid, fill"));
|
JPanel inputPanel = new JPanel(new MigLayout("nogrid, fill"));
|
||||||
inputPanel.setOpaque(false);
|
inputPanel.setOpaque(false);
|
||||||
|
|
||||||
inputPanel.add(new JLabel("Episode:"), "wrap 2px");
|
inputPanel.add(new JLabel("Name:"), "wrap 2px");
|
||||||
inputPanel.add(infoTextField, "hmin 20px, growx, wrap paragraph");
|
inputPanel.add(infoTextField, "hmin 20px, growx, wrap paragraph");
|
||||||
|
|
||||||
inputPanel.add(new JLabel("Media File:"), "wrap 2px");
|
inputPanel.add(new JLabel("Media File:"), "wrap 2px");
|
||||||
|
@ -97,7 +97,7 @@ class BindingDialog extends JDialog {
|
||||||
inputPanel.add(createImageButton(mediaInfoAction), "gap rel, w 26px!, h 24px!");
|
inputPanel.add(createImageButton(mediaInfoAction), "gap rel, w 26px!, h 24px!");
|
||||||
inputPanel.add(createImageButton(selectFileAction), "gap rel, w 26px!, h 24px!, wrap paragraph");
|
inputPanel.add(createImageButton(selectFileAction), "gap rel, w 26px!, h 24px!, wrap paragraph");
|
||||||
|
|
||||||
inputContainer.add("Episode Bindings", inputPanel);
|
inputContainer.add("Bindings", inputPanel);
|
||||||
root.add(inputContainer, "growx, wrap paragraph");
|
root.add(inputContainer, "growx, wrap paragraph");
|
||||||
|
|
||||||
root.add(new JLabel("Preview:"), "gap 5px, wrap 2px");
|
root.add(new JLabel("Preview:"), "gap 5px, wrap 2px");
|
||||||
|
@ -134,13 +134,13 @@ 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);
|
||||||
|
@ -161,7 +161,7 @@ class BindingDialog extends JDialog {
|
||||||
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);
|
||||||
|
@ -208,18 +208,18 @@ 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;
|
||||||
|
|
||||||
|
@ -230,17 +230,17 @@ class BindingDialog extends JDialog {
|
||||||
dispose();
|
dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setInfoObject(Object info) {
|
public void setInfoObject(Object 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() {
|
||||||
try {
|
try {
|
||||||
return infoObjectFormat.parseObject(infoTextField.getText());
|
return infoObjectFormat.parseObject(infoTextField.getText());
|
||||||
|
@ -249,7 +249,7 @@ class BindingDialog extends JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public File getMediaFile() {
|
public File getMediaFile() {
|
||||||
File file = new File(mediaFileTextField.getText());
|
File file = new File(mediaFileTextField.getText());
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@ class BindingDialog extends JDialog {
|
||||||
return file.isAbsolute() ? file : null;
|
return file.isAbsolute() ? file : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
@ -306,7 +306,7 @@ 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());
|
||||||
|
@ -388,24 +388,24 @@ 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) {
|
||||||
|
@ -428,7 +428,7 @@ class BindingDialog extends JDialog {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
try {
|
try {
|
||||||
|
@ -439,14 +439,14 @@ 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();
|
||||||
|
@ -471,7 +471,7 @@ 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);
|
||||||
|
@ -483,7 +483,7 @@ 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);
|
||||||
|
|
||||||
|
@ -492,7 +492,7 @@ class BindingDialog extends JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getColumnName(int column) {
|
public String getColumnName(int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
@ -505,19 +505,19 @@ 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) {
|
||||||
|
@ -530,7 +530,7 @@ class BindingDialog extends JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
@ -544,29 +544,29 @@ 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) {
|
||||||
|
@ -579,7 +579,7 @@ class BindingDialog extends JDialog {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValueAt(int row, int column) {
|
public Object getValueAt(int row, int column) {
|
||||||
switch (column) {
|
switch (column) {
|
||||||
|
|
Loading…
Reference in New Issue