mirror of
https://github.com/mitb-archive/filebot
synced 2025-01-11 05:48:01 -05:00
* fixed wierd keystroke behaviour where one keystroke would affect multiple dialogs in a row
This commit is contained in:
parent
6aea967566
commit
3668b02ed5
@ -37,7 +37,7 @@ public class SelectDialog<T> extends JDialog {
|
||||
|
||||
private boolean valueSelected = false;
|
||||
|
||||
|
||||
|
||||
public SelectDialog(Component parent, Collection<? extends T> options) {
|
||||
super(getWindow(parent), "Select", ModalityType.DOCUMENT_MODAL);
|
||||
|
||||
@ -77,20 +77,20 @@ public class SelectDialog<T> extends JDialog {
|
||||
setSize(new Dimension(210, 210));
|
||||
|
||||
// Shortcut Enter
|
||||
TunedUtilities.installAction(list, KeyStroke.getKeyStroke("released ENTER"), selectAction);
|
||||
TunedUtilities.installAction(list, KeyStroke.getKeyStroke("ENTER"), selectAction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected String convertValueToString(Object value) {
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public JLabel getHeaderLabel() {
|
||||
return headerLabel;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T getSelectedValue() {
|
||||
if (!valueSelected)
|
||||
@ -99,23 +99,23 @@ public class SelectDialog<T> extends JDialog {
|
||||
return (T) list.getSelectedValue();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void close() {
|
||||
setVisible(false);
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Action getSelectAction() {
|
||||
return selectAction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Action getCancelAction() {
|
||||
return cancelAction;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final Action selectAction = new AbstractAction("Select", ResourceManager.getIcon("dialog.continue")) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
@ -29,7 +29,7 @@ class FileTreePanel extends JComponent {
|
||||
|
||||
private FileTreeTransferablePolicy transferablePolicy = new FileTreeTransferablePolicy(fileTree);
|
||||
|
||||
|
||||
|
||||
public FileTreePanel() {
|
||||
fileTree.setTransferHandler(new DefaultTransferHandler(transferablePolicy, null));
|
||||
|
||||
@ -62,20 +62,20 @@ class FileTreePanel extends JComponent {
|
||||
});
|
||||
|
||||
// Shortcut DELETE
|
||||
TunedUtilities.installAction(fileTree, KeyStroke.getKeyStroke("pressed DELETE"), removeAction);
|
||||
TunedUtilities.installAction(fileTree, KeyStroke.getKeyStroke("DELETE"), removeAction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FileTree getFileTree() {
|
||||
return fileTree;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public FileTreeTransferablePolicy getTransferablePolicy() {
|
||||
return transferablePolicy;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final LoadAction loadAction = new LoadAction(transferablePolicy);
|
||||
|
||||
private final AbstractAction clearAction = new AbstractAction("Clear", ResourceManager.getIcon("action.clear")) {
|
||||
@ -108,7 +108,7 @@ class FileTreePanel extends JComponent {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
private void fireFileTreeChange() {
|
||||
firePropertyChange("filetree", null, fileTree);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ class ValidateDialog extends JDialog {
|
||||
|
||||
private boolean cancelled = true;
|
||||
|
||||
|
||||
|
||||
public ValidateDialog(Window owner, Collection<File> source) {
|
||||
super(owner, "Invalid Names", ModalityType.DOCUMENT_MODAL);
|
||||
|
||||
@ -92,24 +92,24 @@ class ValidateDialog extends JDialog {
|
||||
content.add(new JButton(continueAction), "gap related");
|
||||
content.add(new JButton(cancelAction), "gap 12mm");
|
||||
|
||||
installAction(content, KeyStroke.getKeyStroke("released ESCAPE"), cancelAction);
|
||||
installAction(content, KeyStroke.getKeyStroke("ESCAPE"), cancelAction);
|
||||
|
||||
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
|
||||
setMinimumSize(new Dimension(365, 280));
|
||||
pack();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public List<File> getModel() {
|
||||
return unmodifiableList(Arrays.asList(model));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void finish(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
|
||||
@ -117,7 +117,7 @@ class ValidateDialog extends JDialog {
|
||||
dispose();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final Action validateAction = new AbstractAction("Validate", ResourceManager.getIcon("dialog.continue")) {
|
||||
|
||||
@Override
|
||||
@ -155,7 +155,7 @@ class ValidateDialog extends JDialog {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
public static boolean validate(Component parent, List<File> source) {
|
||||
IndexView<File> invalidFilePaths = new IndexView<File>(source);
|
||||
|
||||
@ -192,24 +192,24 @@ class ValidateDialog extends JDialog {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class IndexView<E> extends AbstractList<E> {
|
||||
|
||||
private final List<Integer> mapping = new ArrayList<Integer>();
|
||||
|
||||
private final List<E> source;
|
||||
|
||||
|
||||
|
||||
public IndexView(List<E> source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public boolean addIndex(int index) {
|
||||
return mapping.add(index);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public E get(int index) {
|
||||
int sourceIndex = mapping.get(index);
|
||||
@ -220,13 +220,13 @@ class ValidateDialog extends JDialog {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public E set(int index, E element) {
|
||||
return source.set(mapping.get(index), element);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
return mapping.size();
|
||||
|
@ -48,7 +48,7 @@ public class SfvPanel extends JComponent {
|
||||
private final ChecksumTableTransferablePolicy transferablePolicy = new ChecksumTableTransferablePolicy(table.getModel(), computationService);
|
||||
private final ChecksumTableExportHandler exportHandler = new ChecksumTableExportHandler(table.getModel());
|
||||
|
||||
|
||||
|
||||
public SfvPanel() {
|
||||
table.setTransferHandler(new DefaultTransferHandler(transferablePolicy, exportHandler));
|
||||
|
||||
@ -90,10 +90,10 @@ public class SfvPanel extends JComponent {
|
||||
putClientProperty("transferablePolicy", transferablePolicy);
|
||||
|
||||
// Shortcut DELETE
|
||||
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("pressed DELETE"), removeAction);
|
||||
TunedUtilities.installAction(this, KeyStroke.getKeyStroke("DELETE"), removeAction);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void restartComputation(HashType hash) {
|
||||
// cancel all running computations
|
||||
computationService.reset();
|
||||
@ -127,7 +127,7 @@ public class SfvPanel extends JComponent {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private final SaveAction saveAction = new ChecksumTableSaveAction();
|
||||
|
||||
private final LoadAction loadAction = new LoadAction(transferablePolicy);
|
||||
@ -176,7 +176,7 @@ public class SfvPanel extends JComponent {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
protected class ChangeHashTypeAction extends AbstractAction implements PropertyChangeListener {
|
||||
|
||||
private ChangeHashTypeAction(HashType hash) {
|
||||
@ -190,13 +190,13 @@ public class SfvPanel extends JComponent {
|
||||
table.getModel().addPropertyChangeListener(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
table.getModel().setHashType((HashType) getValue(HASH_TYPE_PROPERTY));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
if (LOADING_PROPERTY.equals(evt.getPropertyName())) {
|
||||
@ -210,48 +210,48 @@ public class SfvPanel extends JComponent {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected class ChecksumTableSaveAction extends SaveAction {
|
||||
|
||||
private File selectedColumn = null;
|
||||
|
||||
|
||||
|
||||
public ChecksumTableSaveAction() {
|
||||
super(exportHandler);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ChecksumTableExportHandler getExportHandler() {
|
||||
return (ChecksumTableExportHandler) super.getExportHandler();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean canExport() {
|
||||
return selectedColumn != null && super.canExport();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void export(File file) throws IOException {
|
||||
getExportHandler().export(file, selectedColumn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected String getDefaultFileName() {
|
||||
return getExportHandler().getDefaultFileName(selectedColumn);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected File getDefaultFolder() {
|
||||
// use the column root as default folder in the file dialog
|
||||
return selectedColumn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
List<File> options = new ArrayList<File>();
|
||||
|
Loading…
Reference in New Issue
Block a user