Java 类javafx.stage.FileChooser.ExtensionFilter 实例源码

项目: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;
        }
    }
}
项目:cyoastudio    文件:MainWindow.java   
@FXML
void exportJson() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile());
    fileChooser.setTitle("Export plain text");
    fileChooser.getExtensionFilters().addAll(
            new ExtensionFilter("JSON files", "*.json"),
            new ExtensionFilter("All files", "*"));
    File selected = fileChooser.showSaveDialog(stage);
    if (selected != null) {
        try {
            Preferences.setPath("lastDir", selected.toPath().getParent());

            byte[] jsonData = ProjectSerializer.toBytes(project, ImageType.BASE64);
            FileUtils.writeByteArrayToFile(selected, jsonData);
        } catch (Exception e) {
            showError("Error while exporting", e);
        }
    }
}
项目:drd    文件:ItemArmorController.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();
    }
}
项目: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;
    }
项目: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;
    }
}
项目:marathonv5    文件:FileSelectionStage.java   
private HBox createBrowserField() {
    HBox browseFieldBox = new HBox(5);
    dirField = new TextField();
    dirField.setId("DirectoryField");
    dirField.textProperty().addListener((observable, oldValue, newValue) -> updateOKButton());
    HBox.setHgrow(dirField, Priority.ALWAYS);
    Button browseButton = FXUIUtils.createButton("browse", "Browse directory", true, "Browse");
    FileSelectionHandler browserListener;
    String fileType = fileSelectionInfo.getFileType();
    if (fileType != null) {
        browserListener = new FileSelectionHandler(this,
                new ExtensionFilter(fileType, Arrays.asList(fileSelectionInfo.getExtensionFilters())), this, null,
                fileSelectionInfo.getTitle());
    } else {
        browserListener = new FileSelectionHandler(this, null, this, null, fileSelectionInfo.getTitle());
        browserListener.setMode(FileSelectionHandler.DIRECTORY_CHOOSER);
    }
    browserListener.setPreviousDir(new File(System.getProperty(Constants.PROP_PROJECT_DIR, ProjectLayout.projectDir)));
    browseButton.setOnAction(browserListener);
    Label label = createLabel("Name: ");
    label.setMinWidth(Region.USE_PREF_SIZE);
    label.setId("FileSelectedLabel");
    browseFieldBox.getChildren().addAll(label, dirField, browseButton);
    VBox.setMargin(browseFieldBox, new Insets(5, 5, 5, 5));
    return browseFieldBox;
}
项目: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;
}
项目:cyoastudio    文件:MainWindow.java   
@FXML
void exportHTML() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile());
    fileChooser.setTitle("Export HTML");
    fileChooser.getExtensionFilters().addAll(
            new ExtensionFilter("HTML files", "*.html", ".htm"),
            new ExtensionFilter("All files", "*"));
    File selected = fileChooser.showSaveDialog(stage);
    if (selected != null) {
        try {
            Preferences.setPath("lastDir", selected.toPath().getParent());
            String text = project.getTemplate().render(project, ImageType.BASE64);

            FileUtils.writeStringToFile(selected, text, Charset.forName("UTF-8"));
        } catch (Exception e) {
            showError("Error while exporting", e);
        }
    }
}
项目:cyoastudio    文件:MainWindow.java   
@FXML
void importJson() {
    if (!isUserSure("Import project")) {
        return;
    }

    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile());
    fileChooser.setTitle("Import project");
    fileChooser.getExtensionFilters().addAll(
            new ExtensionFilter("JSON file", "*.json"),
            new ExtensionFilter("All files", "*"));
    File selected = fileChooser.showOpenDialog(stage);
    if (selected != null) {
        try {
            Preferences.setPath("lastDir", selected.toPath().getParent());

            FileReader reader = new FileReader(selected);
            flushDataStorage();
            replaceProject(ProjectSerializer.fromReader(reader, ImageType.BASE64));
            reader.close();
        } catch (Exception e) {
            showError("Couldn't import file", e);
        }
    }
}
项目:cyoastudio    文件:MainWindow.java   
@FXML
void openProject() {
    if (!isUserSure("Open project")) {
        return;
    }

    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile());
    fileChooser.setTitle("Open project");
    fileChooser.getExtensionFilters().addAll(
            new ExtensionFilter("CYOA Studio Project", "*.cyoa"),
            new ExtensionFilter("All files", "*"));
    File selected = fileChooser.showOpenDialog(stage);
    if (selected != null) {
        try {
            Preferences.setPath("lastDir", selected.toPath().getParent());

            flushDataStorage();
            replaceProject(ProjectSerializer.readFromZip(selected.toPath()));
            saveLocation = selected.toPath();
        } catch (Exception e) {
            showError("Couldn't open file", e);
        }
    }
}
项目:cyoastudio    文件:MainWindow.java   
private boolean selectSaveLocation() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(Preferences.getPath("lastDir").toFile());
    fileChooser.setTitle("Save");
    fileChooser.getExtensionFilters().addAll(
            new ExtensionFilter("CYOA Studio Project", "*.cyoa"),
            new ExtensionFilter("All files", "*"));
    File selected = fileChooser.showSaveDialog(stage);
    if (selected == null) {
        return false;
    } else {
        Preferences.setPath("lastDir", selected.toPath().getParent());

        saveLocation = selected.toPath();
        return true;
    }
}
项目:cyoastudio    文件:MainWindow.java   
@FXML
void templateFromFile() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(Preferences.getPath("lastTemplateDir").toFile());
    fileChooser.setTitle("Import template");
    fileChooser.getExtensionFilters().addAll(
            new ExtensionFilter("CYOA Studio Template", "*.cyoatemplate"),
            new ExtensionFilter("All files", "*"));
    File selected = fileChooser.showOpenDialog(stage);
    if (selected != null) {
        try {
            Preferences.setPath("lastTemplateDir", selected.toPath().getParent());

            Path tempDirectory = Files.createTempDirectory(null);
            ZipUtil.unpack(selected, tempDirectory.toFile());

            loadTemplate(tempDirectory);

            FileUtils.deleteDirectory(tempDirectory.toFile());
        } catch (Exception e) {
            showError("Could not load template", e);
        }
    }
}
项目:drd    文件:ItemGeneralController.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();
    }
}
项目:drd    文件:ItemWeaponRangedController.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();
    }
}
项目:drd    文件:ItemBackpackController.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();
    }
}
项目: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();
    }
}
项目: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");
    }
}
项目:jmonkeybuilder    文件:PluginsDialog.java   
/**
 * Process install a plugin.
 */
