Package ui.tabs.search

Source Code of ui.tabs.search.DownloadableFileJTable$DoubleClickListener

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()));
      }
    }

  }

}
TOP

Related Classes of ui.tabs.search.DownloadableFileJTable$DoubleClickListener

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.