mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e216b4792 | |||
| 3980e2951f | |||
| 1b39c9a08e | |||
| 0db16c0328 | |||
| bec55b6119 | |||
| 7dac3ce011 | |||
| 449f929f08 | |||
| 9e3561fedb |
@@ -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)
|
[Wiki & Documentation](https://github.com/frosch95/SmartCSV.fx/wiki)
|
||||||
|
|
||||||
binary distribution of the [latest release (1.1.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.1.0/SmartCSV.fx-1.0.1.zip)
|
binary distribution of the [latest release (1.4.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.4.0/SmartCSV.fx-1.4.0.zip)
|
||||||
|
|
||||||
## Talks
|
## Talks
|
||||||
[Introduction](http://javafx.ninja/talks/introduction/)
|
[Introduction](http://javafx.ninja/talks/introduction/)
|
||||||
|
|||||||
@@ -48,5 +48,5 @@ test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'ninja.javafx'
|
group 'ninja.javafx'
|
||||||
version '1.1.0'
|
version '1.4.0'
|
||||||
mainClassName = 'ninja.javafx.smartcsv.Main'
|
mainClassName = 'ninja.javafx.smartcsv.Main'
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ import javafx.event.EventHandler;
|
|||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.scene.Node;
|
import javafx.scene.Node;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
|
import javafx.scene.input.Dragboard;
|
||||||
|
import javafx.scene.input.TransferMode;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
import javafx.scene.layout.BorderPane;
|
import javafx.scene.layout.BorderPane;
|
||||||
import javafx.stage.FileChooser;
|
import javafx.stage.FileChooser;
|
||||||
@@ -255,6 +257,34 @@ public class SmartCSVController extends FXMLController {
|
|||||||
fileEncodingFile.setFile(ENCODING_FILE);
|
fileEncodingFile.setFile(ENCODING_FILE);
|
||||||
|
|
||||||
loadCsvPreferencesFromFile();
|
loadCsvPreferencesFromFile();
|
||||||
|
|
||||||
|
initDragAndDrop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initDragAndDrop() {
|
||||||
|
tableWrapper.setOnDragOver(event -> {
|
||||||
|
Dragboard db = event.getDragboard();
|
||||||
|
if (event.getGestureSource() != tableWrapper
|
||||||
|
&& db.hasFiles()
|
||||||
|
&& db.getFiles().size() == 1
|
||||||
|
&& db.getFiles().get(0).getName().endsWith(".csv")) {
|
||||||
|
event.acceptTransferModes(TransferMode.COPY);
|
||||||
|
}
|
||||||
|
event.consume();
|
||||||
|
});
|
||||||
|
|
||||||
|
tableWrapper.setOnDragDropped(event -> {
|
||||||
|
Dragboard db = event.getDragboard();
|
||||||
|
boolean success = false;
|
||||||
|
if (db.hasFiles() && db.getFiles().size() == 1 && canOpen()) {
|
||||||
|
File file = db.getFiles().get(0);
|
||||||
|
openFile(currentCsvFile, file);
|
||||||
|
success = true;
|
||||||
|
}
|
||||||
|
/* let the source know whether the string was successfully
|
||||||
|
* transferred and used */
|
||||||
|
event.setDropCompleted(success);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadEncodingFromFile() {
|
private void loadEncodingFromFile() {
|
||||||
@@ -473,6 +503,22 @@ public class SmartCSVController extends FXMLController {
|
|||||||
return 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<ButtonType> result = alert.showAndWait();
|
||||||
|
if (result.get() != ButtonType.OK){
|
||||||
|
canOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return canOpen;
|
||||||
|
}
|
||||||
|
|
||||||
public void showValidationEditor(String column) {
|
public void showValidationEditor(String column) {
|
||||||
validationEditorController.setSelectedColumn(column);
|
validationEditorController.setSelectedColumn(column);
|
||||||
validationEditorController.updateForm();
|
validationEditorController.updateForm();
|
||||||
@@ -599,6 +645,10 @@ public class SmartCSVController extends FXMLController {
|
|||||||
|
|
||||||
//Show open file dialog
|
//Show open file dialog
|
||||||
File file = fileChooser.showOpenDialog(applicationPane.getScene().getWindow());
|
File file = fileChooser.showOpenDialog(applicationPane.getScene().getWindow());
|
||||||
|
openFile(storageFile, file);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void openFile(FileStorage storageFile, File file) {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
File previousFile = storageFile.getFile();
|
File previousFile = storageFile.getFile();
|
||||||
storageFile.setFile(file);
|
storageFile.setFile(file);
|
||||||
|
|||||||
@@ -65,8 +65,8 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void cancelEdit() {
|
public void cancelEdit() {
|
||||||
super.cancelEdit();
|
|
||||||
setText(getItem().getValue());
|
setText(getItem().getValue());
|
||||||
|
super.cancelEdit();
|
||||||
setContentDisplay(ContentDisplay.TEXT_ONLY);
|
setContentDisplay(ContentDisplay.TEXT_ONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -113,16 +113,11 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
|
|||||||
textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
|
textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
|
||||||
textField.setOnKeyPressed(t -> {
|
textField.setOnKeyPressed(t -> {
|
||||||
if (t.getCode() == KeyCode.ENTER) {
|
if (t.getCode() == KeyCode.ENTER) {
|
||||||
commitEdit(textField.getValue());
|
runLater(() -> commitEdit(textField.getValue()));
|
||||||
} else if (t.getCode() == KeyCode.ESCAPE) {
|
} else if (t.getCode() == KeyCode.ESCAPE) {
|
||||||
cancelEdit();
|
cancelEdit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
textField.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
|
||||||
if (!newValue && textField != null) {
|
|
||||||
commitEdit(textField.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ValueTextField extends TextField {
|
private static class ValueTextField extends TextField {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
application.name = SmartCSV.fx
|
application.name = SmartCSV.fx
|
||||||
application.version = 1.0.0
|
application.version = 1.4.0
|
||||||
|
|
||||||
# fxml views
|
# fxml views
|
||||||
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml
|
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml
|
||||||
|
|||||||
@@ -29,6 +29,10 @@ dialog.exit.title = Close Application
|
|||||||
dialog.exit.header.text = Do you want to 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.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.title = Preferences
|
||||||
dialog.preferences.header.text = Preferences
|
dialog.preferences.header.text = Preferences
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,10 @@ dialog.exit.title = Anwendung beenden
|
|||||||
dialog.exit.header.text = M\u00f6chten Sie wirklich die 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.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.quoteChar = Einfassungszeichen:
|
||||||
preferences.delimiterChar = Trennzeichen:
|
preferences.delimiterChar = Trennzeichen:
|
||||||
preferences.ignoreEmptyLines = Leere Zeilen ignorieren:
|
preferences.ignoreEmptyLines = Leere Zeilen ignorieren:
|
||||||
|
|||||||
Reference in New Issue
Block a user