Java Code Examples for javafx.stage.FileChooser#showOpenMultipleDialog()

The following examples show how to use javafx.stage.FileChooser#showOpenMultipleDialog() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddVideoActionHandler.java    From Quelea with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handle(ActionEvent t) {
    FileChooser fileChooser = new FileChooser();
    if (QueleaProperties.get().getLastVideoDirectory() != null) {
        fileChooser.setInitialDirectory(QueleaProperties.get().getLastVideoDirectory());
    }
    fileChooser.getExtensionFilters().add(FileFilters.MULTIMEDIA);
    final List<File> files = fileChooser.showOpenMultipleDialog(QueleaApp.get().getMainWindow());

    if (files != null) {
        for (File file : files) {
            QueleaProperties.get().setLastVideoDirectory(file.getParentFile());
            VideoDisplayable displayable = new VideoDisplayable(file.getAbsolutePath());
            QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().add(displayable);
            new Thread() {
                @Override
                public void run() {
                    Utils.getVidBlankImage(file); //Cache preview image
                }
            }.start();
        }
    }
}
 
Example 2
Source File: ImagesBrowserController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@Override
    public void selectSourcePath(File path) {
        try {
            final FileChooser fileChooser = new FileChooser();
            if (path.exists()) {
                fileChooser.setInitialDirectory(path);
            }
            fileChooser.getExtensionFilters().addAll(sourceExtensionFilter);
            List<File> files = fileChooser.showOpenMultipleDialog(getMyStage());
            if (files == null || files.isEmpty()) {
                return;
            }
            recordFileOpened(files.get(0));

            loadImages(files);
        } catch (Exception e) {
//            logger.error(e.toString());
        }
    }
 
Example 3
Source File: BatchTableController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
public void addFiles(int index) {
    try {
        final FileChooser fileChooser = new FileChooser();
        File defaultPath = AppVariables.getUserConfigPath(sourcePathKey);
        if (defaultPath.exists()) {
            fileChooser.setInitialDirectory(defaultPath);
        }
        fileChooser.getExtensionFilters().addAll(sourceExtensionFilter);

        List<File> files = fileChooser.showOpenMultipleDialog(getMyStage());
        if (files == null || files.isEmpty()) {
            return;
        }
        isSettingValues = true;
        addFiles(index, files);
        isSettingValues = false;
        tableChanged();

    } catch (Exception e) {
        logger.error(e.toString());
    }

}
 
Example 4
Source File: FilesController.java    From AudioBookConverter with GNU General Public License v2.0 6 votes vote down vote up
public void selectFilesDialog() {
    Window window = ConverterApplication.getEnv().getWindow();
    final FileChooser fileChooser = new FileChooser();
    String sourceFolder = AppProperties.getProperty("source.folder");
    fileChooser.setInitialDirectory(Utils.getInitialDirecotory(sourceFolder));
    StringJoiner filetypes = new StringJoiner("/");

    Arrays.stream(FILE_EXTENSIONS).map(String::toUpperCase).forEach(filetypes::add);

    fileChooser.setTitle("Select " + filetypes.toString() + " files for conversion");

    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Audio", Arrays.asList(toSuffixes("*.", FILE_EXTENSIONS))));


    List<File> files = fileChooser.showOpenMultipleDialog(window);
    if (files != null) {
        processFiles(files);
        File firstFile = files.get(0);
        File parentFile = firstFile.getParentFile();
        AppProperties.setProperty("source.folder", parentFile.getAbsolutePath());
        if (!chaptersMode.get()) {
            filesChapters.getTabs().add(filesTab);
            filesChapters.getSelectionModel().select(filesTab);
        }
    }
}
 
Example 5
Source File: ImportFilesService.java    From greenbeans with Apache License 2.0 6 votes vote down vote up
public List<String> selectedFiles() {
	FileChooser fileChooser = new FileChooser();
	fileChooser.setInitialDirectory(initialDirectory());
	fileChooser.setTitle("Select Files to Import");
	// ofx Microsoft Money
	// qfx Intuit Quicken
	// qbo Intuit Quick Books
	// aso Simply Accounting
	fileChooser.getExtensionFilters().setAll(new ExtensionFilter("Transaction files (*.ofx, *.qfx, *.qbo, *.aso)",
			ImmutableList.of("*.ofx", "*.qfx", "*.qbo", "*.aso")));
	List<File> files = fileChooser.showOpenMultipleDialog(window);
	if (files == null) {
		return ImmutableList.of();
	}
	return FluentIterable.from(files).transform(new Function<File, String>() {

		@Override
		public String apply(File input) {
			return checkNotNull(input).getPath();
		}
	}).toSortedList(Ordering.natural());
}
 
