Example usage for javafx.stage FileChooser showOpenMultipleDialog

List of usage examples for javafx.stage FileChooser showOpenMultipleDialog

Introduction

In this page you can find the example usage for javafx.stage FileChooser showOpenMultipleDialog.

Prototype

public List<File> showOpenMultipleDialog(final Window ownerWindow) 

Source Link

Document

Shows a new file open dialog in which multiple files can be selected.

Usage

From source file:hash.HashFilesController.java

@FXML
protected void locateFile(ActionEvent event) {
    // FileInputStream fis = null;
    FileChooser chooser = new FileChooser();
    chooser.getInitialDirectory();//from   w w  w .j  a  v a2 s  . co  m
    chooser.setTitle("Open File");
    List<File> list = chooser.showOpenMultipleDialog(new Stage());
    list.stream().forEach((list1) -> {
        generateChecksums(list1);
    });//        filePathTextField.setText(files.getAbsolutePath());
    //        generateMD5(files);
}

From source file:de.halirutan.spectralis.examples.sloexporter.Controller.java

private List<File> showFileSelectDialog() {
    Window window = root.getScene().getWindow();
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select .vol files or directories");
    fileChooser.setSelectedExtensionFilter(new ExtensionFilter("Raw Volume files", "vol"));
    return fileChooser.showOpenMultipleDialog(window);
}

From source file:cz.lbenda.dataman.db.frm.DbConfigFrmController.java

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
    lvLibraries.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

    btnAddLibrary.setOnAction(event -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(msgLibraryChooseTitle);
        fileChooser.getExtensionFilters().addAll(Constants.librariesFilter);
        List<File> files = fileChooser.showOpenMultipleDialog(btnAddLibrary.getScene().getWindow());
        if (files != null) {
            files.forEach(file -> lvLibraries.getItems().add(file.getAbsolutePath()));
        }//from   www .  ja v  a 2s . c om
    });
    btnRemoveLibrary.setOnAction(
            event -> lvLibraries.getItems().removeAll(lvLibraries.getSelectionModel().getSelectedItems()));
    btnExtendConfigFindPath.setOnAction(event -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(msgExtendConfigChooseTitle);
        fileChooser.getExtensionFilters().addAll(Constants.configFileFilter);
        if (StringUtils.isEmpty(tfExtendConfigPath.getText())) {
            fileChooser.setInitialFileName(tfExtendConfigPath.getText());
        }
        File file = fileChooser.showOpenDialog(btnExtendConfigFindPath.getScene().getWindow());
        if (file != null) {
            tfExtendConfigPath.setText(file.getAbsolutePath());
        }
    });
    lvLibraries.getItems().addListener((ListChangeListener<String>) change -> {
        while (change.next()) {
            if (change.wasAdded() || change.wasRemoved()) {
                findDriverClasses();
            }
        }
    });
}

From source file:ipat_fx.FXMLDocumentController.java

