Exemplo n.º 1
0
 @FXML
 public void saveDirectory() {
   directory = null;
   DirectoryChooser directoryChooser = new DirectoryChooser();
   File file = directoryChooser.showDialog(null);
   directory = file;
 }
Exemplo n.º 2
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;
  }
Exemplo n.º 3
0
 @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());
   }
 }
Exemplo n.º 4
0
 private void setupDirectorySelectMenuItem() {
   gitoliteDirectorySelectMenuItem.setOnAction(
       event -> {
         ApplicationModel model = ApplicationModel.getInstance();
         DirectoryChooser chooser = new DirectoryChooser();
         if (model.isRepoDirectoryDefined()) {
           chooser.setInitialDirectory(model.getRepoDirectory());
         }
         File selectedDirectory = chooser.showDialog(null);
         if (selectedDirectory != null) {
           model.setRepoDirectory(selectedDirectory);
           checkForDefinedGitRepoDirectory();
         }
       });
 }
Exemplo n.º 5
0
  @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();
    }
  }
Exemplo n.º 6
0
  public void selectFolder(final JSObject callback) {
    DirectoryChooser dirChooser = new DirectoryChooser();
    File selectedFile = dirChooser.showDialog(stage);
    if (selectedFile != null) {
      System.out.println(selectedFile);
      final Object f[] = new Object[2];
      f[0] = null;
      f[1] = selectedFile.toString();

      Platform.runLater(
          new Runnable() {
            @Override
            public void run() {
              callback.call("call", f);
            }
          });
    }
  }
Exemplo n.º 7
0
 public void exportSFRQSetting(ActionEvent actionEvent) {
   log.info("Click 导出SFRQ设置");
   final UINode uiProject = plus.getService(TreeViewService.class).getCurrentUIProject();
   directoryChooser.setInitialDirectory(plus.getLastDir());
   final File outputDir = directoryChooser.showDialog(plus.getStage());
   if (outputDir == null || outputDir.isFile()) {
     return;
   }
   if (!outputDir.exists()) {
     outputDir.mkdirs();
   }
   plus.setLastDir(outputDir);
   final UINode sfrqSetting = UINode.findFromChildren(uiProject, UISFRQSetting_NAME);
   plus.getService(XMLService.class)
       .outputBusinessNodeToXML(
           sfrqSetting.getFirstBusinessNodeChild(),
           new File(outputDir, PlusFileUtil.newFileNameWithTimestamp(SFRQ_Collection_XML_NAME)));
 }
  @Override
  public SelectorDialog show(String title) {
    setTitle(title);
    selectedDirectory = directoryChooser.showDialog(ownerWindow);

    if (selectedDirectory != null) {
      SelectorDialogService.setLastDirectory(selectedDirectory);
    }

    return this;
  }
