Java 类javafx.stage.FileChooser 实例源码

项目:dss-demonstrations    文件:SignatureController.java   
private void save(DSSDocument signedDocument) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialFileName(signedDocument.getName());
    MimeType mimeType = signedDocument.getMimeType();
    ExtensionFilter extFilter = new ExtensionFilter(mimeType.getMimeTypeString(), "*." + MimeType.getExtension(mimeType));
    fileChooser.getExtensionFilters().add(extFilter);
    File fileToSave = fileChooser.showSaveDialog(stage);

    if (fileToSave != null) {
        try {
            FileOutputStream fos = new FileOutputStream(fileToSave);
            Utils.copy(signedDocument.openStream(), fos);
            Utils.closeQuietly(fos);
        } catch (Exception e) {
            Alert alert = new Alert(AlertType.ERROR, "Unable to save file : " + e.getMessage(), ButtonType.CLOSE);
            alert.showAndWait();
            return;
        }
    }
}
项目:IDBuilderFX    文件:MultiFileChooserController.java   
public void selectmultifiles(ActionEvent event) {
    FileChooser fc = new FileChooser();
//  fc.setInitialDirectory(new File("C:\\PdfBox_Examples"));
    fc.getExtensionFilters().addAll(new ExtensionFilter("PDF Files", "*.pdf"));
    selectedFiles = fc.showOpenMultipleDialog(null);

    // FIX - Repeating files in list if ReADDED

    if (selectedFiles != null) {
        for (int i = 0; i < selectedFiles.size(); i++) {
            fileslist.getItems().add(selectedFiles.get(i).getAbsolutePath());
            mylist.add(selectedFiles.get(i).getAbsolutePath());
            NOOFFILES++;
        }
    } else {
        // Provide Error in window
        System.out.println("Invalid File");
    }
}
项目:Recordian    文件:EditLogEntriesTabController.java   
/**
 * Generates a PDF report for the
 * user to save wherever they choose
 */
