Search in sources :

Example 6 with DirectoryChooser

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

the class NetworkCreationTool method createNetwork.

/**
	 * This method, when called, will bring the user through a series of menus helping them
	 * configure the Network they wish to set up.
	 * @return whether or not the network was successfully created.
	 */
public boolean createNetwork() {
    File[] fractals = new File(Constants.FRACTAL_FILEPATH).listFiles();
    List<String> choices = new ArrayList<>();
    for (File f : fractals) {
        if (!f.getName().equals("palettes"))
            choices.add(f.getName());
    }
    ChoiceDialog<String> dialog1 = null;
    try {
        dialog1 = new ChoiceDialog<>(choices.get(0), choices);
    } catch (IndexOutOfBoundsException e) {
        AlertMenu alarm = new AlertMenu("Cannot create network: no fractal found on this computer.", "Fractals are searched for in the fractals folder. Please save a fractal to that folder and try again.");
    }
    dialog1.setTitle("Create Network");
    dialog1.setHeaderText("Step 1");
    dialog1.setContentText("Choose a fractal:");
    System.out.println("here...");
    RenderManager fractal = null;
    try {
        fractal = new RenderManager(dialog1.showAndWait().get());
    } catch (Exception e) {
        return false;
    }
    Pair<Integer, Integer> dimension = displayDialog2();
    if (dimension == null)
        return false;
    fractal.setScreenResolution(new Dimension(dimension.getKey(), dimension.getValue()));
    Pair<Double, Double> params = getParams();
    if (params == null)
        return false;
    if (params.getKey() == null)
        return false;
    if (params.getValue() == null)
        return false;
    fractal.setZoom(params.getKey());
    Alert alert = new Alert(AlertType.CONFIRMATION);
    alert.setTitle("Create Network");
    alert.setHeaderText("Step 4");
    alert.setContentText("Choose a directory:");
    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) {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        File selectedDirectory = directoryChooser.showDialog(null);
        if (selectedDirectory == null) {
            return false;
        } else {
            directory = selectedDirectory.getPath();
        }
    } else {
        return false;
    }
    this.server = new Server(fractal, params.getValue(), directory);
    return true;
}
Also used : Server(server.Server) ArrayList(java.util.ArrayList) Dimension(java.awt.Dimension) Alert(javafx.scene.control.Alert) File(java.io.File) RenderManager(fractal.RenderManager) ButtonType(javafx.scene.control.ButtonType) DirectoryChooser(javafx.stage.DirectoryChooser)

Example 7 with DirectoryChooser

use of javafx.stage.DirectoryChooser in project jabref by JabRef.

the class FXDialogService method showDirectorySelectionDialog.

@Override
public Optional<Path> showDirectorySelectionDialog(DirectoryDialogConfiguration directoryDialogConfiguration) {
    DirectoryChooser chooser = getConfiguredDirectoryChooser(directoryDialogConfiguration);
    File file = chooser.showDialog(null);
    return Optional.ofNullable(file).map(File::toPath);
}
Also used : File(java.io.File) DirectoryChooser(javafx.stage.DirectoryChooser)

Example 8 with DirectoryChooser

use of javafx.stage.DirectoryChooser in project Gargoyle by callakrsos.

the class DialogUtil method showDirectoryDialog.

/**
	 *
	 *
	 * 디렉토리 선택 다이얼로그 오픈
	 *
	 * @Date 2015. 10. 12.
	 * @param ownerWindow
	 * @param option
	 * @return
	 * @User KYJ
	 */
public static File showDirectoryDialog(final Window ownerWindow, Consumer<DirectoryChooser> option) {
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Open Resource Directory");
    installDefaultPath(chooser);
    if (option != null)
        option.accept(chooser);
    File showDialog = chooser.showDialog(ownerWindow);
    applyLastPath(showDialog);
    return showDialog;
}
Also used : File(java.io.File) DirectoryChooser(javafx.stage.DirectoryChooser)