Exemplo n.º 9
0
  @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");
  }
  @FXML
  private void selectFile() {
    if (!isChooserShown) {

      isChooserShown = true;
      File selectedFile;
      if (isFileToConvert) {
        selectedFile = fileChooser.showOpenDialog(new Stage());
      } else {
        selectedFile = directoryChooser.showDialog(new Stage());
      }
      isChooserShown = false;
      if (selectedFile != null) {
        buttonRemoveSubs.setDisable(false);
        file = selectedFile;
      }
    } else {
      alertInfo.showDialog(
          "FileChooser already in use",
          "Sorry, it's not possible to use multiple FileChoosers at the same time .");
    }
  }
  private void bind() {

    // Handles the continue button in the footer being pressed. Validates that all required fields
    // are present, sets the state on the controller,
    // and instructs the controller to move to the next page.
    view.getContinueButton()
        .setOnAction(
            arg0 -> {
              try {
                if (root_artifact_dir != null
                    && root_artifact_dir.exists()
                    && root_artifact_dir.canRead()) {

                  /* Insert properties, if any */
                  for (Map.Entry<String, String> property : view.getPropertyValues().entrySet()) {
                    ruleProperties.setProperty(property.getKey(), property.getValue());
                  }
                  // TODO: when we support multiple ontologies we will need to adjust the handling
                  // of the user's
                  // choice of ontology identifier instead of hardcoded value here

                  final PackageDescriptionServiceWorker packageDescriptionService =
                      new PackageDescriptionServiceWorker(
                          DcsPackageDescriptionSpec.SPECIFICATION_ID, root_artifact_dir);

                  view.showProgressIndicatorPopUp();

                  ((ProgressDialogPopup) view.getProgressIndicatorPopUp())
                      .setCancelEventHandler(event -> packageDescriptionService.cancel());

                  controller.setCrossPageProgressIndicatorPopUp(view.getProgressIndicatorPopUp());
                  controller.setContentRoot(content_dir);
                  controller.setRootArtifactDir(root_artifact_dir);

                  packageDescriptionService.setOnCancelled(
                      event -> {
                        packageDescriptionService.reset();
                        controller.getCrossPageProgressIndicatorPopUp().hide();
                        controller.showHome(false);
                      });

                  packageDescriptionService.setOnFailed(
                      workerStateEvent -> {
                        displayExceptionMessage(workerStateEvent.getSource().getException());
                        view.getErrorMessage().setVisible(true);
                        packageDescriptionService.reset();
                        controller.getCrossPageProgressIndicatorPopUp().hide();
                        controller.showHome(false);
                      });

                  packageDescriptionService.setOnSucceeded(
                      workerStateEvent -> {
                        PackageDescription packageDescription =
                            (PackageDescription) workerStateEvent.getSource().getValue();
                        controller.setPackageDescription(packageDescription);
                        controller.setPackageDescriptionFile(null);
                        packageDescriptionService.reset();
                        controller.goToNextPage();
                      });

                  packageDescriptionService.start();

                } else if (root_artifact_dir != null
                    && (!root_artifact_dir.exists() || !root_artifact_dir.canRead())) {
                  view.getErrorMessage().setText(errors.get(ErrorKey.INACCESSIBLE_CONTENT_DIR));
                  view.getErrorMessage().setVisible(true);
                } else if (controller.getPackageDescription() != null) {
                  controller.goToNextPage();
                } else {
                  view.getErrorMessage()
                      .setText(errors.get(ErrorKey.BASE_DIRECTORY_OR_DESCRIPTION_NOT_SELECTED));
                  view.getErrorMessage().setVisible(true);
                }
              } catch (Exception e) {
                view.getErrorMessage()
                    .setText(messages.formatErrorCreatingNewPackage(e.getMessage()));
                view.getErrorMessage().setVisible(true);
                log.error(e.getMessage());
              }
            });

    // Handles the user pressing the button to choose a base directory to create a package from.
    view.getChooseContentDirectoryButton()
        .setOnAction(
            event -> {
              if (directoryChooser.getInitialDirectory() != null
                  && !directoryChooser.getInitialDirectory().exists()) {
                directoryChooser.setInitialDirectory(null);
              }

              File dir = controller.showOpenDirectoryDialog(directoryChooser);

              if (dir != null) {
                root_artifact_dir = dir;
                content_dir = root_artifact_dir.getParentFile();
                view.getSelectedBaseDirectoryTextField().setText(root_artifact_dir.getPath());
                view.getSelectedPackageDescriptionTextField().setText("");
                // If the error message happens to be visible erase it.
                view.getErrorMessage().setVisible(false);
                directoryChooser.setInitialDirectory(dir);
              }
            });

    // Handles the user pressing a button to choose an existing package description.
    view.getChoosePackageDescriptionButton()
        .setOnAction(
            arg0 -> {
              File descriptionFile = controller.showOpenFileDialog(fileChooser);

              if (descriptionFile != null) {
                try {
                  FileInputStream fis = new FileInputStream(descriptionFile);
                  PackageDescription description = packageDescriptionBuilder.deserialize(fis);
                  // If the selected package description file is valid set it on the controller and
                  // remove the content directory if it was set.
                  if (description != null) {
                    // content_dir = null;
                    controller.setPackageDescription(description);
                    controller.setPackageDescriptionFile(descriptionFile);
                    controller.setRootArtifactDir(null);
                    controller.setContentRoot(null);
                    content_dir = null;
                    root_artifact_dir = null;

                    view.getErrorMessage().setVisible(false);
                    view.getSelectedPackageDescriptionTextField()
                        .setText(descriptionFile.getPath());
                    view.getSelectedBaseDirectoryTextField().setText("");
                    fileChooser.setInitialDirectory(descriptionFile.getParentFile());
                  }
                } catch (FileNotFoundException | PackageToolException e) {
                  view.getErrorMessage()
                      .setText(
                          messages.formatPackageDescriptionBuilderFailure(
                              descriptionFile.getName()));
                  view.getErrorMessage().setVisible(true);
                  log.error(e.getMessage());
                }
              }
            });
  }
Exemplo n.º 12
0
 public void chooseFolder(ActionEvent event) {
   DirectoryChooser dc = new DirectoryChooser();
   dc.setTitle("选择路径");
   File file = dc.showDialog(toolTable.getScene().getWindow());
   pathField.setText(file.getPath());
 }
Exemplo n.º 13
0
 public static File creSaveToFoldDialog(Window parent, String initFileName) {
   DirectoryChooser dir = new DirectoryChooser();
   return dir.showDialog(parent);
 }
Exemplo n.º 14
0
  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 setInitialDirectory(File initialDirectory) {
   directoryChooser.setInitialDirectory(initialDirectory);
 }
 @Override
 public void setTitle(String string) {
   directoryChooser.setTitle(string);
 }