* actively discourage people from using the "Load" button and tell them to use Drag-and-Drop instead
This commit is contained in:
parent
ffc629943b
commit
ee4e373eb1
|
@ -1,7 +1,5 @@
|
||||||
|
|
||||||
package net.sourceforge.filebot.ui.transfer;
|
package net.sourceforge.filebot.ui.transfer;
|
||||||
|
|
||||||
|
|
||||||
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
import static net.sourceforge.filebot.ui.NotificationLogging.*;
|
||||||
|
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
|
@ -16,30 +14,25 @@ import net.sourceforge.filebot.ResourceManager;
|
||||||
import net.sourceforge.filebot.Settings;
|
import net.sourceforge.filebot.Settings;
|
||||||
import net.sourceforge.filebot.ui.transfer.TransferablePolicy.TransferAction;
|
import net.sourceforge.filebot.ui.transfer.TransferablePolicy.TransferAction;
|
||||||
|
|
||||||
|
|
||||||
public class LoadAction extends AbstractAction {
|
public class LoadAction extends AbstractAction {
|
||||||
|
|
||||||
public static final String TRANSFERABLE_POLICY = "transferablePolicy";
|
public static final String TRANSFERABLE_POLICY = "transferablePolicy";
|
||||||
|
|
||||||
|
|
||||||
public LoadAction(TransferablePolicy transferablePolicy) {
|
public LoadAction(TransferablePolicy transferablePolicy) {
|
||||||
this("Load", ResourceManager.getIcon("action.load"), transferablePolicy);
|
this("Load", ResourceManager.getIcon("action.load"), transferablePolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LoadAction(String name, Icon icon, TransferablePolicy transferablePolicy) {
|
public LoadAction(String name, Icon icon, TransferablePolicy transferablePolicy) {
|
||||||
putValue(NAME, name);
|
putValue(NAME, name);
|
||||||
putValue(SMALL_ICON, icon);
|
putValue(SMALL_ICON, icon);
|
||||||
putValue(TRANSFERABLE_POLICY, transferablePolicy);
|
putValue(TRANSFERABLE_POLICY, transferablePolicy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TransferAction getTransferAction(ActionEvent evt) {
|
public TransferAction getTransferAction(ActionEvent evt) {
|
||||||
// if CTRL was pressed when the button was clicked, assume ADD action (same as with dnd)
|
// 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;
|
return ((evt.getModifiers() & ActionEvent.CTRL_MASK) != 0) ? TransferAction.ADD : TransferAction.PUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected File getDefaultFolder() {
|
protected File getDefaultFolder() {
|
||||||
String lastLocation = Settings.forPackage(LoadAction.class).get("load.location");
|
String lastLocation = Settings.forPackage(LoadAction.class).get("load.location");
|
||||||
|
|
||||||
|
@ -49,26 +42,25 @@ public class LoadAction extends AbstractAction {
|
||||||
return new File(lastLocation);
|
return new File(lastLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
public void actionPerformed(ActionEvent evt) {
|
||||||
// get transferable policy from action properties
|
// get transferable policy from action properties
|
||||||
TransferablePolicy transferablePolicy = (TransferablePolicy) getValue(TRANSFERABLE_POLICY);
|
TransferablePolicy transferablePolicy = (TransferablePolicy) getValue(TRANSFERABLE_POLICY);
|
||||||
|
|
||||||
if (transferablePolicy == null)
|
if (transferablePolicy == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
JFileChooser chooser = new JFileChooser(getDefaultFolder());
|
JFileChooser chooser = new JFileChooser(getDefaultFolder());
|
||||||
|
|
||||||
chooser.setFileFilter(new TransferablePolicyFileFilter(transferablePolicy));
|
chooser.setFileFilter(new TransferablePolicyFileFilter(transferablePolicy));
|
||||||
|
|
||||||
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
|
||||||
chooser.setMultiSelectionEnabled(true);
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FileTransferable transferable = new FileTransferable(chooser.getSelectedFiles());
|
FileTransferable transferable = new FileTransferable(chooser.getSelectedFiles());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (transferablePolicy.accept(transferable)) {
|
if (transferablePolicy.accept(transferable)) {
|
||||||
transferablePolicy.handleTransferable(transferable, getTransferAction(evt));
|
transferablePolicy.handleTransferable(transferable, getTransferAction(evt));
|
||||||
|
|
Loading…
Reference in New Issue