Example 9 with DirectoryChooser

use of javafx.stage.DirectoryChooser in project bitsquare by bitsquare.

the class BackupView method activate.

@Override
protected void activate() {
    selectBackupDir.setOnAction(e -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setInitialDirectory(new File(preferences.getDefaultPath()));
        directoryChooser.setTitle("Select backup location");
        File dir = directoryChooser.showDialog(stage);
        if (dir != null) {
            String backupDirectory = dir.getAbsolutePath();
            preferences.setDefaultPath(backupDirectory);
            backUpLocationTextField.setText(backupDirectory);
            preferences.setBackupDirectory(backupDirectory);
            backupNow.setDisable(false);
            backupNow.setDefaultButton(true);
            selectBackupDir.setDefaultButton(false);
        }
    });
    openDataDir.setOnAction(e -> {
        try {
            Utilities.openDirectory(dataDir);
        } catch (IOException e1) {
            log.error(e1.getMessage());
            new Popup().warning("Cannot open directory.\nError =" + e1.getMessage()).show();
        }
    });
    backupNow.setOnAction(e -> {
        String backupDirectory = preferences.getBackupDirectory();
        if (backupDirectory.length() > 0) {
            try {
                String dateString = new SimpleDateFormat("YYYY-MM-dd-HHmmss").format(new Date());
                String destination = Paths.get(backupDirectory, "bitsquare_backup_" + dateString).toString();
                FileUtils.copyDirectory(dataDir, new File(destination));
                new Popup().feedback("Backup successfully saved at:\n" + destination).show();
            } catch (IOException e1) {
                e1.printStackTrace();
                log.error(e1.getMessage());
                new Popup().error("Backup could not be saved.\nError message: " + e1.getMessage()).show();
            }
        }
    });
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) IOException(java.io.IOException) File(java.io.File) SimpleDateFormat(java.text.SimpleDateFormat) DirectoryChooser(javafx.stage.DirectoryChooser) Date(java.util.Date)

Example 10 with DirectoryChooser

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

the class DirectoryChooserControl method bindProperties.

@Override
protected void bindProperties() {
    label.setMinWidth(MIN_WIDTH_LEFT);
    textField.textProperty().bindBidirectional(value);
    label.textProperty().bindBidirectional(this.labelTextProperty);
    button.setText(Constants.getI18nStr("controls.chooseDir"));
    button.setOnMouseClicked((event -> {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        File selectedFolder = directoryChooser.showDialog(BaseController.primaryStage);
        if (selectedFolder != null) {
            value.setValue(selectedFolder.getAbsolutePath());
        }
    }));
}
Also used : Button(javafx.scene.control.Button) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) BaseController(com.spawpaw.mybatis.generator.gui.controller.BaseController) File(java.io.File) Constants(com.spawpaw.mybatis.generator.gui.util.Constants) DirectoryChooser(javafx.stage.DirectoryChooser) File(java.io.File) DirectoryChooser(javafx.stage.DirectoryChooser)

Aggregations

DirectoryChooser (javafx.stage.DirectoryChooser)16 File (java.io.File)8 FXML (javafx.fxml.FXML)6 CodeGenFile (ilargia.entitas.codeGeneration.data.CodeGenFile)4 BaseController (com.spawpaw.mybatis.generator.gui.controller.BaseController)1 Constants (com.spawpaw.mybatis.generator.gui.util.Constants)1 RenderManager (fractal.RenderManager)1 Popup (io.bitsquare.gui.main.overlays.popups.Popup)1 Dimension (java.awt.Dimension)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 CancellationException (java.util.concurrent.CancellationException)1 Platform (javafx.application.Platform)1 Alert (javafx.scene.control.Alert)1 Button (javafx.scene.control.Button)1 ButtonType (javafx.scene.control.ButtonType)1 Label (javafx.scene.control.Label)1