Deleted source/net/sourceforge/filebot/ui/sal

This commit is contained in:
Reinhard Pointner 2007-12-26 16:43:16 +00:00
parent 490101af81
commit 55f79f4930
5 changed files with 0 additions and 211 deletions

View File

@ -1,49 +0,0 @@
package net.sourceforge.filebot.ui.sal;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class FileTransferable implements Transferable {
private List<File> files;
public FileTransferable(File... fileArray) {
files = new ArrayList<File>(fileArray.length);
for (File file : fileArray)
files.add(file);
}
public FileTransferable(List<File> files) {
this.files = files;
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
if (!isDataFlavorSupported(flavor))
throw new UnsupportedFlavorException(flavor);
return files;
}
public DataFlavor[] getTransferDataFlavors() {
DataFlavor[] flavours = { DataFlavor.javaFileListFlavor };
return flavours;
}
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.isFlavorJavaFileListType();
}
}

View File

@ -1,47 +0,0 @@
package net.sourceforge.filebot.ui.sal;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import net.sourceforge.filebot.resources.ResourceManager;
import net.sourceforge.filebot.ui.transferablepolicies.TransferablePolicy;
import net.sourceforge.filebot.ui.transferablepolicies.TransferablePolicySupport;
public class LoadAction extends AbstractAction {
private TransferablePolicySupport transferablePolicySupport;
public LoadAction(TransferablePolicySupport transferablePolicySupport) {
super("Load", ResourceManager.getIcon("action.load"));
this.transferablePolicySupport = transferablePolicySupport;
}
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new TransferablePolicyFileFilter(transferablePolicySupport.getTransferablePolicy()));
chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
chooser.setMultiSelectionEnabled(true);
if (chooser.showOpenDialog(null) != JFileChooser.APPROVE_OPTION)
return;
FileTransferable transferable = new FileTransferable(chooser.getSelectedFiles());
TransferablePolicy transferablePolicy = transferablePolicySupport.getTransferablePolicy();
boolean add = ((e.getModifiers() & ActionEvent.CTRL_MASK) != 0);
if (transferablePolicy.accept(transferable))
transferablePolicy.handleTransferable(transferable, add);
}
}

View File

@ -1,55 +0,0 @@
package net.sourceforge.filebot.ui.sal;
import java.awt.event.ActionEvent;
import java.io.File;
import javax.swing.AbstractAction;
import javax.swing.JFileChooser;
import net.sourceforge.filebot.resources.ResourceManager;
public class SaveAction extends AbstractAction {
protected Saveable saveable;
public SaveAction(Saveable saveable) {
super("Save as ...", ResourceManager.getIcon("action.save"));
this.saveable = saveable;
}
protected void save(File file) {
saveable.save(file);
}
protected String getDefaultFileName() {
return saveable.getDefaultFileName();
}
protected boolean isSaveable() {
return saveable.isSaveable();
}
public void actionPerformed(ActionEvent e) {
if (!isSaveable())
return;
JFileChooser chooser = new JFileChooser();
chooser.setMultiSelectionEnabled(false);
chooser.setSelectedFile(new File(getDefaultFileName()));
if (chooser.showSaveDialog(null) != JFileChooser.APPROVE_OPTION)
return;
save(chooser.getSelectedFile());
}
}

View File

@ -1,17 +0,0 @@
package net.sourceforge.filebot.ui.sal;
import java.io.File;
public interface Saveable {
public void save(File file);
public boolean isSaveable();
public String getDefaultFileName();
}

View File

@ -1,43 +0,0 @@
package net.sourceforge.filebot.ui.sal;
import java.io.File;
import javax.swing.filechooser.FileFilter;
import net.sourceforge.filebot.ui.transferablepolicies.FileTransferablePolicy;
import net.sourceforge.filebot.ui.transferablepolicies.MultiTransferablePolicy;
import net.sourceforge.filebot.ui.transferablepolicies.TransferablePolicy;
public class TransferablePolicyFileFilter extends FileFilter {
private TransferablePolicy transferablePolicy;
public TransferablePolicyFileFilter(TransferablePolicy transferablePolicy) {
this.transferablePolicy = transferablePolicy;
}
@Override
public boolean accept(File f) {
if (f.isDirectory())
return true;
return transferablePolicy.accept(new FileTransferable(f));
}
@Override
public String getDescription() {
if (transferablePolicy instanceof MultiTransferablePolicy) {
MultiTransferablePolicy multi = (MultiTransferablePolicy) transferablePolicy;
return multi.getDescription(FileTransferablePolicy.class);
}
return transferablePolicy.getDescription();
}
}