Search in sources :

Example 46 with FileChooser

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();
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) FileChooser(javafx.stage.FileChooser) IOException(java.io.IOException) ObjectOutputStream(java.io.ObjectOutputStream) File(java.io.File)

Example 47 with FileChooser

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;
}
Also used : FileChooser(javafx.stage.FileChooser) Alert(javafx.scene.control.Alert) ButtonType(javafx.scene.control.ButtonType) File(java.io.File)

Example 48 with FileChooser

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);
}
Also used : FileChooser(javafx.stage.FileChooser) File(java.io.File)

Example 49 with FileChooser

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());
}
Also used : HOGMPerspective(com.sri.ai.praise.sgsolver.demo.perspective.HOGMPerspective) FileChooser(javafx.stage.FileChooser) FXML(javafx.fxml.FXML)

Example 50 with FileChooser

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);
}
Also used : FileChooser(javafx.stage.FileChooser) File(java.io.File)

Aggregations

FileChooser (javafx.stage.FileChooser)65 File (java.io.File)60 Preferences (java.util.prefs.Preferences)21 IOException (java.io.IOException)17 ResourceBundle (java.util.ResourceBundle)11 FXML (javafx.fxml.FXML)11 FileOutputStream (java.io.FileOutputStream)5 ArrayList (java.util.ArrayList)5 Alert (javafx.scene.control.Alert)5 Button (javafx.scene.control.Button)5 Popup (io.bitsquare.gui.main.overlays.popups.Popup)3 List (java.util.List)3 GargoyleFileAlreadyExistException (com.kyj.fx.voeditor.visual.exceptions.GargoyleFileAlreadyExistException)2 Palette (fractal.Palette)2 Path (java.nio.file.Path)2 ObservableList (javafx.collections.ObservableList)2 FilteredList (javafx.collections.transformation.FilteredList)2 SortedList (javafx.collections.transformation.SortedList)2 Task (javafx.concurrent.Task)2 Insets (javafx.geometry.Insets)2