From ee4e373eb19e69265e249093b64dbf4b96cc995d Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Wed, 2 Oct 2013 16:42:52 +0000 Subject: [PATCH] * actively discourage people from using the "Load" button and tell them to use Drag-and-Drop instead --- .../filebot/ui/transfer/LoadAction.java | 34 +++++++------------ 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/source/net/sourceforge/filebot/ui/transfer/LoadAction.java b/source/net/sourceforge/filebot/ui/transfer/LoadAction.java index 8f66ec81..4021a707 100644 --- a/source/net/sourceforge/filebot/ui/transfer/LoadAction.java +++ b/source/net/sourceforge/filebot/ui/transfer/LoadAction.java @@ -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()); } - + }