コード例 #1
0
ファイル: GUILauncher.java プロジェクト: Lujango/frostwire
 /**
  * Launches an array of <code>providers</code> delegating the time consuming construction of
  * {@link Downloader#getDownloadFragment()} into a background threads.
  */
 public static void launch(LaunchableProvider[] providers) {
   boolean audioLaunched = false;
   GUIMediator.instance().setFrameCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
   for (LaunchableProvider provider : providers) {
     File file = provider.getFile();
     if (file != null) {
       audioLaunched = GUIUtils.launchOrEnqueueFile(file, audioLaunched);
     }
   }
   GUIMediator.instance().setFrameCursor(Cursor.getDefaultCursor());
 }
コード例 #2
0
 @Override
 public void download(boolean partial) {
   if (sr instanceof TorrentCrawledSearchResult) {
     GUIMediator.instance()
         .openTorrentSearchResult(sr, ((TorrentCrawledSearchResult) sr).getRelativePath());
   } else {
     GUIMediator.instance().openTorrentSearchResult(sr, partial);
   }
   showDetails(false);
   UXStats.instance()
       .log(
           (sr instanceof TorrentCrawledSearchResult)
               ? UXAction.DOWNLOAD_PARTIAL_TORRENT_FILE
               : UXAction.DOWNLOAD_FULL_TORRENT_FILE);
 }
コード例 #3
0
  /**
   * Defines the abstract method in <tt>AbstractPaneItem</tt>.
   *
   * <p>Applies the options currently set in this window, displaying an error message to the user if
   * a setting could not be applied.
   *
   * @throws IOException if the options could not be applied for some reason
   */
  @Override
  public boolean applyOptions() throws IOException {
    if (!isDirty()) return false;

    StatusBarSettings.CONNECTION_QUALITY_DISPLAY_ENABLED.setValue(CHECK_BOX.isSelected());
    GUIMediator.instance().getStatusLine().refresh();
    return false;
  }
コード例 #4
0
 private static void closeCurrentSearchTab(KeyEvent e) {
   if (e.getSource() instanceof Component) {
     Window eventParentWindow = SwingUtilities.getWindowAncestor((Component) e.getSource());
     if (GUIMediator.getAppFrame().equals(eventParentWindow)) {
       SearchDownloadTab searchTab =
           (SearchDownloadTab) GUIMediator.instance().getTab(Tabs.SEARCH);
       if (searchTab.getComponent().isVisible()) {
         SearchMediator.getSearchResultDisplayer().closeCurrentTab();
       }
     }
   }
 }
コード例 #5
0
  /** Launches the associated applications for each selected file in the library if it can. */
  void launch(boolean playAudio) {
    int[] rows = TABLE.getSelectedRows();
    if (rows.length == 0) {
      return;
    }

    File selectedFile = DATA_MODEL.getFile(rows[0]);

    if (OSUtils.isWindows()) {
      if (selectedFile.isDirectory()) {
        GUIMediator.launchExplorer(selectedFile);
        return;
      } else if (!MediaPlayer.isPlayableFile(selectedFile)) {
        String extension = FilenameUtils.getExtension(selectedFile.getName());
        if (extension != null && extension.equals("torrent")) {
          GUIMediator.instance().openTorrentFile(selectedFile, true);
        } else {
          GUIMediator.launchFile(selectedFile);
        }
        return;
      }
    }

    LaunchableProvider[] providers = new LaunchableProvider[rows.length];
    boolean stopAudio = false;
    for (int i = 0; i < rows.length; i++) {
      try {
        MediaType mt =
            MediaType.getMediaTypeForExtension(
                FilenameUtils.getExtension(DATA_MODEL.getFile(rows[i]).getName()));
        if (mt.equals(MediaType.getVideoMediaType())) {
          stopAudio = true;
        }
      } catch (Throwable e) {
        // ignore
      }
      providers[i] = new FileProvider(DATA_MODEL.getFile(rows[i]));
    }
    if (stopAudio || !playAudio) {
      MediaPlayer.instance().stop();
    }

    if (playAudio) {
      GUILauncher.launch(providers);
      UXStats.instance()
          .log(stopAudio ? UXAction.LIBRARY_VIDEO_PLAY : UXAction.LIBRARY_PLAY_AUDIO_FROM_FILE);
    } else {
      GUIMediator.launchFile(selectedFile);
    }
  }
コード例 #6
0
    @Override
    public void actionPerformed(ActionEvent e) {
      BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();

      List<File> playlistFiles = new ArrayList<File>(downloaders.length);

      for (BTDownload d : downloaders) {
        if (!d.isCompleted()) {
          return;
        }

        playlistFiles.add(d.getSaveLocation());
      }

      LibraryUtils.asyncAddToPlaylist(playlist, playlistFiles.toArray(new File[0]));
      GUIMediator.instance().setWindow(GUIMediator.Tabs.LIBRARY);
    }
コード例 #7
0
 public void actionPerformed(ActionEvent e) {
   GUIMediator.instance().setOptionsVisible(true);
 }