Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 24 additions & 31 deletions code/src/java/pcgen/gui3/dialog/OptionsPathDialogController.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -56,9 +54,6 @@ public class OptionsPathDialogController
@FXML
private ToggleGroup directoryGroup;

@FXML
private ButtonBar ok;

@FXML
private RadioButton select;

Expand All @@ -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)
{
Expand All @@ -98,7 +90,7 @@ void initialize()
}

@FXML
private void onConfirm(final ActionEvent actionEvent)
private void onConfirm()
{
ConfigurationSettings.setSystemProperty(
ConfigurationSettings.SETTINGS_FILES_PATH,
Expand All @@ -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();
Expand All @@ -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> 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> buttonType = alert.showAndWait();
buttonType.ifPresent(option -> {
if (option != ButtonType.YES)
{
return;
}
});
return;
}
model.directoryProperty().setValue(dir.getAbsolutePath());
}
model.directoryProperty().setValue(dir.getAbsolutePath());
}
}
Loading