예제 #1
0
  /** Saves a playlist. */
  public void exportM3U(Playlist playlist) {

    if (playlist == null) {
      return;
    }

    String suggestedName = CommonUtils.convertFileName(playlist.getName());

    // get the user to select a new one.... avoid FrostWire installation folder.
    File suggested;
    File suggestedDirectory = FileChooserHandler.getLastInputDirectory();
    if (suggestedDirectory.equals(CommonUtils.getCurrentDirectory())) {
      suggestedDirectory = new File(CommonUtils.getUserHomeDir(), "Desktop");
    }

    suggested = new File(suggestedDirectory, suggestedName + ".m3u");

    File selFile =
        FileChooserHandler.getSaveAsFile(
            GUIMediator.getAppFrame(),
            I18nMarker.marktr("Save Playlist As"),
            suggested,
            new PlaylistListFileFilter());

    // didn't select a file?  nothing we can do.
    if (selFile == null) {
      return;
    }

    // if the file already exists and not the one just opened, ask if it should be
    //  overwritten.
    // TODO: this should be handled in the jfilechooser
    if (selFile.exists()) {
      DialogOption choice =
          GUIMediator.showYesNoMessage(
              I18n.tr(
                  "Warning: a file with the name {0} already exists in the folder. Overwrite this file?",
                  selFile.getName()),
              QuestionsHandler.PLAYLIST_OVERWRITE_OK,
              DialogOption.NO);
      if (choice != DialogOption.YES) return;
    }

    String path = selFile.getPath();
    try {
      path = FileUtils.getCanonicalPath(selFile);
    } catch (IOException ignored) {
      // LOG.warn("unable to get canonical path for file: " + selFile, ignored);
    }
    // force m3u on the end.
    if (!path.toLowerCase().endsWith(".m3u")) path += ".m3u";

    // create a new thread to handle saving the playlist to disk
    saveM3U(playlist, path);
  }
예제 #2
0
    @Override
    public void actionPerformed(ActionEvent arg0) {

      DialogOption result =
          GUIMediator.showYesNoMessage(
              I18n.tr(
                  "This will remove your \"FrostWire\" playlist in iTunes and replace\n"
                      + "it with one containing all the iTunes compatible files in your \n"
                      + "Frostwire \"Torrent Data Folder\"\n\n"
                      + "Please note that it will add the files to the iTunes library as well\n"
                      + "and this could result in duplicate files on your iTunes library\n\n"
                      + "Are you sure you want to continue?"),
              I18n.tr("Warning"),
              JOptionPane.WARNING_MESSAGE);

      if (result == DialogOption.YES) {
        iTunesMediator.instance().resetFrostWirePlaylist();
      }
    }
    public void performAction(ActionEvent e) {
      if (_deleteData) {

        DialogOption result =
            GUIMediator.showYesNoMessage(
                I18n.tr(
                    "Are you sure you want to remove the data files from your computer?\n\nYou won't be able to recover the files."),
                I18n.tr("Are you sure?"),
                JOptionPane.QUESTION_MESSAGE);

        if (result != DialogOption.YES) return;
      }

      BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();
      for (int i = 0; i < downloaders.length; i++) {
        downloaders[i].setDeleteTorrentWhenRemove(_deleteTorrent);
        downloaders[i].setDeleteDataWhenRemove(_deleteData);
      }
      BTDownloadMediator.instance().removeSelection();
      UXStats.instance().log(UXAction.DOWNLOAD_REMOVE);
    }
    public void performAction(ActionEvent e) {
      boolean oneIsCompleted = false;

      BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();

      for (int i = 0; i < downloaders.length; i++) {
        if (downloaders[i].isCompleted()) {
          oneIsCompleted = true;
          break;
        }
      }

      boolean allowedToResume = true;
      DialogOption answer = null;
      if (oneIsCompleted && !SharingSettings.SEED_FINISHED_TORRENTS.getValue()) {
        String message1 =
            (downloaders.length > 1)
                ? I18n.tr(
                    "One of the transfers is complete and resuming will cause it to start seeding")
                : I18n.tr(
                    "This transfer is already complete, resuming it will cause it to start seeding");
        String message2 = I18n.tr("Do you want to enable torrent seeding?");
        answer = GUIMediator.showYesNoMessage(message1 + "\n\n" + message2, DialogOption.YES);
        allowedToResume = answer.equals(DialogOption.YES);

        if (allowedToResume) {
          SharingSettings.SEED_FINISHED_TORRENTS.setValue(true);
        }
      }

      if (allowedToResume) {
        for (int i = 0; i < downloaders.length; i++) {
          downloaders[i].resume();
        }
      }

      UXStats.instance().log(UXAction.DOWNLOAD_RESUME);
    }