diff --git a/README.md b/README.md index 680b371..ddca580 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ even in a "normal" CSV editor. So I decided to write this simple JavaFX applicat [Wiki & Documentation](https://github.com/frosch95/SmartCSV.fx/wiki) -binary distribution of the [latest release (1.2.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.2.0/SmartCSV.fx-1.2.0.zip) +binary distribution of the [latest release (1.3.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.3.0/SmartCSV.fx-1.3.0.zip) ## Talks [Introduction](http://javafx.ninja/talks/introduction/) diff --git a/build.gradle b/build.gradle index bce54df..262fbdf 100644 --- a/build.gradle +++ b/build.gradle @@ -48,5 +48,5 @@ test { } group 'ninja.javafx' -version '1.2.0' +version '1.3.0' mainClassName = 'ninja.javafx.smartcsv.Main' diff --git a/src/main/java/ninja/javafx/smartcsv/fx/SmartCSVController.java b/src/main/java/ninja/javafx/smartcsv/fx/SmartCSVController.java index ae0f2c1..c6e4ce2 100644 --- a/src/main/java/ninja/javafx/smartcsv/fx/SmartCSVController.java +++ b/src/main/java/ninja/javafx/smartcsv/fx/SmartCSVController.java @@ -276,7 +276,7 @@ private void initDragAndDrop() { tableWrapper.setOnDragDropped(event -> { Dragboard db = event.getDragboard(); boolean success = false; - if (db.hasFiles() && db.getFiles().size() == 1) { + if (db.hasFiles() && db.getFiles().size() == 1 && canOpen()) { File file = db.getFiles().get(0); openFile(currentCsvFile, file); success = true; @@ -503,6 +503,22 @@ public boolean canExit() { return canExit; } + private boolean canOpen() { + boolean canOpen = true; + if (currentCsvFile.getContent() != null && currentCsvFile.isFileChanged()) { + Alert alert = new Alert(Alert.AlertType.CONFIRMATION); + alert.setTitle(resourceBundle.getString("dialog.changes.title")); + alert.setHeaderText(resourceBundle.getString("dialog.changes.header.text")); + alert.setContentText(resourceBundle.getString("dialog.changes.text")); + + Optional result = alert.showAndWait(); + if (result.get() != ButtonType.OK){ + canOpen = false; + } + } + return canOpen; + } + public void showValidationEditor(String column) { validationEditorController.setSelectedColumn(column); validationEditorController.updateForm(); diff --git a/src/main/resources/ninja/javafx/smartcsv/fx/application.properties b/src/main/resources/ninja/javafx/smartcsv/fx/application.properties index 2f533ec..6e24aed 100644 --- a/src/main/resources/ninja/javafx/smartcsv/fx/application.properties +++ b/src/main/resources/ninja/javafx/smartcsv/fx/application.properties @@ -1,5 +1,5 @@ application.name = SmartCSV.fx -application.version = 1.2.0 +application.version = 1.3.0 # fxml views fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml diff --git a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties index 4e12b63..aff7970 100644 --- a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties +++ b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv.properties @@ -29,6 +29,10 @@ dialog.exit.title = Close Application dialog.exit.header.text = Do you want to close application? dialog.exit.text = There are changes made to the csv file. If you close now, the changes are lost! +dialog.changes.title = Discard changes +dialog.changes.header.text = Do you want to discard changes? +dialog.changes.text = There are changes made to the csv file. If you open a new file, the changes are lost! + dialog.preferences.title = Preferences dialog.preferences.header.text = Preferences diff --git a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties index dbcc0bc..7a1bc0b 100644 --- a/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties +++ b/src/main/resources/ninja/javafx/smartcsv/fx/smartcsv_de.properties @@ -45,6 +45,10 @@ dialog.exit.title = Anwendung beenden dialog.exit.header.text = M\u00f6chten Sie wirklich die Anwendung beenden? dialog.exit.text = Es gibt noch ungespeicherte \u00c4nderungen, die verloren gehen, wenn Sie die Anwendung jetzt beenden. +dialog.changes.title = Änderungen verwerfen +dialog.changes.header.text = Wollen Sie Ihre Änderungen verwerfen? +dialog.changes.text = Es gibt noch ungespeicherte \u00c4nderungen, die verloren gehen, wenn Sie die Datei laden. + preferences.quoteChar = Einfassungszeichen: preferences.delimiterChar = Trennzeichen: preferences.ignoreEmptyLines = Leere Zeilen ignorieren: