use of javafx.stage.FileChooser in project DistributedFractalNetwork by Budder21.
the class RenderManager method saveFractal.
/**
* Saves the fractal, its layers, and their palettes to the specified
* directory based on the fractal's name
*/
public void saveFractal() {
if (filePath == null) {
FileChooser chooser = new FileChooser();
chooser.setTitle("Save Fractal");
chooser.setInitialDirectory(new File("fractals"));
FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("Fractals (*.fractal)", "*.fractal");
chooser.getExtensionFilters().add(filter);
File f = chooser.showSaveDialog(null);
filePath = f.getAbsolutePath();
setName(f.getName().substring(0, f.getName().indexOf(".")));
}
try {
ObjectOutputStream objOut = new ObjectOutputStream(new FileOutputStream(new File(filePath)));
objOut.writeObject(this);
objOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
use of javafx.stage.FileChooser in project DistributedFractalNetwork by Budder21.
the class RegisterLayerTool method registerLayer.
/**
* This method takes the user through a series of menus that, at the end, will locate the file
* containing the data for the new layer type. It will then store that file internally for access later.
* @return true if the file was located, false if the user cancelled.
*/
public boolean registerLayer() {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle("Register Layer");
alert.setHeaderText(null);
alert.setContentText("Choose a file:");
ButtonType buttonTypeOne = new ButtonType("Choose");
ButtonType buttonTypeCancel = new ButtonType("Cancel", ButtonData.CANCEL_CLOSE);
alert.getButtonTypes().setAll(buttonTypeOne, buttonTypeCancel);
Optional<ButtonType> result = alert.showAndWait();
String directory = "";
if (result.get() == buttonTypeOne) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Choose Layer");
fileChooser.setInitialDirectory(new File(Constants.CUSTOM_FRACTAL_FILEPATH));
FileChooser.ExtensionFilter filter = new FileChooser.ExtensionFilter("Layers (*.java)", "*.java");
fileChooser.getExtensionFilters().add(filter);
File selectedFile = fileChooser.showOpenDialog(null);
if (selectedFile == null) {
return false;
} else {
file = selectedFile;
}
} else {
return false;
}
return true;
}
use of javafx.stage.FileChooser in project POL-POM-5 by PlayOnLinux.
the class LibrarySideBar method populateAdvancedTools.
/**
* This method populates the advanced tools button group.
*/
private void populateAdvancedTools() {
this.runScript = new LeftButton(tr("Run a script"));
this.runScript.getStyleClass().add("scriptButton");
this.runConsole = new LeftButton(tr("{0} console", applicationName));
this.runConsole.getStyleClass().add("consoleButton");
this.runScript.setOnMouseClicked(event -> {
final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle(tr("Open a script"));
final File scriptToRun = fileChooser.showOpenDialog(null);
if (scriptToRun != null) {
onScriptRun.accept(scriptToRun);
}
});
this.runConsole.setOnMouseClicked(event -> onOpenConsole.run());
this.advancedToolsGroup = new LeftGroup(tr("Advanced tools"), runScript, runConsole);
}
use of javafx.stage.FileChooser in project aic-praise by aic-sri-international.
the class SGSolverDemoController method initialize.
//
// PRIVATE
//
@FXML
private void initialize() throws IOException {
FXUtil.setDefaultButtonIcon(openMenuButton, FontAwesomeIcons.BARS);
//
FXUtil.setDefaultButtonIcon(newButton, FontAwesomeIcons.FILE_ALT);
FXUtil.setDefaultButtonIcon(openFileButton, FontAwesomeIcons.FOLDER_OPEN);
FXUtil.setDefaultButtonIcon(saveButton, FontAwesomeIcons.SAVE);
//
FXUtil.setDefaultButtonIcon(undoModelEditButton, FontAwesomeIcons.ROTATE_LEFT);
FXUtil.setDefaultButtonIcon(redoModelEditButton, FontAwesomeIcons.ROTATE_RIGHT);
//
FXUtil.setButtonStackedIcons(undoPagesChangeButton, FontAwesomeIcons.ROTATE_LEFT, FontAwesomeIcons.SQUARE_ALT);
FXUtil.setButtonStackedIcons(redoPagesChangeButton, FontAwesomeIcons.ROTATE_RIGHT, FontAwesomeIcons.SQUARE_ALT);
//
FXUtil.setPaginationButtonIcon(removePageButton, FontAwesomeIcons.MINUS);
FXUtil.setPaginationButtonIcon(previousPageButton, FontAwesomeIcons.CARET_LEFT);
FXUtil.setPaginationButtonIcon(nextPageButton, FontAwesomeIcons.CARET_RIGHT);
FXUtil.setPaginationButtonIcon(addPageButton, FontAwesomeIcons.PLUS);
//
FXUtil.setDefaultButtonIcon(configureButton, FontAwesomeIcons.WRENCH);
//
praiseFileChooser = new FileChooser();
praiseFileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Model Files", "*.praise"));
uaiFileChooser = new FileChooser();
uaiFileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("UAI Files", "*.uai"));
openMenuPopOver.setArrowLocation(ArrowLocation.LEFT_TOP);
openMenuPopOver.setAutoHide(true);
openMenuPopOver.setDetachedTitle("Menu");
openMenuPopOver.setContentNode(openMenuContent());
configureSettingsPopOver.setArrowLocation(ArrowLocation.RIGHT_TOP);
configureSettingsPopOver.setAutoHide(true);
configureSettingsPopOver.setDetachedTitle("Configure Settings");
configureSettingsPopOver.setContentNode(configureSettingsContent());
//
//
modelPagination.setPageFactory(this::createModelPage);
modelPagination.pageCountProperty().addListener((observable, oldValue, newValue) -> updatePaginationControls(modelPagination.getCurrentPageIndex(), newValue.intValue()));
modelPagination.currentPageIndexProperty().addListener((observable, oldValue, newValue) -> updatePaginationControls(newValue.intValue(), modelPagination.getPageCount()));
examplesComboBox.getSelectionModel().selectedIndexProperty().addListener(this::exampleSelectionChaned);
setPerspective(new HOGMPerspective());
}
use of javafx.stage.FileChooser in project jabref by JabRef.
the class FXDialogService method showFileOpenDialog.
@Override
public Optional<Path> showFileOpenDialog(FileDialogConfiguration fileDialogConfiguration) {
FileChooser chooser = getConfiguredFileChooser(fileDialogConfiguration);
File file = chooser.showOpenDialog(null);
return Optional.ofNullable(file).map(File::toPath);
}
Aggregations