@FXThread
private void processAdd() {

    GAnalytics.sendPageView("PluginChooseDialog", null, "/dialog/PluginChooseDialog");
    GAnalytics.sendEvent(GAEvent.Category.DIALOG, GAEvent.Action.DIALOG_OPENED, "PluginChooseDialog");

    final FileChooser chooser = new FileChooser();
    chooser.setTitle(Messages.PLUGINS_DIALOG_FILE_CHOOSER_TITLE);
    chooser.setSelectedExtensionFilter(new ExtensionFilter(Messages.PLUGINS_DIALOG_FILE_CHOOSER_FILTER, "*.zip"));
    chooser.setInitialDirectory(new File(System.getProperty("user.home")));

    final File result = chooser.showOpenDialog(getDialog());

    if (result == null) {
        return;
    }

    PLUGIN_MANAGER.installPlugin(result.toPath());

    refreshPlugins();
}
项目:Universal-Sorter    文件:Controller.java   
public void saveFile() throws IOException {
    if (filePresent == true) { // save

        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(currentFile.getAbsolutePath()), "UTF-8"));
        try {
            String ls = System.getProperty("line.separator");
            String text = textField.getText().replaceAll("\n", ls);
            out.write(text);
        } finally {
            out.close();
        }

    } else { // save as

        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
        fileChooser.getExtensionFilters().add(extFilter);
        File file = fileChooser.showSaveDialog(textField.getScene().getWindow());

        if (file != null) {
            SaveFileAction(textField.getText(), file);
        }
    }
}
项目:greenbeans    文件:ImportFilesService.java   
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());
}
项目:Game-Engine-Vooga    文件:SoundEffectGUI.java   
private void initialize () {
    fileChooser = new VoogaFileChooser();
    fileChooser.setInitialDirectory(new File("resources/sound/"));
    ResourceBundle extensions = VoogaBundles.extensionProperties;
    for (String key : extensions.keySet()) {
        if (extensions.getString(key).equalsIgnoreCase("AUDIO")) {
            fileChooser.addFilters(new ExtensionFilter("(" + key + ")", "*." + key));
        }
    }
    file = new Text();
    browse = new ButtonMaker().makeButton("Browse", e -> {
        try {
            file.setText(fileChooser.launch());
        }
        catch (Exception e1) {
            VoogaAlert alert = new VoogaAlert(e1.getMessage());
            alert.showAndWait();
        }
    });
    node = generateHBox(new Text("Sound Path"), browse, file);
}
项目:Gargoyle    文件:XsltTransformComposite.java   
/**
 * 템플릿 파일 open
 * 
 * @작성자 : KYJ
 * @작성일 : 2017. 9. 1.
 */
