Skip to content

Commit f5cb6b8

Browse files
ddamkeddamke
authored andcommitted
add confirmationDialog
1 parent 77aec2a commit f5cb6b8

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/main/java/de/doubleslash/keeptime/view/SettingsController.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import java.nio.file.Paths;
2424
import java.sql.SQLException;
2525

26+
import javafx.scene.control.*;
2627
import org.h2.tools.RunScript;
2728
import org.h2.tools.Script;
2829
import org.slf4j.Logger;
@@ -42,12 +43,7 @@
4243
import javafx.fxml.FXMLLoader;
4344
import javafx.scene.Parent;
4445
import javafx.scene.Scene;
45-
import javafx.scene.control.Alert;
4646
import javafx.scene.control.Alert.AlertType;
47-
import javafx.scene.control.Button;
48-
import javafx.scene.control.CheckBox;
49-
import javafx.scene.control.ColorPicker;
50-
import javafx.scene.control.Label;
5147
import javafx.scene.layout.AnchorPane;
5248
import javafx.scene.layout.Region;
5349
import javafx.scene.paint.Color;
@@ -244,6 +240,16 @@ private void initImportButton(){
244240
importButton.setOnAction(event ->{
245241

246242
try {
243+
Alert confirmationAlert = new Alert(AlertType.CONFIRMATION , "", ButtonType.YES, ButtonType.NO);
244+
confirmationAlert.setTitle("Import");
245+
confirmationAlert.setHeaderText("Do you want to Override current Data ?");
246+
confirmationAlert.showAndWait();
247+
248+
if(confirmationAlert.getResult()==ButtonType.NO){
249+
LOG.info("User canceled import");
250+
return;
251+
}
252+
247253
final FileChooser fileChooser = new FileChooser();
248254
fileChooser.setTitle("Open Exported SQl Script");
249255
File file = fileChooser.showOpenDialog(thisStage);
@@ -258,6 +264,11 @@ private void initImportButton(){
258264
final String password = applicationProperties.getSpringDataSourcePassword();
259265
RunScript.execute(url, username, password, file.toString(), Charset.defaultCharset(), true);
260266

267+
Alert informationDialog = new Alert(AlertType.INFORMATION);
268+
informationDialog.setTitle("Import done");
269+
informationDialog.setHeaderText("The data was imported.");
270+
informationDialog.setContentText("You have to RESTART KeepTime to see the changes");
271+
informationDialog.showAndWait();
261272

262273
} catch (SQLException e) {
263274
LOG.error("Could not import script file to db.", e);

0 commit comments

Comments
 (0)