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