@FXML
public void miOpenTemplates() {
    File file = FxUtil.showFileOpenDialog(FxUtil.getWindow(this), c -> {
        c.getExtensionFilters()
                .add(new ExtensionFilter("XLST Template files (*.gxml)", GargoyleExtensionFilters.EXTENSION_COMMONS + "gxml"));
    });

    String cont = FileUtil.readFile(file, LoadFileOptionHandler.getDefaultHandler());
    JSONObject json = ValueUtil.toJSONObject(cont);
    Object xmlObj = json.get("xmlData");

    if (ValueUtil.isNotEmpty(xmlObj)) {
        xeXmlData.setText(xmlObj.toString());
    }

    Object xlstObj = json.get("xsltData");
    if (ValueUtil.isNotEmpty(xlstObj)) {
        xeXsltData.setText(xlstObj.toString());
    }

}
项目:Gargoyle    文件:SceneBuilderLocationComposite.java   
/***********************************************************************************/
/* 이벤트 구현 */

@FXML
public void btnBrowseOnMouseClick() {
    File selectedFile = DialogUtil.showFileDialog(this.getScene().getWindow(), chooser -> {
        String property = System.getProperty("user.home");

        String pathname = String.join(File.separator, property, "AppData", "Local", "SceneBuilder");
        File file = new File(pathname);
        if (!file.exists())
            file = new File(property);
        chooser.setTitle("Scenebuilder Location");
        chooser.setInitialFileName("SceneBuilder.exe");
        chooser.setInitialDirectory(file);
        chooser.setSelectedExtensionFilter(new ExtensionFilter(GargoyleExtensionFilters.EXE_NAME, GargoyleExtensionFilters.EXE));
    });

    if (selectedFile != null && selectedFile.exists()) {
        txtLocation.setText(selectedFile.getAbsolutePath());
    }

}
项目:Gargoyle    文件:SqlTab.java   
public void miOenOnAction(ActionEvent e) {
        File showFileDialog = DialogUtil.showFileDialog(/*SharedMemory.getPrimaryStage()*/ null, choser -> {
            /*마지막에 선택한 경로를 자동선택하는 기능이 추가되었으므로 기본경로 선택 처리는 없앰.*/
            //                  String dir = System.getProperty("user.home");
            //                  choser.setInitialDirectory(new File(dir));
            choser.getExtensionFilters().add(new ExtensionFilter(GargoyleExtensionFilters.SQL_NAME, GargoyleExtensionFilters.SQL));
//          choser.getExtensionFilters().add(new ExtensionFilter("SQL files (*.sql)", "*.sql"));
        });

        //선택한 파일이 정상적으로 선택된 경우는 null이 아님.
        if (showFileDialog != null) {

            String fileContent = FileUtil.readFile(showFileDialog, new LoadFileOptionHandler());
            if (fileContent != null /*공백여부는 체크안함. 파일 내용에 실제 공백이 포함될 수 있으므로...*/) {
                setTxtSql(fileContent);
                setText(showFileDialog.getName());

            }
        }

        e.consume();
    }
