* 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
1 changed files with 13 additions and 21 deletions

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,30 +14,25 @@ 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");
@ -49,26 +42,25 @@ public class LoadAction extends AbstractAction {
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));