Example 6
Source File: PreferencesController.java    From examples-javafx-repos1 with Apache License 2.0 6 votes vote down vote up
@FXML
public void browse(ActionEvent evt) {
	
	if( logger.isDebugEnabled() ) {
		logger.debug("[BROWSE]");
	}
	
	FileChooser fileChooser = new FileChooser();
	fileChooser.setTitle("Select JARs");
	fileChooser.getExtensionFilters().addAll(
			new ExtensionFilter("JAR Files", "*.jar", "*.zip")
					);
	List<File> selectedFiles = 
			fileChooser.showOpenMultipleDialog(((Button)evt.getSource()).getScene().getWindow());
	if( selectedFiles != null ) {
		lvJARs.getItems().clear();
		lvJARs.setItems( FXCollections.observableArrayList(selectedFiles) );
	}
}
 
Example 7
Source File: TabService.java    From AsciidocFX with Apache License 2.0 6 votes vote down vote up
public void openDoc() {
    FileChooser fileChooser = directoryService.newFileChooser("Open File");

    if (OSHelper.isWindows()) {
        fileChooser.getExtensionFilters().add(ExtensionFilters.ASCIIDOC);
        fileChooser.getExtensionFilters().add(ExtensionFilters.MARKDOWN);
        fileChooser.getExtensionFilters().add(ExtensionFilters.ALL);
    }

    List<File> chosenFiles = fileChooser.showOpenMultipleDialog(controller.getStage());
    if (chosenFiles != null) {
        chosenFiles.stream().map(File::toPath).forEach(this::previewDocument);
        ObservableList<Item> recentFiles = storedConfigBean.getRecentFiles();
        chosenFiles.stream()
                .map(e -> new Item(e.toPath()))
                .filter(file -> !recentFiles.contains(file)).forEach(recentFiles::addAll);
        directoryService.setInitialDirectory(Optional.ofNullable(chosenFiles.get(0)));
    }
}
 
Example 8
Source File: Main.java    From sis with Apache License 2.0 6 votes vote down vote up
/**
 * Invoked when the user selects "File" ▶ "Open" menu.
 * Users can select an arbitrary amount of files or directories.
 * The effect is the same as dragging the files in the "resources tree" window.
 */
private void open() {
    if (openFilters == null) {
        createFileFilters();
        lastFilter = openFilters[1];
    }
    final FileChooser chooser = new FileChooser();
    chooser.setTitle(Resources.format(Resources.Keys.OpenDataFile));
    chooser.getExtensionFilters().addAll(openFilters);
    chooser.setSelectedExtensionFilter(lastFilter);
    final List<File> files = chooser.showOpenMultipleDialog(window);
    if (files != null) {
        lastFilter = chooser.getSelectedExtensionFilter();
        content.open(files);
    }
}
 
Example 9
Source File: AuxclasspathSetupController.java    From pmd-designer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void onSelectFileClicked() {
    FileChooser chooser = new FileChooser();
    chooser.setTitle("Add files to the auxilliary classpath");
    chooser.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("Java archives", "*.jar", "*.war", "*.ear"),
            new FileChooser.ExtensionFilter("Java class files", "*.class")
    );
    List<File> files = chooser.showOpenMultipleDialog(designerRoot.getMainStage());
    fileListView.getItems().addAll(files);
}
 
Example 10
Source File: FrontController.java    From ns-usbloader with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Functionality for selecting NSP button.
 * */
private void selectFilesBtnAction(){
    List<File> filesList;
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(resourceBundle.getString("btn_OpenFile"));

    File validator = new File(previouslyOpenedPath);
    if (validator.exists() && validator.isDirectory())
        fileChooser.setInitialDirectory(validator);
    else
        fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));

    if (getSelectedProtocol().equals("TinFoil") && MediatorControl.getInstance().getContoller().getSettingsCtrlr().getTfXciNszXczSupport())
        fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP/XCI/NSZ/XCZ", "*.nsp", "*.xci", "*.nsz", "*.xcz"));
    else if (getSelectedProtocol().equals("GoldLeaf") && (! MediatorControl.getInstance().getContoller().getSettingsCtrlr().getNSPFileFilterForGL()))
        fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Any file", "*.*"),
                new FileChooser.ExtensionFilter("NSP ROM", "*.nsp")
        );
    else
        fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("NSP ROM", "*.nsp"));

    filesList = fileChooser.showOpenMultipleDialog(usbNetPane.getScene().getWindow());
    if (filesList != null && !filesList.isEmpty()) {
        tableFilesListController.setFiles(filesList);
        uploadStopBtn.setDisable(false);
        previouslyOpenedPath = filesList.get(0).getParent();
    }
}
 