项目:gralog    文件:MainWindow.java   
public void onOpen() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(getLastDirectory()));
    fileChooser.getExtensionFilters().addAll(
        new FileChooser.ExtensionFilter("All (*.*)", "*.*"),
        new FileChooser.ExtensionFilter("Graph Markup Language (*.graphml)", "*.graphml")
    );

    // add export-filters to list of extensions
    for (String format : ImportFilterManager.getImportFilterClasses()) {
        ImportFilterDescription descr = ImportFilterManager.getImportFilterDescription(format);
        ExtensionFilter filter = new FileChooser.ExtensionFilter(
            descr.name() + " (*." + descr.fileExtension() + ")",
            "*." + descr.fileExtension());
        fileChooser.getExtensionFilters().add(filter);
    }

    fileChooser.setInitialFileName("*.*");
    fileChooser.setTitle("Open File");
    List<File> list = fileChooser.showOpenMultipleDialog(stage);
    if (list != null) {
        setLastDirectory(list.get(0));
        for (File file : list)
            doOpenFile(file);
    }
}
项目:fx-log    文件:MainController.java   
/**
 * Opens a file chooser to choose the file to tail, and starts tailing the selected file.
 */
@FXML
public void openFile() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Open Log File");
    fileChooser.getExtensionFilters()
               .add(new ExtensionFilter("Log files (*.txt, *.log, *.out)", "*.txt", "*.log", "*.out"));
    fileChooser.getExtensionFilters().add(new ExtensionFilter("All files", "*.*"));
    File file = fileChooser.showOpenDialog(mainPane.getScene().getWindow());
    if (file != null) {
        try {
            startTailingFile(file);
        } catch (FileNotFoundException e) {
            ErrorDialog.selectedFileNotFound(file.getPath());
        }
    }
}
项目:Push2Display    文件:DisplayEmulator.java   
/**
 * Select the Bitwig executable.
 */