private void generateReport() {

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Copy of Report");
    fileChooser.setInitialDirectory(
            new File(System.getProperty("user.home"))
    );
    fileChooser.setInitialFileName("Log Entries.pdf");
    FileChooser.ExtensionFilter pdfExtensionFilter =
            new FileChooser.ExtensionFilter(
                    "PDF - Portable Document Format (.pdf)", "*.pdf");
    fileChooser.getExtensionFilters().add(pdfExtensionFilter);
    fileChooser.setSelectedExtensionFilter(pdfExtensionFilter);
    File file = fileChooser.showSaveDialog(currentStage);

    if (file != null) {
        try {
            exportTableAsPDF(file);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:CleanBT    文件:EditorApp.java   
private void initView() {
    centerArea.getChildren().add(centerBtn);
    centerArea.setAlignment(Pos.CENTER);
    fileTree.setEditable(true);
    fileTree.setCellFactory((TreeView<FileTreeItemModel> tree) -> new FileTreeItemCell());
    mainArea.setTop(topArea);
    mainArea.setCenter(centerArea);
    chooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("All Torrent", "*.torrent"));

    //将菜单栏添加到顶部
    topArea.getChildren().add(menuBar);
    errorDialog.setTitle("错误");
    infoDialog.setTitle("提示");

    centerBtn.setOnAction(event -> openFile());
}
项目:fwm    文件:AddableImage.java   
public void addImage(){
    FileChooser fc = new FileChooser();
    fc.setTitle("Select an image for this object!");
    fc.getExtensionFilters().addAll(filts);
    // figure out who the owner is here... 
    File selectedFile = fc.showOpenDialog(App.getMainController().getStage());
    File addedFile = null;
    if(selectedFile == null){
        // they couldn't decide what they want. 
        return; 
    }
    else
    {
        addedFile = App.worldFileUtil.addMultimedia(selectedFile);
    }
    if(addedFile == null){
        log.error("Added file was null!");
    }
    else
    {
        setImageTwo(addedFile);
        changeEvent();
    }
}
项目:FEFEditor    文件:FileDialogs.java   
public static void saveFile(Stage stage, byte[] bytes) {
    FileChooser chooser = new FileChooser();
    FileChooser.ExtensionFilter lzFilter = new FileChooser.ExtensionFilter("Compressed Bin File (*.bin.lz)",
            "*.bin.lz");
    FileChooser.ExtensionFilter binFilter = new FileChooser.ExtensionFilter("Bin File (*.bin)",
            "*.bin");
    FileChooser.ExtensionFilter allFilter = new FileChooser.ExtensionFilter("All Files",
            "*");
    chooser.getExtensionFilters().addAll(lzFilter, binFilter, allFilter);
    File file = chooser.showSaveDialog(stage);
    if (file != null) {
        try {
            if (file.getName().endsWith("lz")) {
                byte[] compressed = CompressionUtils.compress(bytes);
                Path path = Paths.get(file.getCanonicalPath());
                Files.write(path, compressed);
            } else
                Files.write(Paths.get(file.getCanonicalPath()), bytes);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
项目:shuffleboard    文件:MainWindowController.java   
/**
 * Choose a new file and save the dashboard to that file.
 */
@FXML
private void saveAs() throws IOException {
  FileChooser chooser = new FileChooser();
  chooser.getExtensionFilters().setAll(
      new FileChooser.ExtensionFilter("Shuffleboard Save File (.json)", "*.json"));
  if (currentFile == null) {
    chooser.setInitialDirectory(Storage.getStorageDir());
    chooser.setInitialFileName("shuffleboard.json");
  } else {
    chooser.setInitialDirectory(currentFile.getAbsoluteFile().getParentFile());
    chooser.setInitialFileName(currentFile.getName());
  }

  File selected = chooser.showSaveDialog(root.getScene().getWindow());

  saveFile(selected);
}
项目:FEFEditor    文件:Support.java   
@SuppressWarnings("unused")
@FXML
private void export() {
    FileChooser chooser = new FileChooser();
    FileChooser.ExtensionFilter lzFilter = new FileChooser.ExtensionFilter("Compressed Bin File (*.bin.lz)", "*.bin.lz");
    FileChooser.ExtensionFilter binFilter = new FileChooser.ExtensionFilter("Bin File (*.bin)", "*.bin");
    FileChooser.ExtensionFilter allFilter = new FileChooser.ExtensionFilter("All Files", "*");
    chooser.getExtensionFilters().addAll(lzFilter, binFilter, allFilter);
    File file = chooser.showSaveDialog(GuiData.getInstance().getStage());
    if (file != null) {
        try {
            if (file.getName().endsWith("lz")) {
                byte[] compressed = CompressionUtils.compress(bin.toBin());
                Path path = Paths.get(file.getCanonicalPath());
                Files.write(path, compressed);
            } else
                Files.write(Paths.get(file.getCanonicalPath()), bin.toBin());
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
}
项目:stvs    文件:StvsMenuBarController.java   
private void openSpec(ActionEvent t) {
    FileChooser fileChooser = FileChooserFactory
            .createOpenFileChooser(SPECIFICATION,
                    rootModel.get().getWorkingdir());
    File chosenFile = fileChooser
            .showOpenDialog(view.getScene().getWindow());
    if (chosenFile == null) {
        return;
    }
    try {
        HybridSpecification spec = ImporterFacade
                .importHybridSpec(chosenFile,
                        ImporterFacade.ImportFormat.XML);
        this.rootModel.get().getHybridSpecifications().add(spec);
        this.rootModel.get().getHistory()
                .addFilename(chosenFile.getAbsolutePath());
        setWorkingDir(chosenFile);
    } catch (IOException | ImportException e) {
        AlertFactory.createAlert(e).showAndWait();
    }
}
项目:spring2017java    文件:FXMLDocumentController.java   
@FXML
private void handleFileSaveAction(ActionEvent event) {
    FileChooser fileChooser = new FileChooser();
    File file = fileChooser.showSaveDialog(null);

    if (file != null) {
        try {
            WritableImage writableImage = new WritableImage((int) drawingCanvas.getWidth(), (int) drawingCanvas.getHeight());
            drawingCanvas.snapshot(null, writableImage);
            RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);            
            ImageIO.write(renderedImage, "png", file);
        } catch (IOException ex) {
            Logger.getLogger(FXMLDocumentController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
项目:Parallator    文件:Helper.java   
public static File showFileChooser(Scene scene, FileChooser.ExtensionFilter filter) {
    String home = System.getProperty("user.home");
    File[] downloads = {
            new File(home + "/Downloads/"),
            new File(home + "/Загрузки/"),
            new File(home)
    };
    FileChooser fileChooser = new FileChooser();
    for (File download : downloads) {
        if (download.exists()) {
            fileChooser.setInitialDirectory(download);
            break;
        }
    }
    fileChooser.setSelectedExtensionFilter(filter);
    return fileChooser.showOpenDialog(scene.getWindow());
}
项目:CDN-FX-2.2    文件:SettingsController.java   
@FXML
protected void btnTDClickedFile() throws Exception{
    String path2 = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
    path2 = path2.substring(1, path2.lastIndexOf("/")) + "/";
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open encTitleKeys.bin");
    fileChooser.setInitialDirectory(new File(path2));
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("encTitleKeys", "*.bin"));
    File selectedFile = fileChooser.showOpenDialog(btnCancel.getScene().getWindow());

    if(selectedFile != null){
        String path = selectedFile.getPath();
        textTDFile.setText(path);
        path = path.replaceAll(":", "!");
        PropertiesHandler.setProperties(path, "tdfile");
    }
}
项目:jedai-ui    文件:CompletedController.java   
/**
 * Asks the user for a filename with a save file dialog, and saves a CSV with the entity clusters
 */
public void exportBtnHandler() {
    FileChooser fileChooser = new FileChooser();

    // Set extension filter
    FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("CSV File", "*.csv");
    fileChooser.getExtensionFilters().add(extFilter);

    // Show save file dialog
    File file = fileChooser.showSaveDialog(containerVBox.getScene().getWindow());

    if (file != null) {
        // Results export to CSV
        try {
            PrintToFile.toCSV(entityClusters, file.getAbsolutePath());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }
}
项目:Squid    文件:FileHandler.java   
public static File selectSquid25TaskFile(SquidProject squidProject, Window ownerWindow)
        throws SquidException, IOException, JAXBException, SAXException {
    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Squid 2.5 Task File in Excel '.xls");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Squid 2.5 Excel Task Files", "*.xls"));

    File squidTaskFile = fileChooser.showOpenDialog(ownerWindow);

    if (squidTaskFile != null) {
        if (squidTaskFile.getName().toLowerCase(Locale.US).endsWith(".xls")) {
            retVal = squidTaskFile;
        } else {
            throw new SquidException("Filename does not end with '.xls'");
        }
    }

    return retVal;
}
项目:Squid    文件:FileHandler.java   
public static File saveExpressionFileXML(Expression expression, Window ownerWindow)
        throws IOException {

    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Expression '.xml' file");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression '.xml' files", "*.xml"));
    File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
    fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);
    fileChooser.setInitialFileName(expression.getName() + ".xml");

    File expressionFileXML = fileChooser.showSaveDialog(ownerWindow);

    if (expressionFileXML != null) {
        retVal = expressionFileXML;
        squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
        ((XMLSerializerInterface) expression)
                .serializeXMLObject(expressionFileXML.getAbsolutePath());
    }

    return retVal;
}
项目:Squid    文件:FileHandler.java   
public static File selectExpressionXMLFile(Window ownerWindow)
        throws IOException, JAXBException, SAXException {
    File retVal = null;

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Select Expression xml File '.xml");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Expression xml Files", "*.xml"));
    File mruFolder = new File(squidPersistentState.getMRUExpressionFolderPath());
    fileChooser.setInitialDirectory(mruFolder.isDirectory() ? mruFolder : null);

    File expressionFileXML = fileChooser.showOpenDialog(ownerWindow);

    if (expressionFileXML != null) {
        if (expressionFileXML.getName().toLowerCase(Locale.US).endsWith(".xml")) {
            squidPersistentState.setMRUExpressionFolderPath(expressionFileXML.getParent());
            retVal = expressionFileXML;
        } else {
            throw new IOException("Filename does not end with '.xml'");
        }
    }

    return retVal;
}
项目:voogasalad-ltub    文件:FileVariableSetter.java   
public FileVariableSetter(String variableName) {
    super(variableName);
    Button fileChooser= new Button("Choose file");
    fileLabel=new Label("No file chosen");
    FileChooser chooser=new FileChooser();
    chooser.setInitialDirectory(baseDirectory);
    fileChooser.setOnMouseClicked((event)->{
        File file=chooser.showOpenDialog(new Stage());
        if(file!=null){
            File relativePath=new File(baseDirectory.toURI().relativize(file.toURI()).getPath());
            setField(relativePath);
        }
    });
    this.getChildren().addAll(fileChooser,fileLabel);
    ;
}
项目:stvs    文件:StvsMenuBarController.java   
private boolean saveCode(ActionEvent t) {
    // Set the code filename, if no filename set yet
    Code code = rootModel.get().getScenario().getCode();
    if (code.getFilename().isEmpty()) {
        FileChooser fileChooser = FileChooserFactory
                .createSaveFileChooser(CODE,
                        rootModel.get().getWorkingdir());
        File chosenFile = fileChooser
                .showSaveDialog(view.getScene().getWindow());
        if (chosenFile == null) {
            return false;
        }
        code.setFilename(chosenFile.getAbsolutePath());
    }
    // Export the code to the file
    try {
        ExporterFacade.exportCode(code, false);
        return true;
    } catch (IOException e) {
        AlertFactory.createAlert(e).showAndWait();
        return false;
    }
}
项目:Notebook    文件:FileUtils.java   
public static File chooseFile(){

        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("��ѡ���ļ�");
        if(justVisitedDir == null) {
            // ���ó�ʼĿ¼
            fileChooser.setInitialDirectory(new File(System.getProperty("user.home")));
        } else {
            fileChooser.setInitialDirectory(justVisitedDir);
        }

        fileChooser.getExtensionFilters().addAll(new ExtensionFilter[]{new ExtensionFilter("Image Files", new String[]{"*.png", "*.jpg", "*.jpeg", "*.gif", "*.bmp"}), new ExtensionFilter("JPG", new String[]{"*.jpg"}), new ExtensionFilter("JPEG", new String[]{"*.jpeg"}), new ExtensionFilter("BMP", new String[]{"*.bmp"}), new ExtensionFilter("PNG", new String[]{"*.png"}), new ExtensionFilter("GIF", new String[]{"*.gif"})});
        File file = fileChooser.showOpenDialog(null);
        if(file != null){
            justVisitedDir = file.getParentFile();
        }
        return file;
    }
项目:hygene    文件:MenuController.java   
/**
 * Opens a {@link FileChooser} and sets the parent {@link javafx.stage.Window} as
 * {@link Hygene#getPrimaryStage()#getOwner()}.
 *
 * @param fileChooser the file chooser that needs to be shown to the user
 * @param type        a descriptive type name of the file that needs to be opened
 * @return a file object or {@code null} if no file was selected
 * @throws IOException               if unable to open or parse the file
 * @throws UIInitialisationException if this method was called before {@link Hygene} was instantiated
 */
private File openFileAction(final FileChooser fileChooser, final String type)
        throws UIInitialisationException, IOException {
    final Stage primaryStage = Hygene.getInstance().getPrimaryStage();

    final File recentDirectory = RecentDirectory.get(type);
    if (recentDirectory.exists()) {
        fileChooser.setInitialDirectory(recentDirectory);
    }

    final File file = fileChooser.showOpenDialog(primaryStage.getScene().getWindow());
    if (file == null) {
        return null;
    }

    if (file.getParentFile() != null) {
        RecentDirectory.store(type, file.getParentFile());
    }

    return file;
}
项目:Steam-trader-tools    文件:AppController.java   
@FXML
private void saveNewAppListToXml(ActionEvent event)
{
    JAXBContext context;
    try
    {
        context = JAXBContext.newInstance(UserAppList.class);
        Marshaller marshaller = context.createMarshaller();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        FileChooser fc = new FileChooser();
        File file = fc.showSaveDialog(null);
        if (file != null)
        {
            marshaller.marshal(userAppList, file);
            JFXSnackbar info = new JFXSnackbar(root);
            info.show(I18n.getMessage("savedtoxml") + file.getAbsolutePath(), 3000);
            prefs.put(PreferencesKeys.SAVE_PATH.toString(), file.getAbsolutePath());
        }
    } catch (JAXBException e)
    {
        e.printStackTrace();
    }

}
项目:drd    文件:ItemWeaponMeleController.java   
public void handleSelectImage(MouseEvent mouseEvent) {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(imageChooserTitle);
    fileChooser.getExtensionFilters().add(new ExtensionFilter("PNG", "*.png"));
    final File file = fileChooser
        .showOpenDialog(((Node) mouseEvent.getSource()).getScene().getWindow());
    if (file == null) {
        return;
    }

    try {
        final byte[] image = ImageUtils.readImage(file);
        model.imageRaw.set(image);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
项目:SerialAssistant    文件:HomeController.java   
/**
 * 保存数据按钮被点击
 */
@FXML
public void onSaveDataBtnClicked() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("保存到...");
    File file = fileChooser.showSaveDialog(AppDelegate.static_stage);

    if (file == null) {
        receivedToFileCbox.setSelected(false);
        return;
    }

    //解除文件占用
    unlockFile(file);

    //统一换行符
    String data = dataTextArea.getText().replace("\r", "");
    data = data.replace("\n", "\r\n");

    //写入文件
    writeToFile(data, file);

}
项目:Matcher    文件:FileMenu.java   
private void saveMatches() {
    Path path = Gui.requestFile("Save matches file", gui.getScene().getWindow(), Arrays.asList(new FileChooser.ExtensionFilter("Matches", "*.match")), false);
    if (path == null) return;

    if (!path.getFileName().toString().toLowerCase(Locale.ENGLISH).endsWith(".match")) {
        path = path.resolveSibling(path.getFileName().toString()+".match");
    }

    try {
        if (Files.isDirectory(path)) {
            gui.showAlert(AlertType.ERROR, "Save error", "Invalid file selection", "The selected file is a directory.");
        } else if (Files.exists(path)) {
            Files.deleteIfExists(path);
        }

        if (!gui.getMatcher().saveMatches(path)) {
            gui.showAlert(AlertType.WARNING, "Matches save warning", "No matches to save", "There are currently no matched classes, so saving was aborted.");
        }
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return;
    }
}
项目:NativeJFileChooser    文件:NativeJFileChooser.java   
@Override
public void setAcceptAllFileFilterUsed(boolean bool) {
    boolean differs = isAcceptAllFileFilterUsed() ^ bool;
    super.setAcceptAllFileFilterUsed(bool);
    if (!FX_AVAILABLE) {
        return;
    }
    if (differs) {
        if (bool) {
            fileChooser.getExtensionFilters()
                    .add(new FileChooser.ExtensionFilter("All files", "*.*"));
        } else {
            for (Iterator<FileChooser.ExtensionFilter> it
                    = fileChooser.getExtensionFilters().iterator(); it.hasNext();) {
                FileChooser.ExtensionFilter filter = it.next();
                if (filter.getExtensions().size() == 1
                        && filter.getExtensions().contains("*.*")) {
                    it.remove();
                }
            }
        }
    }
}
项目:candlelight    文件:Ludwig.java   
private void loadDungeon(Stage stage)
{
    FileChooser chooser = new FileChooser();
    chooser.setInitialFileName("dungeon.json");
    File file = chooser.showOpenDialog(stage);

    if (file != null)
    {
        try
        {
            JSONObject data;
            BufferedReader reader = new BufferedReader(new FileReader(file));
            JSONFormatParser parser = new JSONFormatParser(256);
            data = (JSONObject) parser.parse(reader);
            reader.close();
            this.dungeon = Dungeon.loadFromJSON(data);
            this.dungeonHandler = new DungeonHandler(this.dungeon);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
    }
}
项目:file-transfer    文件:NetPane.java   
protected void createSelectButton() {
    selectButton = new Button("Select...");
    selectButton.setOnAction(event -> {
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Select file");
        if (LastVisitedDirectory.getInstance().wasVisited()) {
            fileChooser.setInitialDirectory(new File(LastVisitedDirectory.getInstance().getPath()));
        }
        try {
            String newPath = getFilePath(fileChooser, primaryStage);
            LastVisitedDirectory.getInstance().setLastVisitedDirectory(newPath);
            pathTextField.setText(newPath);
        } catch (NullPointerException e) {
            System.out.println("Canceled");
        }
    });
}
项目:gatepass    文件:Restore.java   
public String getRestore(){
    String backuppath ="";
    File file;
    FileChooser fileChooser= new FileChooser();
    file = fileChooser.showOpenDialog(stage);
    fileChooser.setTitle("Select Photo");
       if (file != null) {
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("All Images", "*.*"),
                new FileChooser.ExtensionFilter("SQL", "*.sql")
       );

        backuppath = file.getAbsolutePath();      
}
    return backuppath;
}
项目:tenhou-visualizer    文件:DownloaderController.java   
public void exportMjlog(ActionEvent actionEvent) throws IOException {
    if (this.tableView.getSelectionModel().getSelectedItem() != null) {
        InfoSchema infoSchema = this.tableView.getSelectionModel().getSelectedItem();
        String content = this.databaseService.findMjlogById(infoSchema.getId());
        if (content != null) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setInitialFileName(infoSchema.getId());
            fileChooser.setTitle("Save mjlog File");
            fileChooser.getExtensionFilters().add(
                    new FileChooser.ExtensionFilter("mjlog Files", "*.mjlog"));
            File selectedFile = fileChooser.showSaveDialog(this.dateListView.getScene().getWindow());
            if (selectedFile != null) {
                Files.copy(new ByteArrayInputStream(content.getBytes()), selectedFile.toPath());
            }
        }
    }
}
项目:OpenDiabetes    文件:MainGuiController.java   
@FXML
private void handleButtonBrowseAbbott(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ABBOTT_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.TXT_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        abbottTextField.setText(sb.toString().substring(0, sb.length() - 1));
        abbottCheckBox.setSelected(true);
    }
}
项目:OpenDiabetes    文件:MainGuiController.java   
@FXML
private void handleButtonBrowseGoogleFit(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_GOOGLE_FIT_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.CSV_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        googleFitTextField.setText(sb.toString().substring(0, sb.length() - 1));
        googleFitCheckBox.setSelected(true);
    }
}
项目:OpenDiabetes    文件:MainGuiController.java   
@FXML
private void handleButtonBrowseGoogleTracks(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_GOOGLE_TRACKS_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.JSON_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        googleGatheredTextField.setText(sb.toString().substring(0, sb.length() - 1));
        googleGatheredCheckBox.setSelected(true);
    }
}
项目:OpenDiabetes    文件:MainGuiController.java   
@FXML
private void handleButtonBrowseRoche(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ROCHE_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.CSV_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        sonyTextField.setText(sb.toString().substring(0, sb.length() - 1));
        sonyCheckBox.setSelected(true);
    }
}
项目:OpenDiabetes    文件:MainGuiController.java   
@FXML
private void handleButtonBrowseOpenDiabetesVault(ActionEvent event) {
    Stage stage = (Stage) ap.getScene().getWindow();
    File lastPath = new File(prefs.get(Constants.IMPORTER_ODV_IMPORT_PATH_KEY + 0, ""));

    FileChooser fileChooser = new FileChooser();
    configureFileChooser(fileChooser, lastPath, Constants.JSON_EXTENSION_FILTER);
    List<File> files = fileChooser.showOpenMultipleDialog(stage);

    if (files != null && !files.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        files.forEach((item) -> {
            sb.append(item.getAbsolutePath()).append(Constants.MULTI_FILE_PATH_DELIMITER);
        });
        odvTextField.setText(sb.toString().substring(0, sb.length() - 1));
        odvCheckBox.setSelected(true);
    }
}
项目:voogasalad-ltub    文件:ImageVariableSetter.java   
public ImageVariableSetter(String variableName) {
    super(variableName);
    myImagePath=new SimpleStringProperty();
    myContents=new VBox();
    getChildren().add(myContents);
    Button button= new Button("Choose Image File");
    button.setOnMouseClicked((event)->{
        FileChooser chooser=new FileChooser();
        chooser.setInitialDirectory(base);  
        File imageFile=chooser.showOpenDialog(new Stage());
        if(imageFile!=null){
            File relativePath=new File(base.toURI().relativize(imageFile.toURI()).getPath());
            myImagePath.set(relativePath.toString());
            System.out.println(relativePath);
        }
    });
    myContents.getChildren().addAll(new ImageDisplay(),button);
    myContents.setSpacing(20);
    System.out.println(base);
}
项目:Optics-Simulator    文件:MenuBarController.java   
/**
 * Save image.
 */
@FXML
public void saveImage(){
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save Image");
    fileChooser.getExtensionFilters().addAll(
            new FileChooser.ExtensionFilter("PNG File","*.png"),
            new FileChooser.ExtensionFilter("GIF File","*.gif"));

    File image = fileChooser.showSaveDialog(saveNode.getScene().getWindow());

    int fileExtensionLength = fileChooser.getSelectedExtensionFilter().getExtensions().get(0).length();
    String fileExt = fileChooser.getSelectedExtensionFilter().getExtensions().get(0).substring(2,fileExtensionLength);

    try {
        ImageIO.write(getSnapshot(saveNode),fileExt,image);
    } catch (IOException e) {
        e.printStackTrace();
    }

}
项目:Dronology    文件:InteractiveFlightPlannerView.java   
private Button createSaveFlightButton(Stage stage){
       Button btnSaveFlight = new Button();
       btnSaveFlight.setLayoutX(10);
       btnSaveFlight.setLayoutY(60);;
       btnSaveFlight.setText("Save Flight");

       btnSaveFlight.setOnAction(       
       new EventHandler<ActionEvent>() {
          @Override
          public void handle(final ActionEvent e) {
           FileChooser fileChooser = new FileChooser();
               fileChooser.setTitle("Flight plan (xml)");
               File file = fileChooser.showSaveDialog(stage);
               if (file != null) {
                   System.out.println("Selected " + file);
                   try {
                        fzv.setPlanningMode(false);
                    new SaveXMLFlight(file.getAbsolutePath(),wayPoints);
               } catch (IOException | FlightZoneException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
               }     
            }
       }});
       return btnSaveFlight;
}
项目:Dronology    文件:ButtonGenerator.java   
/**
 * Load flight plans from file
 * @param flightZoneView
 * @param btnText
 * @param stage
 * @return
 */
Button makeFlightPickerButton(final FlightZoneView flightZoneView, String btnText, Stage stage){
    Button btnFlights = createButton(btnText, 120);
    btnFlights.setOnAction(
       new EventHandler<ActionEvent>() {
       @Override
       public void handle(final ActionEvent e) {
           // File file = fileChooser.showOpenDialog(stage);
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("Flight plan (xml)");
            fileChooser.getExtensionFilters().addAll(
                 new ExtensionFilter("XML Files", "*.xml"));
            File selectedFile = fileChooser.showOpenDialog(stage);
            if (selectedFile != null) {
               System.out.println("Selected " + selectedFile);
               flightZoneView.flightManager.loadFlightFromXML(selectedFile.toString());
            }
            }
       });
    return btnFlights;
}
项目:aem-epic-tool    文件:PackageInfoController.java   
@FXML
void exportTypeSummaries(ActionEvent event) throws IOException {
    FileChooser saveChooser = new FileChooser();
    saveChooser.setTitle("Export (Save) data");
    saveChooser.setInitialFileName(pkg.getName() + "_type_summary.xlsx");
    File saveFile = saveChooser.showSaveDialog(null);
    if (saveFile != null) {
        FileOutputStream out = new FileOutputStream(saveFile);
        String[] headers = new String[]{
            "Type", "Count"
        };
        ReportUtil.exportSpreadsheet(out, pkgContents.getFilesByType().entrySet(), headers,
                Map.Entry::getKey,
                e->e.getValue().size()
        );
        out.close();
    }
}
项目:aem-epic-tool    文件:PackageListController.java   
public void exportPackagesButtonPressed(ActionEvent evt) throws FileNotFoundException, IOException {
    FileChooser saveChooser = new FileChooser();
    saveChooser.setTitle("Export (Save) data");
    saveChooser.setInitialFileName("package_list.xlsx");
    File saveFile = saveChooser.showSaveDialog(null);
    if (saveFile != null) {
        FileOutputStream out = new FileOutputStream(saveFile);
        String[] headers = new String[]{
            "Group", "Package Name", "Package File", "Size", "Version",
            "Created", "Created By",
            "Last Modified", "Modified By",
            "Last Unpacked", "Unpacked By"
        };
        ReportUtil.exportSpreadsheet(out, packageList, headers,
                PackageType::getGroup, PackageType::getName,
                PackageType::getDownloadName, PackageType::getSize,
                PackageOps::getInformativeVersion,
                PackageType::getCreated, PackageType::getCreatedBy,
                PackageType::getLastModified, PackageType::getLastModifiedBy,
                PackageType::getLastUnpacked, PackageType::getLastUnpackedBy
        );
        out.close();
    }
}