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);
}
}
}
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);
}
}
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);
}
}
}
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("."));
}
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);
}
Aggregations