private void selectDAWExecutable ()
{
    final FileChooser chooser = new FileChooser ();
    chooser.setTitle ("Select the DAW executable file");

    if (OperatingSystem.get () == OperatingSystem.WINDOWS)
    {
        final ExtensionFilter filter = new ExtensionFilter ("Executable", "*.exe");
        chooser.getExtensionFilters ().add (filter);
    }

    final File file = chooser.showOpenDialog (this.stage);
    if (file != null)
        this.applicationCommand.setText (file.getAbsolutePath ());
}
项目:PL3-2016    文件:MainController.java   
/**
* Used to import a new .gfa file. It will open up a file explorer to browse to your file.
* It will build the recently opened file submenu and the existing submenu accordingly.
* It also checks if the import is really new. If it is, then getting an existing database
* should return null and it will start the import, else it will open it as an existing file.
* @param actionEvent    An Event representing some type of action
*/
public void importNew(final ActionEvent actionEvent) {
 final FileChooser fileExplorer = new FileChooser();
 fileExplorer.getExtensionFilters().addAll(new ExtensionFilter("gfa files", "*.gfa"));
 File file = fileExplorer.showOpenDialog(verticalBox.getScene().getWindow());

 if (file != null) {
     RecentHandler recent = new RecentHandler();
     final String fileName = FilenameUtils.removeExtension(file.getName());
     final String dbPath = System.getProperty("user.dir") 
                + File.separator + "db" + File.separator + fileName;
     if (new ExistingHandler().buildExistingMap().get(fileName) == null) {
         recent.buildRecent(dbPath, fileName);
         ImportHandler importer = new ImportHandler(
                 Launcher.getStage(), file.getAbsolutePath(), fileName);
         importer.startImport();
         updateExisting();
     } else {
         openExisting(dbPath, fileName);
     }  
       }
}
项目:certmgr    文件:CertExportController.java   
@SuppressWarnings("unused")
@FXML
void onCmdChooseFileDestination(ActionEvent evt) {
    FileChooser chooser = new FileChooser();
    List<ExtensionFilter> extensionFilters = new ArrayList<>();
    CertWriter writer = this.ctlFormatOption.getValue();

    if (writer != null) {
        extensionFilters.add(new ExtensionFilter(writer.fileType(), writer.fileExtensionPatterns()));
    }
    extensionFilters.add(FileChooserHelper.filterFromString(CertExportI18N.formatSTR_FILTER_ALLFILES()));
    chooser.getExtensionFilters().addAll(extensionFilters);
    chooser.setSelectedExtensionFilter(extensionFilters.get(0));
    chooser.setInitialDirectory(this.preferenceInitalDirectory.getValueAsFile());

    File fileSource = chooser.showSaveDialog(getUI());

    if (fileSource != null) {
        this.ctlFileDestinationInput.setText(fileSource.getAbsolutePath());
        this.preferenceInitalDirectory.putValueFromFile(fileSource.getParentFile());
        syncPreferences();
    }
}
项目:certmgr    文件:CertImportController.java   
@SuppressWarnings("unused")
@FXML
void onCmdChooseFileSource(ActionEvent evt) {
    FileChooser chooser = new FileChooser();
    List<ExtensionFilter> extensionFilters = new ArrayList<>();

    extensionFilters.add(FileChooserHelper.filterFromString(CertImportI18N.formatSTR_FILTER_ALLFILES()));
    for (CertReader reader : CertReaders.REGISTERED.providers()) {
        extensionFilters.add(new ExtensionFilter(reader.fileType(), reader.fileExtensionPatterns()));
    }

    chooser.getExtensionFilters().addAll(extensionFilters);
    chooser.setSelectedExtensionFilter(extensionFilters.get(0));
    chooser.setInitialDirectory(this.preferenceInitalDirectory.getValueAsFile());

    File fileSource = chooser.showOpenDialog(getUI());

    if (fileSource != null) {
        this.ctlFileSourceInput.setText(fileSource.getAbsolutePath());
        this.preferenceInitalDirectory.putValueFromFile(fileSource.getParentFile());
        syncPreferences();
        validateAndReloadFileSource();
    }
}
项目:Encryptor    文件:Controller.java   
public void saveFile() throws IOException {
    if (filePresent == true) { // save

        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(currentFile.getAbsolutePath()), "UTF-8"));
        try {
            String ls = System.getProperty("line.separator");
            String text = textField.getText().replaceAll("\n", ls);
            out.write(text);
        } finally {
            out.close();
        }

    } else { // save as

        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
        fileChooser.getExtensionFilters().add(extFilter);
        File file = fileChooser.showSaveDialog(textField.getScene().getWindow());

        if (file != null) {
            SaveFileAction(textField.getText(), file);
        }
    }
}
项目:Encryptor    文件:Controller.java   
public void saveFile() throws IOException {
    if (filePresent == true) { // save

        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(currentFile.getAbsolutePath()), "UTF-8"));
        try {
            String ls = System.getProperty("line.separator");
            String text = textField.getText().replaceAll("\n", ls);
            out.write(text);
        } finally {
            out.close();
        }

    } else { // save as

        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
        fileChooser.getExtensionFilters().add(extFilter);
        File file = fileChooser.showSaveDialog(textField.getScene().getWindow());

        if (file != null) {
            SaveFileAction(textField.getText(), file);
        }
    }
}
项目:Encryptor    文件:Controller.java   
public void saveFile() throws IOException {
    if (filePresent == true) { // save

        BufferedWriter out = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(currentFile.getAbsolutePath()), "UTF-8"));
        try {
            String ls = System.getProperty("line.separator");
            String text = textField.getText().replaceAll("\n", ls);
            out.write(text);
        } finally {
            out.close();
        }

    } else { // save as

        FileChooser fileChooser = new FileChooser();
        FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("TXT files (*.txt)", "*.txt");
        fileChooser.getExtensionFilters().add(extFilter);
        File file = fileChooser.showSaveDialog(textField.getScene().getWindow());

        if (file != null) {
            SaveFileAction(textField.getText(), file);
        }
    }
}
项目:LuoYing    文件:FileConverter.java   
private List<ExtensionFilter> getFilters() {
    // 示例:"Model File|*.j3o|*.obj|*.mesh.xml,All Files|*.*"
    String[] filters = this.featureHelper.getAsArray(FEATURE_FILTERS);
    if (filters != null && filters.length > 0) {
        List<ExtensionFilter> efs = new ArrayList(filters.length);
        for (String f : filters) {
            if (f == null || f.trim().equals("")) {
                continue;
            }
            List<String> itemList = new ArrayList(Arrays.asList(f.split("\\|")));
            String des = itemList.remove(0);
            efs.add(new ExtensionFilter(des, itemList));
        }
        return efs;
    }
    return Collections.EMPTY_LIST;
}
项目:story-inspector    文件:MainPageController.java   
/**
 * Triggered by the inspect button. Opens a dialogue for the user to decide the output file for the report, then executes the report, writing the
 * output to that file.
 *
 * @throws FileNotFoundException
 *             If the story file or report spec file no longer exist.
 */
