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