Example 11
Source File: RawDataImportParameters.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public ExitCode showSetupDialog(boolean valueCheckRequired) {

  FileChooser fileChooser = new FileChooser();
  fileChooser.setTitle("Import raw data files");
  fileChooser.getExtensionFilters().addAll(
      new ExtensionFilter("All raw data files", "*.cdf", "*.nc", "*.mzData", "*.mzML", "*.mzXML",
          "*.xml", "*.raw", "*.csv", "*.zip", "*.gz"), //
      new ExtensionFilter("NetCDF files", "*.cdf", "*.nc"), //
      new ExtensionFilter("mzML files", "*.mzML"), //
      new ExtensionFilter("mzData files", "*.mzData"), //
      new ExtensionFilter("mzXML files", "*.mzXML"), //
      new ExtensionFilter("Thermo RAW files", "*.raw"), //
      new ExtensionFilter("Waters RAW folders", "*.raw"), //
      new ExtensionFilter("Agilent CSV files", "*.csv"), //
      new ExtensionFilter("Compressed files", "*.zip", "*.gz"), //
      new ExtensionFilter("All Files", "*.*"));

  // We need to allow directories, because Waters raw data come in
  // directories, not files
  // chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);

  File lastFiles[] = getParameter(fileNames).getValue();
  if ((lastFiles != null) && (lastFiles.length > 0)) {
    File currentDir = lastFiles[0].getParentFile();
    if ((currentDir != null) && (currentDir.exists()))
      fileChooser.setInitialDirectory(currentDir);
  }

  List<File> selectedFiles = fileChooser.showOpenMultipleDialog(null);
  if (selectedFiles == null)
    return ExitCode.CANCEL;
  getParameter(fileNames).setValue(selectedFiles.toArray(new File[0]));

  return ExitCode.OK;

}
 
Example 12
Source File: AddPowerpointActionHandler.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add the presentation
 * <p>
 * @param t the event.
 */
@Override
public void handle(ActionEvent t) {
    FileChooser chooser = new FileChooser();
    if (QueleaProperties.get().getLastDirectory() != null) {
        chooser.setInitialDirectory(QueleaProperties.get().getLastDirectory());
    }
    chooser.getExtensionFilters().add(FileFilters.POWERPOINT);
    final List<File> files = chooser.showOpenMultipleDialog(QueleaApp.get().getMainWindow());
    addPresentation(files);
}
 
Example 13
Source File: AddPdfActionHandler.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add the PDF
 * <p>
 * @param t the event.
 */
@Override
public void handle(ActionEvent t) {
    FileChooser chooser = new FileChooser();
    if (QueleaProperties.get().getLastDirectory() != null) {
        chooser.setInitialDirectory(QueleaProperties.get().getLastDirectory());
    }
    chooser.getExtensionFilters().add(FileFilters.PDF_GENERIC);
    final List<File> files = chooser.showOpenMultipleDialog(QueleaApp.get().getMainWindow());
    addPDF(files);
}
 
Example 14
Source File: ChartController.java    From TAcharting with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Opens a FileChooser dialog and adds excel or csv ohlc org.sjwimmer.tacharting.data as BarSeries to the current watchlist
 */
public void openCsvExcelDialog(){
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Csv/Excel File(s)");
    fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
    fileChooser.getExtensionFilters().addAll(EXTENSION_FILTER_CSV, EXTENSION_FILTER_EXCEL);

    List<File> files = fileChooser.showOpenMultipleDialog((vbxChart).getScene().getWindow());
    if(files == null) {
        return;
    }

    for(File file: files){
        if(file==null) {
            continue;
        }
        int extPoint = file.getName().lastIndexOf(".");
        String extension = file.getName().substring(extPoint+1);
        if(EXTENSION_FILTER_CSV.getExtensions().contains("*."+extension)){
            addCSV(file);
            continue;
        }
        if(EXTENSION_FILTER_EXCEL.getExtensions().contains("*."+extension)){
            addExcel(file);
        }
    }
}
 
Example 15
Source File: FileEditorTabPane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 5 votes vote down vote up
FileEditor[] openEditor() {
	FileChooser fileChooser = createFileChooser(Messages.get("FileEditorTabPane.openChooser.title"));
	List<File> selectedFiles = fileChooser.showOpenMultipleDialog(mainWindow.getScene().getWindow());
	if (selectedFiles == null)
		return null;

	saveLastDirectory(selectedFiles.get(0));
	return openEditors(selectedFiles, 0, -1);
}