* hot fix for Folder Drop / Link Drop regression bug

@see http://www.filebot.net/forums/viewtopic.php?f=6&t=2054&p=11854#p11852
This commit is contained in:
Reinhard Pointner 2014-10-11 15:15:05 +00:00
parent e20425e978
commit 5485004130
8 changed files with 23 additions and 27 deletions

View File

@ -52,7 +52,7 @@ class FileTreeTransferablePolicy extends BackgroundFileTransferablePolicy<TreeNo
} }
@Override @Override
protected void load(List<File> files) { protected void load(List<File> files, TransferAction action) {
try { try {
if (files.size() > 1 || containsOnly(files, FILES)) { if (files.size() > 1 || containsOnly(files, FILES)) {
files = Arrays.asList(files.get(0).getParentFile()); files = Arrays.asList(files.get(0).getParentFile());

View File

@ -33,7 +33,7 @@ class FileListTransferablePolicy extends FileTransferablePolicy {
} }
@Override @Override
protected void load(List<File> files) throws IOException { protected void load(List<File> files, TransferAction action) throws IOException {
// set title based on parent folder of first file // set title based on parent folder of first file
list.setTitle(FileUtilities.getFolderName(files.get(0).getParentFile())); list.setTitle(FileUtilities.getFolderName(files.get(0).getParentFile()));

View File

@ -3,7 +3,6 @@ package net.filebot.ui.rename;
import static java.util.Arrays.*; import static java.util.Arrays.*;
import static net.filebot.MediaTypes.*; import static net.filebot.MediaTypes.*;
import static net.filebot.ui.NotificationLogging.*; import static net.filebot.ui.NotificationLogging.*;
import static net.filebot.ui.transfer.FileTransferable.*;
import static net.filebot.util.FileUtilities.*; import static net.filebot.util.FileUtilities.*;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
@ -40,19 +39,16 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
@Override @Override
public void handleTransferable(Transferable tr, TransferAction action) throws Exception { public void handleTransferable(Transferable tr, TransferAction action) throws Exception {
if (action == TransferAction.LINK) { if (action == TransferAction.LINK || action == TransferAction.PUT) {
// special handling for do-not-resolve-folders-drop
clear(); clear();
load(getFilesFromTransferable(tr), false);
} else {
// load files recursively by default
super.handleTransferable(tr, action);
} }
super.handleTransferable(tr, action);
} }
@Override @Override
protected void load(List<File> files) { protected void load(List<File> files, TransferAction action) {
load(files, true); load(files, action != TransferAction.LINK);
} }
protected void load(List<File> files, boolean recursive) { protected void load(List<File> files, boolean recursive) {
@ -111,7 +107,7 @@ class FilesListTransferablePolicy extends BackgroundFileTransferablePolicy<File>
@Override @Override
protected void process(List<File> chunks) { protected void process(List<File> chunks) {
model.addAll(FastFile.create(chunks)); model.addAll(chunks);
} }
@Override @Override

View File

@ -614,7 +614,7 @@ class HistoryDialog extends JDialog {
} }
@Override @Override
protected void load(List<File> files) throws IOException { protected void load(List<File> files, TransferAction action) throws IOException {
History history = getModel(); History history = getModel();
try { try {

View File

@ -61,7 +61,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy {
model.addAll(Arrays.asList((Episode[]) tr.getTransferData((episodeArrayFlavor)))); model.addAll(Arrays.asList((Episode[]) tr.getTransferData((episodeArrayFlavor))));
} else if (hasFileListFlavor(tr)) { } else if (hasFileListFlavor(tr)) {
// file transferable // file transferable
load(getFilesFromTransferable(tr)); load(getFilesFromTransferable(tr), action);
} else if (tr.isDataFlavorSupported(stringFlavor)) { } else if (tr.isDataFlavorSupported(stringFlavor)) {
// string transferable // string transferable
load((String) tr.getTransferData(stringFlavor)); load((String) tr.getTransferData(stringFlavor));
@ -83,7 +83,7 @@ class NamesListTransferablePolicy extends FileTransferablePolicy {
} }
@Override @Override
protected void load(List<File> files) throws IOException { protected void load(List<File> files, TransferAction action) throws IOException {
List<Object> values = new ArrayList<Object>(); List<Object> values = new ArrayList<Object>();
if (containsOnly(files, LIST_FILES)) { if (containsOnly(files, LIST_FILES)) {

View File

@ -46,10 +46,11 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
} }
@Override @Override
protected void prepare(List<File> files) { protected void handleInBackground(List<File> files, TransferAction action) {
if (files.size() == 1 && getHashType(files.get(0)) != null) { if (files.size() == 1 && getHashType(files.get(0)) != null) {
model.setHashType(getHashType(files.get(0))); model.setHashType(getHashType(files.get(0)));
} }
super.handleInBackground(files, action);
} }
@Override @Override
@ -66,7 +67,7 @@ class ChecksumTableTransferablePolicy extends BackgroundFileTransferablePolicy<C
private final ThreadLocal<VerificationTracker> verificationTracker = new ThreadLocal<VerificationTracker>(); private final ThreadLocal<VerificationTracker> verificationTracker = new ThreadLocal<VerificationTracker>();
@Override @Override
protected void load(List<File> files) throws IOException { protected void load(List<File> files, TransferAction action) throws IOException {
// initialize drop parameters // initialize drop parameters
executor.set(computationService.newExecutor()); executor.set(computationService.newExecutor());
verificationTracker.set(new VerificationTracker(3)); verificationTracker.set(new VerificationTracker(3));

View File

@ -29,14 +29,11 @@ public abstract class BackgroundFileTransferablePolicy<V> extends FileTransferab
clear(); clear();
} }
prepare(files); handleInBackground(files, action);
// create and start worker
new BackgroundWorker(files).execute();
} }
protected void prepare(List<File> files) { protected void handleInBackground(List<File> files, TransferAction action) {
new BackgroundWorker(files, action).execute();
} }
@Override @Override
@ -91,9 +88,11 @@ public abstract class BackgroundFileTransferablePolicy<V> extends FileTransferab
protected class BackgroundWorker extends SwingWorker<Object, V> { protected class BackgroundWorker extends SwingWorker<Object, V> {
private final List<File> files; private final List<File> files;
private final TransferAction action;
public BackgroundWorker(List<File> files) { public BackgroundWorker(List<File> files, TransferAction action) {
this.files = files; this.files = files;
this.action = action;
// register this worker // register this worker
synchronized (workers) { synchronized (workers) {
@ -109,7 +108,7 @@ public abstract class BackgroundFileTransferablePolicy<V> extends FileTransferab
threadLocalWorker.set(this); threadLocalWorker.set(this);
try { try {
load(files); load(files, action);
} finally { } finally {
threadLocalWorker.remove(); threadLocalWorker.remove();
} }

View File

@ -37,12 +37,12 @@ public abstract class FileTransferablePolicy extends TransferablePolicy {
clear(); clear();
} }
load(files); load(files, action);
} }
protected abstract boolean accept(List<File> files); protected abstract boolean accept(List<File> files);
protected abstract void load(List<File> files) throws IOException; protected abstract void load(List<File> files, TransferAction action) throws IOException;
protected abstract void clear(); protected abstract void clear();