@FXML
private void chooseFiles(ActionEvent event) {

    int numOfProfiles = Integer.parseInt(noOfProfiles.getText());
    if (numOfProfiles > 8) {
        JOptionPane.showMessageDialog(null, "Please set the number of Profiles to be less than 8.");
    } else if (problemDataFolderName == null) {
        JOptionPane.showMessageDialog(null, "Please first select a case from the cases tab in the menu bar.\n"
                + "If no cases exist, ensure the candidate solutions are correctly entered in the /web/data folder.");
    } else {//w w w . j  a va2 s.  c om
        FileChooser chooser = new FileChooser();

        List<File> uploads = chooser.showOpenMultipleDialog(null);

        uploads.stream().forEach((fi) -> {
            File file;
            String fileName = fi.getName();
            File input = new File(dataPath + "/input/");
            input.mkdirs();
            File output = new File(dataPath + "/output/");
            output.mkdirs();
            if (fileName.lastIndexOf("\\") >= 0) {
                file = new File(input.getAbsolutePath() + "/" + fileName.substring(fileName.lastIndexOf("/")));
            } else {
                file = new File(
                        input.getAbsolutePath() + "/" + fileName.substring(fileName.lastIndexOf("/") + 1));
            }
            try {
                OutputStream outStream;
                try (InputStream inStream = new FileInputStream(fi)) {
                    outStream = new FileOutputStream(file);
                    byte[] buffer = new byte[1024];
                    int fileLength;
                    while ((fileLength = inStream.read(buffer)) > 0) {
                        outStream.write(buffer, 0, fileLength);
                    }
                }
                outStream.close();
            } catch (IOException ex) {
                Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE,
                        "Error loading file see mainframe ", ex);
            }

        });
        try {
            controller = new Controller(inputFolder, outputFolder, profilePath, hintsXML,
                    problemDataFolderName);
            HashMap<String, Object> display = controller.initialisation();
            WebView previewView = (WebView) display.get("previewView");
            previewPane.getChildren().add(previewView);
            @SuppressWarnings("unchecked")
            HashMap<String, ArrayList<GridPane>> map = (HashMap<String, ArrayList<GridPane>>) display
                    .get("results");
            byProfileTab = getByProfile(map, numOfProfiles);
            byProfilePane.setCenter(byProfileTab);

            tabPane.getSelectionModel().select(0);
            tabFlag = "byProfile";

            tabPane.getSelectionModel().selectedIndexProperty()
                    .addListener((ObservableValue<? extends Number> ov, Number oldValue, Number newValue) -> {
                        if (newValue == Number.class.cast(1)) {
                            tabFlag = "byImage";
                            byImageTab = getByImage(map);
                            byImagePane.setCenter(byImageTab);
                        } else if (newValue == Number.class.cast(0)) {
                            tabFlag = "byProfile";
                            byProfileTab = getByProfile(map, numOfProfiles);
                            byProfilePane.setCenter(byProfileTab);
                        } else {
                            System.out.println("Error this tab has not been created.");
                        }
                    });

        } catch (IOException ex) {
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.gmail.frogocomics.schematic.gui.Main.java

@Override
public void start(Stage primaryStage) throws Exception {
    this.primaryStage = primaryStage;
    this.root = new GridPane();
    this.primaryScene = new Scene(this.root, 1000, 600, Color.AZURE);

    Label title = new Label("Schematic Utilities");
    title.setId("schematic-utilities");
    title.setPrefWidth(this.primaryScene.getWidth() + 500);
    this.root.add(title, 0, 0);

    filesSelected.setId("files-selected");
    this.root.add(filesSelected, 0, 1);

    Region spacer1 = new Region();
    spacer1.setPrefWidth(30);//from  w w  w  .  j  a v a2s  .c  o m
    spacer1.setPrefHeight(30);

    Region spacer2 = new Region();
    spacer2.setPrefWidth(30);
    spacer2.setPrefHeight(30);

    Region spacer3 = new Region();
    spacer3.setPrefWidth(30);
    spacer3.setPrefHeight(250);

    Region spacer4 = new Region();
    spacer4.setPrefWidth(1000);
    spacer4.setPrefHeight(10);

    Region spacer5 = new Region();
    spacer5.setPrefWidth(30);
    spacer5.setPrefHeight(30);

    Region spacer6 = new Region();
    spacer6.setPrefWidth(1000);
    spacer6.setPrefHeight(10);

    Region spacer7 = new Region();
    spacer7.setPrefWidth(1000);
    spacer7.setPrefHeight(100);

    Region spacer8 = new Region();
    spacer8.setPrefWidth(30);
    spacer8.setPrefHeight(30);

    this.root.add(spacer4, 0, 3);

    listView.setId("schematic-list");
    listView.setEditable(false);
    listView.setPrefWidth(500);
    listView.setPrefHeight(250);
    this.root.add(new HBox(spacer3, listView), 0, 4);

    uploadFiles.setPadding(new Insets(5, 5, 5, 5));
    uploadFiles.setPrefWidth(120);
    uploadFiles.setPrefHeight(30);
    uploadFiles.setOnAction((event) -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select schematic(s)");
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("MCEdit Schematic File", "*.schematic"),
                new FileChooser.ExtensionFilter("Biome World Object Version 2", "*.bo2"));
        List<File> selectedFiles = fileChooser.showOpenMultipleDialog(this.primaryStage);
        if (selectedFiles != null) {
            if (selectedFiles.size() == 1) {
                filesSelected.setText("There is currently 1 file selected");
            } else {
                filesSelected.setText(
                        "There are currently " + String.valueOf(selectedFiles.size()) + " files selected");
            }
            ObservableList<SchematicLocation> selectedSchematicFiles = FXCollections.observableArrayList();
            selectedSchematicFiles.addAll(selectedFiles.stream().map(f -> new SchematicLocation(f, f.getName()))
                    .collect(Collectors.toList()));
            listView.setItems(selectedSchematicFiles);
            this.schematics = selectedSchematicFiles;
        }

    });
    this.root.add(new HBox(spacer1, uploadFiles, spacer2,
            new Label("Only .schematic files are allowed at this point!")), 0, 2);

    editing.setPadding(new Insets(5, 5, 5, 5));
    editing.setPrefWidth(240);
    editing.setPrefHeight(30);
    editing.setDisable(true);
    editing.setOnAction(event -> this.primaryStage.setScene(Editing.getScene()));
    this.root.add(new HBox(spacer8, editing), 0, 8);

    loadSchematics.setPadding(new Insets(5, 5, 5, 5));
    loadSchematics.setPrefWidth(120);
    loadSchematics.setPrefHeight(30);
    loadSchematics.setOnAction(event -> {
        if (this.schematics != null) {
            ((Runnable) () -> {
                for (SchematicLocation location : this.schematics) {
                    if (FilenameUtils.isExtension(location.getLocation().getName(), "schematic")) {
                        try {
                            Schematics.schematics.add(McEditSchematicObject.load(location.getLocation()));
                        } catch (ParseException | ClassicNotSupportedException | IOException e) {
                            e.printStackTrace();
                        }
                    } else if (FilenameUtils.isExtension(location.getLocation().getName(), "bo2")) {
                        try {
                            Schematics.schematics.add(BiomeWorldV2Object.load(location.getLocation()));
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }).run();
            loadSchematics.setDisable(true);
            uploadFiles.setDisable(true);
            listView.setDisable(true);
            editing.setDisable(false);
        }
    });
    this.root.add(spacer6, 0, 5);
    this.root.add(new HBox(spacer5, loadSchematics), 0, 6);
    this.root.add(spacer7, 0, 7);

    this.primaryScene.getStylesheets()
            .add("https://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700,800");
    this.primaryScene.getStylesheets().add(new File("style.css").toURI().toURL().toExternalForm());
    this.primaryStage.setScene(this.primaryScene);
    this.primaryStage.setResizable(false);
    this.primaryStage.setTitle("Schematic Utilities - by frogocomics");
    this.primaryStage.show();
}

From source file:dpfmanager.shell.interfaces.gui.component.dessign.DessignController.java

public void selectInputAction() {
    String txtFile = null;//from  w ww .  ja  v a  2  s .  c  o m
    ComboBox c = getView().getComboChoice();
    String configDir = DPFManagerProperties.getDefaultDirFile();
    if (c.getValue().equals(getBundle().getString("comboFile"))) {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(getBundle().getString("openFile"));
        fileChooser.setInitialDirectory(new File(configDir));
        fileChooser.getExtensionFilters().addAll(generateExtensionsFilters());
        List<File> files = fileChooser.showOpenMultipleDialog(GuiWorkbench.getMyStage());
        if (files != null) {
            String sfiles = "";
            File last = null;
            for (File file : files) {
                if (sfiles.length() > 0)
                    sfiles += ";";
                sfiles += file.getPath();
                last = file;
            }
            txtFile = sfiles;
            if (last.exists() && last.getParent() != null && last.getParentFile().exists()
                    && last.getParentFile().isDirectory()) {
                String path = last.getParent();
                DPFManagerProperties.setDefaultDirFile(path);
            }
        }
    } else if (c.getValue().equals(getBundle().getString("comboFolder"))) {
        DirectoryChooser folderChooser = new DirectoryChooser();
        folderChooser.setTitle(getBundle().getString("openFolder"));
        folderChooser.setInitialDirectory(new File(configDir));
        File directory = folderChooser.showDialog(GuiWorkbench.getMyStage());
        if (directory != null) {
            txtFile = directory.getPath();
            DPFManagerProperties.setDefaultDirFile(directory.getPath());
        }
    }
    if (txtFile != null) {
        getView().getInputText().setText(txtFile);
    }
}

From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java

@FXML
void addOverlayButton_onAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(I18N.getString("ManageOverlays.filechooser.overlay.title"));
    fileChooser.getExtensionFilters().addAll(ImageUtil.GET_EXTENSION_FILTERS());

    if (lastSelectedDirectory != null)
        fileChooser.setInitialDirectory(lastSelectedDirectory);

    List<File> selectedFiles = fileChooser
            .showOpenMultipleDialog((Stage) addOverlayButton.getScene().getWindow());

    if (selectedFiles != null) {
        for (File selectedFile : selectedFiles) {
            FileSaveUtil.copyFile(selectedFile, currentDirectory);
        }//from w ww .  j  a v  a2s  . co  m

        lastSelectedDirectory = selectedFiles.get(0).getParentFile();
        loadImages(overlayTreeView.getSelectionModel().getSelectedItem());
    }
}

From source file:org.martus.client.swingui.PureFxMainWindow.java

protected File[] showMultiFileOpenDialog(String title, File directory, Vector<FormatFilter> filters) {
    FileChooser fileChooser = createFileChooser(title, directory,
            filters.toArray(new FormatFilter[filters.size()]));
    List<File> files = fileChooser.showOpenMultipleDialog(getActiveStage());

    if (files == null)
        return new File[0];

    return files.toArray(new File[files.size()]);
}

From source file:ca.wumbo.doommanager.client.controller.FileEditorController.java

/**
 * Requests the user to select a file to open.
 *///w w  w.j  ava  2s .c  o  m
public void openFile() {
    log.debug("Attempting to open file...");

    // Provide a file chooser that looks for extensions we know.
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open file");
    fileChooser.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("Any Doom File", "*.wad", "*.WAD", "*.pk3", "*.PK3", "*.dxml",
                    "*.DXML"),
            new FileChooser.ExtensionFilter("DoomManager Project Files", "*.dxml", "*.DXML"),
            new FileChooser.ExtensionFilter("Wad Files", "*.wad", "*.WAD"),
            new FileChooser.ExtensionFilter("PK3 Files", "*.pk3", "*.PK3"),
            new FileChooser.ExtensionFilter("All files", "*.*"));
    List<File> files = fileChooser.showOpenMultipleDialog(coreController.getStage());

    // If the user selected one or more files...
    if (files != null) {
        // For each file the user selected...
        for (File file : files) {
            Path filePath = file.toPath();
            String lowerPath = filePath.toString().toLowerCase();
            log.debug("Attempting to load file from {}...", filePath.toString());

            // Handle based on ending:
            if (lowerPath.endsWith(".wad")) {
                openWad(filePath);
            } else if (lowerPath.endsWith(".pk3")) {
                openPK3(filePath);
            } else if (lowerPath.endsWith(".dxml")) {
                openDXMLProject(filePath);
            }
        }
    }
}

From source file:editeurpanovisu.EquiCubeDialogController.java

/**
 *
 * @return liste des fichiers//from  w  ww.java  2s .  c o m
 */
private File[] choixFichiers() {
    File[] fileLstFich = null;
    FileChooser fcRepertChoix = new FileChooser();
    fcRepertChoix.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("fichier Image (*.jpg|*.bmp|*.tif)", "*.jpg", "*.bmp", "*.tif"));
    File fileRepert = new File(strRepertFichier + File.separator);
    fcRepertChoix.setInitialDirectory(fileRepert);
    List<File> fileListe = fcRepertChoix.showOpenMultipleDialog(stTransformations);
    int i = 0;
    boolean bAttention = false;
    if (fileListe != null) {
        File[] fileLstFich1 = new File[fileListe.size()];
        for (File fileLst : fileListe) {
            if (i == 0) {
                strRepertFichier = fileLst.getParent();
            }
            String strNomFich = fileLst.getAbsolutePath();
            String strExtension;
            strExtension = strNomFich.substring(strNomFich.lastIndexOf(".") + 1, strNomFich.length())
                    .toLowerCase();
            Image img = null;
            if (!strExtension.equals("tif")) {
                img = new Image("file:" + strNomFich);
            } else {
                try {
                    img = ReadWriteImage.readTiff(strNomFich);
                } catch (ImageReadException | IOException ex) {
                    Logger.getLogger(EquiCubeDialogController.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            if (strTypeTransformation.equals(EquiCubeDialogController.EQUI2CUBE)) {
                if (img.getWidth() == 2 * img.getHeight()) {
                    fileLstFich1[i] = fileLst;
                    i++;
                } else {
                    bAttention = true;
                }
            } else {
                if (img.getWidth() == img.getHeight()) {
                    String strNom = fileLst.getAbsolutePath().substring(0,
                            fileLst.getAbsolutePath().length() - 6);
                    boolean bTrouve = false;
                    for (int j = 0; j < i; j++) {
                        String strNom1 = fileLstFich1[j].getAbsolutePath().substring(0,
                                fileLst.getAbsolutePath().length() - 6);
                        if (strNom.equals(strNom1)) {
                            bTrouve = true;
                        }
                    }
                    if (!bTrouve) {
                        fileLstFich1[i] = fileLst;
                        i++;
                    }
                } else {
                    bAttention = true;
                }

            }
        }
        if (bAttention) {
            Alert alert = new Alert(AlertType.ERROR);
            alert.setTitle(rbLocalisation.getString("transformation.traiteImages"));
            alert.setHeaderText(null);
            alert.setContentText(rbLocalisation.getString("transformation.traiteImagesType"));
            alert.showAndWait();
        }
        fileLstFich = new File[i];
        System.arraycopy(fileLstFich1, 0, fileLstFich, 0, i);
        lblDragDropE2C.setVisible(false);
    }

    return fileLstFich;
}