Search in sources :

Example 1 with TorrentSearchResult

use of com.frostwire.search.torrent.TorrentSearchResult in project frostwire by frostwire.

the class SearchResultMediator method buildListeners.

/**
 * Sets all the listeners.
 */
protected void buildListeners() {
    super.buildListeners();
    DOWNLOAD_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (e != null && e.getSource() instanceof JButton) {
                UXStats.instance().log(UXAction.SEARCH_RESULT_BIG_BUTTON_DOWNLOAD);
            }
            SearchMediator.doDownload(SearchResultMediator.this);
        }
    };
    TORRENT_DETAILS_LISTENER = new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1) {
                final SearchResultDataLine[] lines = getAllSelectedLines();
                if (lines.length == 1) {
                    UISearchResult searchResult = lines[0].getSearchResult();
                    searchResult.showDetails(true);
                }
            }
        }
    };
    COPY_MAGNET_ACTION_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            StringBuilder sb = new StringBuilder();
            for (SearchResultDataLine line : lines) {
                sb.append(TorrentUtil.getMagnet(line.getInitializeObject()));
                sb.append("\n");
            }
            GUIMediator.setClipboardContent(sb.toString());
        }
    };
    COPY_HASH_ACTION_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            StringBuilder sb = new StringBuilder();
            for (SearchResultDataLine line : lines) {
                sb.append(line.getInitializeObject().getHash());
                sb.append("\n");
            }
            GUIMediator.setClipboardContent(sb.toString());
        }
    };
    CONFIGURE_SHARING_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            GUIMediator.instance().setOptionsVisible(true, tr("Options"));
        }
    };
    DOWNLOAD_PARTIAL_FILES_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            if (lines.length == 1 && lines[0] != null) {
                final SearchResult sr = lines[0].getInitializeObject().getSearchResult();
                if (sr instanceof TorrentSearchResult) {
                    // GUIMediator gm = GUIMediator.instance();
                    // if (sr instanceof ScrapedTorrentFileSearchResult) {
                    // gm.openTorrentSearchResult((ScrapedTorrentFileSearchResult) sr);
                    // } else {
                    GUIMediator.instance().openTorrentSearchResult((TorrentSearchResult) sr, true);
                // }
                }
            }
        }
    };
    STOP_SEARCH_LISTENER = new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            SearchMediator.instance().stopSearch(token);
            updateSearchIcon(false);
            setButtonEnabled(SearchButtons.STOP_SEARCH_BUTTON_INDEX, false);
        }
    };
}
Also used : MouseEvent(java.awt.event.MouseEvent) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) MouseAdapter(java.awt.event.MouseAdapter) SearchResult(com.frostwire.search.SearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult) TorrentSearchResult(com.frostwire.search.torrent.TorrentSearchResult)

Aggregations

SearchResult (com.frostwire.search.SearchResult)1 TorrentSearchResult (com.frostwire.search.torrent.TorrentSearchResult)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1