Exemple #1
0
  /**
   * Prompts the user to select a directory
   *
   * @param pTitle - Title to be displayed on the prompt window
   * @return Users selected directory
   * @throws Exception if the user clicks cancel or enter without choosing a directory
   */
  public static File getDir(String pTitle) throws Exception {
    dChooser.setTitle(pTitle);
    File dir = dChooser.showDialog(null);

    if (null == dir) {
      throw new Exception("No Directory Chosen");
    }
    return dir;
  }
 @FXML
 private void onBrowseButtonClick(ActionEvent event) {
   Stage stage = null;
   stage = (Stage) browseButton.getScene().getWindow();
   DirectoryChooser dirChoose = new DirectoryChooser();
   dirChoose.setTitle("Choose JDK Location");
   File selectedDir = dirChoose.showDialog(stage);
   if (selectedDir != null) {
     jdkLocationTextBox.setText(selectedDir.getPath());
   }
 }
  @FXML
  void browseDir() {

    DirectoryChooser directoryChooser = new DirectoryChooser();

    directoryChooser.setTitle("Select Archive Directory");
    // Show open file dialog

    File file = directoryChooser.showDialog(null);

    if (file != null) {

      txtDir.setText(txtDir.getText() + ";" + file.getPath());
      constants.addValue("s_dumpDir", txtDir.getText());
      generateBackupPaths();
    }
  }
  @FXML
  protected void addAlbumButton() {
    // wybieranie folderu z albumem
    DirectoryChooser directoryChooser = new DirectoryChooser();
    directoryChooser.setTitle("Choose album folder");
    File selectedDirectory = directoryChooser.showDialog(root.getScene().getWindow());

    // kopiowanie albumu do folderu biblioteki
    File destinationDirectory = new File("C:/Users/Public/Music/" + selectedDirectory.getName());
    try {
      FileUtils.copyDirectory(selectedDirectory, destinationDirectory);
      flowPane.getChildren().clear();
      clearData();
      loadAlbums();
      drawAlbums();
    } catch (IOException e) {
      e.printStackTrace();
    }

    SystemTrayIcon.trayMessage("Succes", "Added new album");
  }
 public void chooseFolder(ActionEvent event) {
   DirectoryChooser dc = new DirectoryChooser();
   dc.setTitle("选择路径");
   File file = dc.showDialog(toolTable.getScene().getWindow());
   pathField.setText(file.getPath());
 }
  void setupTracksContextMenu() {
    ContextMenu cm = tracksContextMenu;
    List<MenuItem> items = cm.getItems();
    items.clear();

    Playlist pl = getSelectedPlaylist();
    if (pl == null) {
      items.add(
          menuItem(
              "-> " + res.getString("add_to"),
              () -> {
                menuAddToPlaylist();
              }));
      if (rememberedPlaylist != null) {
        items.add(
            menuItem(
                "-> "
                    + String.format(
                        res.getString("add_to_featured"), rememberedPlaylist.getTitle()),
                () -> {
                  Track t = getSelectedTrack();
                  if (t != null) {
                    addToPlaylist(t, rememberedPlaylist);
                  }
                }));
      }
    } else {
      items.add(
          menuItem(
              "(+) " + res.getString("add_files"),
              () -> {
                FileChooser fileChooser = new FileChooser();
                fileChooser.setInitialDirectory(new File(System.getProperty("user.dir")));
                fileChooser.setTitle(String.format(res.getString("add_files_to"), pl.getTitle()));
                fileChooser
                    .getExtensionFilters()
                    .addAll(new FileChooser.ExtensionFilter("MP3", "*.mp3"));
                List<File> files = fileChooser.showOpenMultipleDialog(null);
                if (files != null) {
                  addToPlaylist(files, pl);
                }
              }));
      items.add(
          menuItem(
              "(+) " + res.getString("add_folder_recursively"),
              () -> {
                DirectoryChooser dirChooser = new DirectoryChooser();
                dirChooser.setTitle(String.format(res.getString("add_folder_to"), pl.getTitle()));
                dirChooser.setInitialDirectory(new File(System.getProperty("user.dir")));
                File dir = dirChooser.showDialog(null);
                if (dir == null) return;
                Collection<File> files = FileUtils.listFiles(dir, new String[] {"mp3"}, true);
                addToPlaylist(new ArrayList(files), pl);
              }));
      items.add(new SeparatorMenuItem());
      if (rememberedPlaylist != null)
        items.add(
            menuItem(
                "-> "
                    + String.format(
                        res.getString("add_to_featured"), rememberedPlaylist.getTitle()),
                () -> {
                  Track t = getSelectedTrack();
                  if (t != null) addToPlaylist(t, rememberedPlaylist);
                }));
      items.add(
          menuItem(
              "-> " + res.getString("add_to"),
              () -> {
                menuAddToPlaylist();
              }));
      items.add(new SeparatorMenuItem());
      items.add(
          menuItem(
              "(...) " + res.getString("rename_track"),
              () -> {
                renameTrack();
              }));
      items.add(new SeparatorMenuItem());
      items.add(
          menuItem(
              "(-) " + res.getString("delete_track") + pl.getTitle(),
              () -> {
                deleteTrackFromPlaylist();
              }));
      items.add(
          menuItem(
              "(-) " + res.getString("delete_dead_items"),
              () -> {
                Track t = getSelectedTrack();
                if (t == null) {
                  return;
                }
                deleteDeadFromOfflinePlaylist(pl);
              }));
    }
  }
 @Override
 public void setTitle(String string) {
   directoryChooser.setTitle(string);
 }