package ui.tabs.search;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import ui.misc.files.MultiNamedFileJTable;
import ui.misc.files.MultiNamedFileTableModel;
import common.files.MultiNamedFile;
import common.files.NamedFile;
import static main.ClientMain.getDownloadManager;
public class DownloadableFileJTable extends MultiNamedFileJTable
{
private static final long serialVersionUID = -689058696028629073L;
private MultiNamedFileTableModel model;
public DownloadableFileJTable()
{
super();
addMouseListener(new DoubleClickListener());
model = new MultiNamedFileTableModel();
setModel(model);
}
public MultiNamedFileTableModel getModel()
{
return model;
}
private class DoubleClickListener extends MouseAdapter
{
public void mouseClicked(MouseEvent event)
{
if ((event.getClickCount() == 2) && !getSelectionModel().isSelectionEmpty())
{
MultiNamedFile file = (MultiNamedFile) getValueAt(getSelectedRow(), 1);
getDownloadManager()
.addDownload(new NamedFile(file, file.getFirstName()));
}
}
}
}