/** Sets all the listeners. */
  protected void buildListeners() {
    super.buildListeners();

    DOWNLOAD_LISTENER =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            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();
            String str = "";
            for (SearchResultDataLine line : lines) {
              str += TorrentUtil.getMagnet(line.getInitializeObject().getHash());
              str += "\n";
            }
            GUIMediator.setClipboardContent(str);
          }
        };

    COPY_HASH_ACTION_LISTENER =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            String str = "";
            for (SearchResultDataLine line : lines) {
              str += line.getInitializeObject().getHash();
              str += "\n";
            }
            GUIMediator.setClipboardContent(str);
          }
        };

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

    DOWNLOAD_PARTIAL_FILES_LISTENER =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SearchResultDataLine[] lines = getAllSelectedLines();
            if (lines.length == 1 && lines[0] != null) {
              if (lines[0].getInitializeObject().getSearchResult() instanceof TorrentSearchResult) {
                GUIMediator.instance()
                    .openTorrentSearchResult(
                        (TorrentSearchResult) lines[0].getInitializeObject().getSearchResult(),
                        true);
              }
            }
          }
        };

    STOP_SEARCH_LISTENER =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            SearchMediator.instance().stopSearch(token);
            updateSearchIcon(false);
            setButtonEnabled(SearchButtons.STOP_SEARCH_BUTTON_INDEX, false);
          }
        };
  }