@FXML
private void inspect() {
    final FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Choose Report Output File");
    fileChooser.setInitialDirectory(this.selectedStoryFile.getParentFile());
    fileChooser.setInitialFileName(getDefaultReportOutputFile().getName());
    fileChooser.getExtensionFilters().add(new ExtensionFilter("Microsoft Word Open XML Format Document", "*.docx"));
    final File reportOutputFile = fileChooser.showSaveDialog(ControllerUtils.getStage(this.reportNameLabel));

    if (reportOutputFile != null) {
        try {
            executeReport(reportOutputFile);
        } catch (final FileNotFoundException e) {
            final Alert alert = new Alert(AlertType.ERROR, "File not found: " + e.getLocalizedMessage(), ButtonType.OK);
            alert.showAndWait();
        }
    }
}
项目:TranslationHelper    文件:OverviewPresenter.java   
/**
 * Allows the user to choose an arbitrary *.resx file and asks them to choose out of the available locales for
 * Left
 * and Right in the view.
 */
public void fileChoosing() {
    project.hide();
    view.hide();
    final Path chosenFile = DIALOG.chooseFile("Select a resx or thp file",
            new ExtensionFilter("Resource file", "*.resx"),
            new ExtensionFilter("TranslationHelper Project file", "*.thp"));
    if (chosenFile == null) {
        project.show();
        return;
    }
    if (chosenFile.getFileName().toString().endsWith(".thp")) {
        project.loadProject(chosenFile);
        project.show();
    } else {
        view.loadFiles(chosenFile);
        view.show();
        view.selectLocale();
    }
}
项目:iso-game-engine    文件:EditorCanvas.java   
/**
 * Save the current stage under a new name.
 * */
public void saveStageAs(final File dataDir) {
    final Stage stage = getStage();
    if (stage == null) return;

    final FileChooser fc = new FileChooser();
    fc.setTitle("Save map file");
    fc.setInitialDirectory(dataDir);
    fc.getExtensionFilters().addAll(new ExtensionFilter("Map Files", "*.map"));
    File r = fc.showSaveDialog(window);
    if (r != null) {
        // automatically append .map if the user didn't give an extension
        final String name = r.getName();
        if (name.lastIndexOf('.') == -1) {
            final File p = r.getAbsoluteFile().getParentFile();
            r = new File(p, name + ".map");
        }
        stageFile = r;
        String n = r.getName();
        getStage().name = n.substring(0, n.lastIndexOf('.'));
        saveStage(dataDir);
    }
}
项目:maptranslator    文件:TranslateWindow.java   
private void exportData(Map<String, String> data) {
    FileChooser chooser = new FileChooser();
    chooser.setTitle(translate("translate.export"));
    chooser.setSelectedExtensionFilter(new ExtensionFilter("*.json", "*.json"));
    File target = chooser.showSaveDialog(stage);
    if (target == null) return;
    progressWindow().show(false);
    CompletableFuture
            .runAsync(() -> {
                JSONObject json = new JSONObject(data);
                try (Writer writer = new OutputStreamWriter(new FileOutputStream(target), "UTF-8")) {
                    writer.write(json.toString());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            })
            .handleAsync((result, err) -> {
                progressWindow().hide();
                if (err == null) {
                    lastStoredData = new HashMap<>(data);
                } else {
                    reportException(err);
                }
                return null;
            }, Platform::runLater);
}
项目:examples-javafx-repos1    文件:PreferencesController.java   
@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) );
    }
}
项目:markdown-writer-fx    文件:FileEditorTabPane.java   
private FileChooser createFileChooser(String title) {
    String[] extensions = Options.getMarkdownFileExtensions().trim().split("\\s*,\\s*");

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle(title);
    fileChooser.getExtensionFilters().addAll(
        new ExtensionFilter(Messages.get("FileEditorTabPane.chooser.markdownFilesFilter"), extensions),
        new ExtensionFilter(Messages.get("FileEditorTabPane.chooser.allFilesFilter"), "*.*"));

    String lastDirectory = MarkdownWriterFXApp.getState().get("lastDirectory", null);
    File file = new File((lastDirectory != null) ? lastDirectory : ".");
    if (!file.isDirectory())
        file = new File(".");
    fileChooser.setInitialDirectory(file);
    return fileChooser;
}