1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-11-10 11:25:04 -05:00

* actively discourage people from using the "Load" button and tell them to use Drag-and-Drop instead

This commit is contained in:
Reinhard Pointner 2013-10-02 16:42:52 +00:00
parent ffc629943b
commit ee4e373eb1

View File

@ -1,7 +1,5 @@
package net.sourceforge.filebot.ui.transfer;
import static net.sourceforge.filebot.ui.NotificationLogging.*;
import java.awt.event.ActionEvent;
@ -16,59 +14,53 @@ import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.Settings;
import net.sourceforge.filebot.ui.transfer.TransferablePolicy.TransferAction;
public class LoadAction extends AbstractAction {
public static final String TRANSFERABLE_POLICY = "transferablePolicy";
public LoadAction(TransferablePolicy transferablePolicy) {
this("Load", ResourceManager.getIcon("action.load"), transferablePolicy);
}
public LoadAction(String name, Icon icon, TransferablePolicy transferablePolicy) {
putValue(NAME, name);
putValue(SMALL_ICON, icon);
putValue(TRANSFERABLE_POLICY, transferablePolicy);
}
public TransferAction getTransferAction(ActionEvent evt) {
// if CTRL was pressed when the button was clicked, assume ADD action (same as with dnd)
return ((evt.getModifiers() & ActionEvent.CTRL_MASK) != 0) ? TransferAction.ADD : TransferAction.PUT;
}
protected File getDefaultFolder() {
String lastLocation = Settings.forPackage(LoadAction.class).get("load.location");
if (lastLocation == null || lastLocation.isEmpty())
return null;
return new File(lastLocation);
}
public void actionPerformed(ActionEvent evt) {
// get transferable policy from action properties
TransferablePolicy transferablePolicy = (TransferablePolicy) getValue(TRANSFERABLE_POLICY);
if (transferablePolicy == null)
return;
JFileChooser chooser = new JFileChooser(getDefaultFolder());
chooser.setFileFilter(new TransferablePolicyFileFilter(transferablePolicy));
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setMultiSelectionEnabled(true);
if (chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
// tell noobs to use drag-n-drop
UILogger.info("Why do you not use drag-and-drop to directly drop in your files?");
if (chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION) {
return;
}
FileTransferable transferable = new FileTransferable(chooser.getSelectedFiles());
try {
if (transferablePolicy.accept(transferable)) {
transferablePolicy.handleTransferable(transferable, getTransferAction(evt));
@ -76,9 +68,9 @@ public class LoadAction extends AbstractAction {
} catch (Exception e) {
UILogger.log(Level.WARNING, e.getMessage(), e);
}
// remember last location
Settings.forPackage(LoadAction.class).put("load.location", chooser.getCurrentDirectory().getPath());
}
}