mirror of
https://github.com/mitb-archive/filebot
synced 2024-12-25 17:28:51 -05:00
* added Original Folder column in HistoryDialog
This commit is contained in:
parent
92193a153d
commit
9596ffffe7
@ -1,7 +1,5 @@
|
||||
|
||||
package net.sourceforge.filebot.ui.rename;
|
||||
|
||||
|
||||
import static java.awt.Font.*;
|
||||
import static java.util.Collections.*;
|
||||
import static java.util.regex.Pattern.*;
|
||||
@ -82,7 +80,6 @@ import net.sourceforge.tuned.ui.LazyDocumentListener;
|
||||
import net.sourceforge.tuned.ui.notification.SeparatorBorder;
|
||||
import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position;
|
||||
|
||||
|
||||
class HistoryDialog extends JDialog {
|
||||
|
||||
private final JLabel infoLabel = new JLabel();
|
||||
@ -97,7 +94,6 @@ class HistoryDialog extends JDialog {
|
||||
|
||||
private final JTable elementTable = createTable(elementModel);
|
||||
|
||||
|
||||
public HistoryDialog(Window owner) {
|
||||
super(owner, "Rename History", ModalityType.DOCUMENT_MODAL);
|
||||
|
||||
@ -185,7 +181,6 @@ class HistoryDialog extends JDialog {
|
||||
|
||||
private final DateFormat format = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT);
|
||||
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
return super.getTableCellRendererComponent(table, format.format(value), isSelected, hasFocus, row, column);
|
||||
@ -250,7 +245,6 @@ class HistoryDialog extends JDialog {
|
||||
setSize(580, 640);
|
||||
}
|
||||
|
||||
|
||||
public void setModel(History history) {
|
||||
// update table model
|
||||
sequenceModel.setData(history.sequences());
|
||||
@ -267,17 +261,14 @@ class HistoryDialog extends JDialog {
|
||||
initializeInfoLabel();
|
||||
}
|
||||
|
||||
|
||||
public History getModel() {
|
||||
return new History(sequenceModel.getData());
|
||||
}
|
||||
|
||||
|
||||
public JLabel getInfoLabel() {
|
||||
return infoLabel;
|
||||
}
|
||||
|
||||
|
||||
private void initializeInfoLabel() {
|
||||
int count = 0;
|
||||
Date since = new Date();
|
||||
@ -292,7 +283,6 @@ class HistoryDialog extends JDialog {
|
||||
infoLabel.setText(String.format("A total of %,d files have been renamed since %s.", count, DateFormat.getDateInstance().format(since)));
|
||||
}
|
||||
|
||||
|
||||
private JScrollPane createScrollPaneGroup(String title, JComponent component) {
|
||||
JScrollPane scrollPane = new JScrollPane(component);
|
||||
scrollPane.setBorder(new CompoundBorder(new TitledBorder(title), scrollPane.getBorder()));
|
||||
@ -300,7 +290,6 @@ class HistoryDialog extends JDialog {
|
||||
return scrollPane;
|
||||
}
|
||||
|
||||
|
||||
private JTable createTable(TableModel model) {
|
||||
JTable table = new JTable(model);
|
||||
table.setBackground(Color.white);
|
||||
@ -342,13 +331,11 @@ class HistoryDialog extends JDialog {
|
||||
maybeShowPopup(e);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
maybeShowPopup(e);
|
||||
}
|
||||
|
||||
|
||||
private void maybeShowPopup(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
JTable table = (JTable) e.getSource();
|
||||
@ -388,14 +375,12 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private class RevertCurrentSelectionAction extends RevertAction {
|
||||
|
||||
public RevertCurrentSelectionAction() {
|
||||
super("Revert Selection", HistoryDialog.this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Element> elements() {
|
||||
List<Element> selection = new ArrayList<Element>();
|
||||
@ -416,45 +401,37 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class RevertSelectionAction extends RevertAction {
|
||||
|
||||
public static final String ELEMENTS = "elements";
|
||||
|
||||
|
||||
public RevertSelectionAction(Collection<Element> elements) {
|
||||
super("Revert...", HistoryDialog.this);
|
||||
putValue(ELEMENTS, elements.toArray(new Element[0]));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Element> elements() {
|
||||
return Arrays.asList((Element[]) getValue(ELEMENTS));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static abstract class RevertAction extends AbstractAction {
|
||||
|
||||
public static final String PARENT = "parent";
|
||||
|
||||
|
||||
public RevertAction(String name, HistoryDialog parent) {
|
||||
putValue(NAME, name);
|
||||
putValue(SMALL_ICON, ResourceManager.getIcon("action.revert"));
|
||||
putValue(PARENT, parent);
|
||||
}
|
||||
|
||||
|
||||
public abstract List<Element> elements();
|
||||
|
||||
|
||||
public HistoryDialog parent() {
|
||||
return (HistoryDialog) getValue(PARENT);
|
||||
}
|
||||
|
||||
|
||||
private enum Option {
|
||||
Rename {
|
||||
|
||||
@ -479,7 +456,6 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<Element> elements = elements();
|
||||
@ -553,7 +529,6 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void rename(File directory, List<Element> elements) {
|
||||
int count = 0;
|
||||
|
||||
@ -580,7 +555,6 @@ class HistoryDialog extends JDialog {
|
||||
parent().repaint();
|
||||
}
|
||||
|
||||
|
||||
private Map<File, File> getRenameMap(File directory) {
|
||||
Map<File, File> renameMap = new LinkedHashMap<File, File>();
|
||||
|
||||
@ -604,7 +578,6 @@ class HistoryDialog extends JDialog {
|
||||
return renameMap;
|
||||
}
|
||||
|
||||
|
||||
private List<File> getMissingFiles(File directory) {
|
||||
List<File> missingFiles = new ArrayList<File>();
|
||||
|
||||
@ -624,13 +597,11 @@ class HistoryDialog extends JDialog {
|
||||
return FileUtilities.containsOnly(files, new ExtensionFileFilter("xml"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void clear() {
|
||||
setModel(new History());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void load(List<File> files) throws IOException {
|
||||
History history = getModel();
|
||||
@ -645,7 +616,6 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getFileFilterDescription() {
|
||||
return "history files (.xml)";
|
||||
@ -660,30 +630,25 @@ class HistoryDialog extends JDialog {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void export(File file) throws IOException {
|
||||
History.exportHistory(getModel(), new FileOutputStream(file));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getDefaultFileName() {
|
||||
return "history.xml";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private static class HistoryFilter extends RowFilter<Object, Integer> {
|
||||
|
||||
private final Pattern filter;
|
||||
|
||||
|
||||
public HistoryFilter(String filter) {
|
||||
this.filter = compile(quote(filter), CASE_INSENSITIVE | UNICODE_CASE | CANON_EQ);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean include(Entry<?, ? extends Integer> entry) {
|
||||
// sequence model
|
||||
@ -709,23 +674,19 @@ class HistoryDialog extends JDialog {
|
||||
throw new IllegalArgumentException("Illegal model: " + entry.getModel());
|
||||
}
|
||||
|
||||
|
||||
private boolean include(Element element) {
|
||||
return include(element.to()) || include(element.from()) || include(element.dir().getPath());
|
||||
}
|
||||
|
||||
|
||||
private boolean include(String value) {
|
||||
return filter.matcher(value).find();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class SequenceTableModel extends AbstractTableModel {
|
||||
|
||||
private List<Sequence> data = emptyList();
|
||||
|
||||
|
||||
public void setData(List<Sequence> data) {
|
||||
this.data = new ArrayList<Sequence>(data);
|
||||
|
||||
@ -733,12 +694,10 @@ class HistoryDialog extends JDialog {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
||||
public List<Sequence> getData() {
|
||||
return unmodifiableList(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
switch (column) {
|
||||
@ -755,19 +714,16 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int column) {
|
||||
switch (column) {
|
||||
@ -784,7 +740,6 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row, int column) {
|
||||
switch (column) {
|
||||
@ -801,12 +756,10 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Sequence getRow(int row) {
|
||||
return data.get(row);
|
||||
}
|
||||
|
||||
|
||||
private String getName(Sequence sequence) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
@ -826,12 +779,10 @@ class HistoryDialog extends JDialog {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static class ElementTableModel extends AbstractTableModel {
|
||||
|
||||
private List<Element> data = emptyList();
|
||||
|
||||
|
||||
public void setData(List<Element> data) {
|
||||
this.data = new ArrayList<Element>(data);
|
||||
|
||||
@ -839,7 +790,6 @@ class HistoryDialog extends JDialog {
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column) {
|
||||
switch (column) {
|
||||
@ -850,25 +800,23 @@ class HistoryDialog extends JDialog {
|
||||
case 2:
|
||||
return "Original Name";
|
||||
case 3:
|
||||
return "Directory";
|
||||
default:
|
||||
return "New Folder";
|
||||
case 4:
|
||||
return "Original Folder";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getRowCount() {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int column) {
|
||||
switch (column) {
|
||||
@ -880,11 +828,11 @@ class HistoryDialog extends JDialog {
|
||||
return String.class;
|
||||
case 3:
|
||||
return File.class;
|
||||
default:
|
||||
case 4:
|
||||
return File.class;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int row, int column) {
|
||||
@ -892,22 +840,22 @@ class HistoryDialog extends JDialog {
|
||||
case 0:
|
||||
return row + 1;
|
||||
case 1:
|
||||
return data.get(row).to();
|
||||
return new File(data.get(row).to()).getName();
|
||||
case 2:
|
||||
return data.get(row).from();
|
||||
case 3:
|
||||
return new File(data.get(row).to()).getParentFile();
|
||||
case 4:
|
||||
return data.get(row).dir();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Element getRow(int row) {
|
||||
return data.get(row);
|
||||
}
|
||||
|
||||
|
||||
public boolean isBroken(int row) {
|
||||
Element element = data.get(row);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user