Search in sources :

Example 1 with FileChooser

use of javafx.stage.FileChooser in project cryptomator by cryptomator.

the class MainController method didClickAddExistingVaults.

@FXML
private void didClickAddExistingVaults(ActionEvent event) {
    final FileChooser fileChooser = new FileChooser();
    fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("Cryptomator Masterkey", "*.cryptomator"));
    final List<File> files = fileChooser.showOpenMultipleDialog(mainWindow);
    if (files != null) {
        for (final File file : files) {
            addVault(file.toPath(), false);
        }
    }
}
Also used : FileChooser(javafx.stage.FileChooser) File(java.io.File) FXML(javafx.fxml.FXML)

Example 2 with FileChooser

use of javafx.stage.FileChooser in project cryptomator by cryptomator.

the class MainController method didClickCreateNewVault.

@FXML
private void didClickCreateNewVault(ActionEvent event) {
    final FileChooser fileChooser = new FileChooser();
    final File file = fileChooser.showSaveDialog(mainWindow);
    if (file == null) {
        return;
    }
    try {
        final Path vaultDir = file.toPath();
        if (!Files.exists(vaultDir)) {
            Files.createDirectory(vaultDir);
        }
        addVault(vaultDir, true);
    } catch (IOException e) {
        LOG.error("Unable to create vault", e);
    }
}
Also used : Path(java.nio.file.Path) FileChooser(javafx.stage.FileChooser) IOException(java.io.IOException) File(java.io.File) FXML(javafx.fxml.FXML)

Example 3 with FileChooser

use of javafx.stage.FileChooser in project fxexperience2 by EricCanull.

the class StylerController method getSaveStyleSheet.

public void getSaveStyleSheet() {
    FileChooser fileChooser = new FileChooser();
    File file = fileChooser.showSaveDialog(sizeGridPanel.getScene().getWindow());
    if (file != null && !file.exists() && file.getParentFile().isDirectory()) {
        try (FileWriter writer = new FileWriter(file)) {
            writer.write(createCSS(true));
            writer.flush();
        } catch (IOException ex) {
            Logger.getLogger(StylerController.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : FileChooser(javafx.stage.FileChooser)

Example 4 with FileChooser

use of javafx.stage.FileChooser in project fxexperience2 by EricCanull.

the class FileUtils method configure.

/**
     * Define file extension filters to filtering supported image files, matching files whose
     * extensions are: *.css
     *
     * @param fileChooser
     */
public static void configure(FileChooser fileChooser) {
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("All CSS", "*.css"), new FileChooser.ExtensionFilter("All Files", "*.*"), new FileChooser.ExtensionFilter("CSS", "*.css"));
    // Set "." as default dir
    fileChooser.setInitialDirectory(new File("."));
}
Also used : FileChooser(javafx.stage.FileChooser) File(java.io.File)

Example 5 with FileChooser

use of javafx.stage.FileChooser in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerToolsTab method populate.

private void populate() {
    final VBox toolsPane = new VBox();
    final Text title = new TextWithStyle(tr("Tools"), TITLE_CSS_CLASS);
    toolsPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS);
    toolsPane.getChildren().add(title);
    final GridPane toolsContentPane = new GridPane();
    toolsContentPane.getStyleClass().add("grid");
    Button openTerminal = new Button(tr("Open a terminal"));
    openTerminal.getStyleClass().addAll("wineToolButton", "openTerminal");
    openTerminal.setOnMouseClicked(e -> {
        this.lockAll();
        winePrefixContainerController.openTerminalInPrefix(container);
        this.unlockAll();
    });
    GridPane.setHalignment(openTerminal, HPos.CENTER);
    this.lockableElements.add(openTerminal);
    toolsContentPane.add(openTerminal, 0, 0);
    toolsContentPane.add(wineToolCaption(tr("Open a terminal")), 0, 1);
    Button createShortcut = new Button();
    createShortcut.getStyleClass().addAll("wineToolButton", "openTerminal");
    createShortcut.setOnMouseClicked(event -> {
        this.lockAll();
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(tr("Choose executable"));
        File file = fileChooser.showOpenDialog(this.getContent().getScene().getWindow());
        if (file != null) {
            winePrefixContainerController.createShortcut(container, file.getName(), file.getName(), this::unlockAll, e -> Platform.runLater(() -> new ErrorMessage("Error", e).show()));
        }
        this.unlockAll();
    });
    GridPane.setHalignment(createShortcut, HPos.CENTER);
    this.lockableElements.add(createShortcut);
    toolsContentPane.add(createShortcut, 1, 0);
    toolsContentPane.add(wineToolCaption(tr("Create shortcut")), 1, 1);
    Button runExecutable = new Button();
    runExecutable.getStyleClass().addAll("wineToolButton", "runExecutable");
    runExecutable.setOnMouseClicked(event -> {
        this.lockAll();
        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle(tr("Choose executable"));
        File file = fileChooser.showOpenDialog(this.getContent().getScene().getWindow());
        if (file != null) {
            winePrefixContainerController.runInPrefix(container, file.getAbsolutePath(), this::unlockAll, e -> Platform.runLater(() -> new ErrorMessage("Error", e).show()));
        }
    });
    GridPane.setHalignment(runExecutable, HPos.CENTER);
    this.lockableElements.add(runExecutable);
    toolsContentPane.add(runExecutable, 2, 0);
    toolsContentPane.add(wineToolCaption(tr("Run executable")), 2, 1);
    toolsPane.getChildren().addAll(toolsContentPane);
    toolsContentPane.getColumnConstraints().addAll(new ColumnConstraintsWithPercentage(25), new ColumnConstraintsWithPercentage(25), new ColumnConstraintsWithPercentage(25), new ColumnConstraintsWithPercentage(25));
    this.setContent(toolsPane);
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) ColumnConstraintsWithPercentage(org.phoenicis.javafx.views.common.ColumnConstraintsWithPercentage) GridPane(javafx.scene.layout.GridPane) Button(javafx.scene.control.Button) FileChooser(javafx.stage.FileChooser) Text(javafx.scene.text.Text) ErrorMessage(org.phoenicis.javafx.views.common.ErrorMessage) VBox(javafx.scene.layout.VBox) File(java.io.File)

Aggregations

FileChooser (javafx.stage.FileChooser)194 File (java.io.File)176 IOException (java.io.IOException)51 FXML (javafx.fxml.FXML)43 Preferences (java.util.prefs.Preferences)24 ArrayList (java.util.ArrayList)19 Button (javafx.scene.control.Button)18 VBox (javafx.scene.layout.VBox)15 ResourceBundle (java.util.ResourceBundle)14 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)14 Stage (javafx.stage.Stage)13 Alert (javafx.scene.control.Alert)12 Label (javafx.scene.control.Label)12 List (java.util.List)11 ScriptException (javax.script.ScriptException)11 Scene (javafx.scene.Scene)10 TextField (javafx.scene.control.TextField)10 ObservableList (javafx.collections.ObservableList)9 MenuItem (javafx.scene.control.MenuItem)9 FileOutputStream (java.io.FileOutputStream)8