diff --git a/code/src/java/pcgen/gui3/dialog/OptionsPathDialogController.java b/code/src/java/pcgen/gui3/dialog/OptionsPathDialogController.java index a26bd3770ce..9fa4c4401fc 100644 --- a/code/src/java/pcgen/gui3/dialog/OptionsPathDialogController.java +++ b/code/src/java/pcgen/gui3/dialog/OptionsPathDialogController.java @@ -24,12 +24,10 @@ import pcgen.system.ConfigurationSettings; import pcgen.util.Logging; -import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Button; -import javafx.scene.control.ButtonBar; import javafx.scene.control.ButtonType; import javafx.scene.control.RadioButton; import javafx.scene.control.TextField; @@ -56,9 +54,6 @@ public class OptionsPathDialogController @FXML private ToggleGroup directoryGroup; - @FXML - private ButtonBar ok; - @FXML private RadioButton select; @@ -70,22 +65,19 @@ void initialize() { model.directoryProperty().bindBidirectional(dirSelection.textProperty()); select.selectedProperty().addListener(( - (observable, oldValue, newValue) -> { + (_, _, _) -> { dirSelection.setDisable(!select.isSelected()); dirSelection.setEditable(select.isSelected()); selectButton.setDisable(!select.isSelected()); })); - if (!SystemUtils.IS_OS_MAC_OSX) - { - macUserDir.setVisible(false); - } - if (!SystemUtils.IS_OS_UNIX) - { - freedesktop.setVisible(false); - } + // macUserDir - macOS, freedesktop - Unix. setManaged mirrors setVisible to avoid an empty gap. + macUserDir.setVisible(SystemUtils.IS_OS_MAC_OSX); + macUserDir.setManaged(SystemUtils.IS_OS_MAC_OSX); + freedesktop.setVisible(SystemUtils.IS_OS_UNIX); + freedesktop.setManaged(SystemUtils.IS_OS_UNIX); - directoryGroup.selectedToggleProperty().addListener((observable, oldValue, newValue) -> { + directoryGroup.selectedToggleProperty().addListener((observable, _, newValue) -> { Logging.debugPrint("toggle changed " + observable); if (newValue.getUserData() != null) { @@ -98,7 +90,7 @@ void initialize() } @FXML - private void onConfirm(final ActionEvent actionEvent) + private void onConfirm() { ConfigurationSettings.setSystemProperty( ConfigurationSettings.SETTINGS_FILES_PATH, @@ -108,7 +100,7 @@ private void onConfirm(final ActionEvent actionEvent) } @FXML - private void doChooser(final ActionEvent actionEvent) + private void doChooser() { DirectoryChooser directoryChooser = new DirectoryChooser(); String modelDirectory = model.directoryProperty().getValue(); @@ -119,23 +111,24 @@ private void doChooser(final ActionEvent actionEvent) File dir = directoryChooser.showDialog(optionsPathDialogScene.getWindow()); - if (dir != null) + if (dir == null) + { + return; + } + + File[] contents = dir.listFiles(); + if (contents != null && contents.length > 0) { - if (dir.listFiles().length > 0) + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setTitle("Directory Not Empty"); + alert.setContentText("The folder " + dir.getAbsolutePath() + " is not empty.\n" + + "All ini files in this directory may be overwritten. " + "Are you sure?"); + Optional buttonType = alert.showAndWait(); + if (buttonType.filter(type -> type == ButtonType.OK).isEmpty()) { - Alert alert = new Alert(Alert.AlertType.CONFIRMATION); - alert.setTitle("Directory Not Empty"); - alert.setContentText("The folder " + dir.getAbsolutePath() + " is not empty.\n" - + "All ini files in this directory may be overwritten. " + "Are you sure?"); - Optional buttonType = alert.showAndWait(); - buttonType.ifPresent(option -> { - if (option != ButtonType.YES) - { - return; - } - }); + return; } - model.directoryProperty().setValue(dir.getAbsolutePath()); } + model.directoryProperty().setValue(dir.getAbsolutePath()); } }