Search in sources :

Example 86 with FileChooser

use of javafx.stage.FileChooser in project DistributedFractalNetwork by Budder21.

the class RenderManager method saveFractalAs.

/**
 * used when the user wants to save the fractal with a different name, but
 * not change the name of the current instance.
 */
public void saveFractalAs() {
    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);
    try {
        ObjectOutputStream objOut = new ObjectOutputStream(new FileOutputStream(f));
        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 87 with FileChooser

use of javafx.stage.FileChooser in project aic-praise by aic-sri-international.

the class PRAiSEController 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("FactorNetwork 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.other.application.praise.app.perspective.HOGMPerspective) FileChooser(javafx.stage.FileChooser) FXML(javafx.fxml.FXML)

Example 88 with FileChooser

use of javafx.stage.FileChooser in project mybatis-generator-gui-extension by spawpaw.

the class FileChooserControl method bindProperties.

@Override
protected void bindProperties() {
    label.setMinWidth(MIN_WIDTH_LEFT);
    textField.textProperty().bindBidirectional(value);
    label.textProperty().bindBidirectional(this.labelTextProperty);
    button.setOnMouseClicked((event -> {
        FileChooser fileChooser = new FileChooser();
        File selectedFile = fileChooser.showOpenDialog(BaseController.primaryStage);
        if (selectedFile != null) {
            value.setValue(selectedFile.getAbsolutePath());
        }
    }));
}
Also used : Button(javafx.scene.control.Button) FileChooser(javafx.stage.FileChooser) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) BaseController(com.spawpaw.mybatis.generator.gui.controller.BaseController) File(java.io.File) FileChooser(javafx.stage.FileChooser) File(java.io.File)

Example 89 with FileChooser

use of javafx.stage.FileChooser in project SIMVA-SoS by SESoS.

the class ChartViewer method handleExportToPNG.

/**
 * A handler for the export to PNG option in the context menu.
 */
private void handleExportToPNG() {
    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Export to PNG");
    fileChooser.setSelectedExtensionFilter(new FileChooser.ExtensionFilter("Portable Network Graphics (PNG)", "png"));
    File file = fileChooser.showSaveDialog(this.getScene().getWindow());
    if (file != null) {
        try {
            ExportUtils.writeAsPNG(this.chart, (int) getWidth(), (int) getHeight(), file);
        } catch (IOException ex) {
        // FIXME: show a dialog with the error
        }
    }
}
Also used : FileChooser(javafx.stage.FileChooser) IOException(java.io.IOException) File(java.io.File)

Example 90 with FileChooser

use of javafx.stage.FileChooser in project BlocklyArduinoIDEPlugin by technologiescollege.

the class BlocklyArduinoServer method IDEsaveXML.

/**
 * This method is called from javascript. It lets the user select a location
 * where to save the blocks to and saves them.
 *
 * @param xml The xml structure of the created block program.
 */
public void IDEsaveXML(String xml) {
    // System.out.println("saving blocks");
    FileChooser fileChooser = new FileChooser();
    fileChooser.setInitialDirectory(new File(lastOpenedLocation));
    fileChooser.setTitle("Save");
    fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("Blockly@rduino", "*.B@"));
    File selectedFile = fileChooser.showSaveDialog(ownerWindow);
    if (selectedFile != null) {
        if (selectedFile.getName().matches("^.*\\.B@$")) {
        // filename is OK as-is
        } else {
            // append .B@ if "foo.jpg.xml" is OK
            selectedFile = new File(selectedFile.toString() + ".B@");
        }
        lastOpenedLocation = selectedFile.getParent();
        try {
            BufferedWriter bWriter = new BufferedWriter(new FileWriter(selectedFile));
            bWriter.write(xml);
            bWriter.flush();
            bWriter.close();
        } catch (IOException ex) {
            Logger.getLogger(BlocklyArduinoServer.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
Also used : FileWriter(java.io.FileWriter) FileChooser(javafx.stage.FileChooser) IOException(java.io.IOException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Aggregations

FileChooser (javafx.stage.FileChooser)208 File (java.io.File)189 IOException (java.io.IOException)55 FXML (javafx.fxml.FXML)49 Preferences (java.util.prefs.Preferences)24 Button (javafx.scene.control.Button)21 ArrayList (java.util.ArrayList)19 VBox (javafx.scene.layout.VBox)15 ResourceBundle (java.util.ResourceBundle)14 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)14 Stage (javafx.stage.Stage)14 Label (javafx.scene.control.Label)13 Alert (javafx.scene.control.Alert)12 List (java.util.List)11 TextField (javafx.scene.control.TextField)11 ScriptException (javax.script.ScriptException)11 Scene (javafx.scene.Scene)10 Map (java.util.Map)9 ObservableList (javafx.collections.ObservableList)9 MenuItem (javafx.scene.control.MenuItem)9