4 Commits
1.3.0 ... 1.5.0

Author SHA1 Message Date
18335b9280 Update dependencies and Gradle wrapper; bump JavaFX to 25 and Groovy to 5.0.2 2025-10-20 21:16:21 +02:00
4e216b4792 Merge pull request #32 from frosch95/fix_enter_bug
When pressing enter leave the editing mode
2022-10-22 21:27:37 +02:00
3980e2951f Version 1.4.0 2022-10-22 21:23:40 +02:00
1b39c9a08e When pressing enter leave the editing mode and commit the new value.
Also reset the value when cancel the edit mode.
2022-10-22 21:21:54 +02:00
7 changed files with 58 additions and 45 deletions

View File

@@ -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.3.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.3.0/SmartCSV.fx-1.3.0.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/)

View File

@@ -3,43 +3,50 @@ plugins {
id 'java' id 'java'
id 'groovy' id 'groovy'
id 'application' id 'application'
id 'org.openjfx.javafxplugin' version '0.0.10' id 'org.openjfx.javafxplugin' version '0.0.14'
id 'com.github.ben-manes.versions' version '0.48.0'
} }
repositories { repositories {
mavenCentral() mavenCentral()
jcenter()
} }
apply plugin: 'java' apply plugin: 'java'
sourceCompatibility = 17
targetCompatibility = 17 java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
javafx { javafx {
version = "17" version = "25"
modules = [ 'javafx.controls', 'javafx.fxml' ] modules = [ 'javafx.controls', 'javafx.fxml' ]
} }
dependencies { dependencies {
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api // updated testing libraries
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2' testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '6.0.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '6.0.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.2' testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '6.0.0'
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.2' testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '6.0.0'
testImplementation group: 'org.mockito', name: 'mockito-core', version:'3.1.0' testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '3.0'
implementation group: 'org.apache.groovy', name: 'groovy', version: '4.0.0-rc-1' testImplementation group: 'org.mockito', name: 'mockito-core', version:'5.20.0'
implementation group: 'org.springframework', name:'spring-context', version: '5.3.13'
implementation group: 'de.siegmar', name: 'fastcsv', version: '2.1.0' // runtime libraries - bumped to recent stable versions where compatible
implementation group: 'commons-validator', name: 'commons-validator', version: '1.7' implementation group: 'org.apache.groovy', name: 'groovy', version: '5.0.2'
implementation group: 'de.jensd', name: 'fontawesomefx-commons', version: '11.0' implementation group: 'org.springframework', name: 'spring-context', version: '6.2.12'
implementation group: 'de.jensd', name: 'fontawesomefx-fontawesome', version: '4.7.0-11' implementation group: 'de.siegmar', name: 'fastcsv', version: '4.1.0'
implementation group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '1.7.22-11' implementation group: 'commons-validator', name: 'commons-validator', version: '1.10.0'
implementation group: 'de.jensd', name: 'fontawesomefx-materialicons', version: '2.2.0-11' implementation group: 'de.jensd', name: 'fontawesomefx-commons', version: '9.1.2'
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.1.0' implementation group: 'de.jensd', name: 'fontawesomefx-fontawesome', version: '4.7.0-9.1.2'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9' implementation group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '2.0.26-9.1.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1' implementation group: 'de.jensd', name: 'fontawesomefx-materialicons', version: '2.2.0-9.1.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1' implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.2.2'
implementation group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.7' implementation group: 'com.google.code.gson', name: 'gson', version: '2.13.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.25.2'
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.25.2'
implementation group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.11.6'
} }
@@ -48,5 +55,9 @@ test {
} }
group 'ninja.javafx' group 'ninja.javafx'
version '1.3.0' version '1.5.0'
mainClassName = 'ninja.javafx.smartcsv.Main'
application {
mainClass = 'ninja.javafx.smartcsv.Main'
applicationDefaultJvmArgs = ["--enable-native-access=javafx.graphics"]
}

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@@ -26,7 +26,8 @@
package ninja.javafx.smartcsv.csv; package ninja.javafx.smartcsv.csv;
import de.siegmar.fastcsv.reader.NamedCsvReader; import de.siegmar.fastcsv.reader.CsvReader;
import de.siegmar.fastcsv.reader.NamedCsvRecord;
import ninja.javafx.smartcsv.FileReader; import ninja.javafx.smartcsv.FileReader;
import ninja.javafx.smartcsv.fx.table.model.CSVModel; import ninja.javafx.smartcsv.fx.table.model.CSVModel;
@@ -49,7 +50,13 @@ public class CSVFileReader extends CSVConfigurable implements FileReader<CSVMode
model = new CSVModel(); model = new CSVModel();
// the header columns are used as the keys to the Map // the header columns are used as the keys to the Map
var header = csv.getHeader().toArray(new String[csv.getHeader().size()]); var firstRow = csv.stream().findFirst();
if (firstRow.isEmpty()) {
return;
}
var header = firstRow.get().getHeader().toArray(String[]::new);
model.setHeader(header); model.setHeader(header);
csv.forEach(csvRow -> { csv.forEach(csvRow -> {
@@ -66,14 +73,14 @@ public class CSVFileReader extends CSVConfigurable implements FileReader<CSVMode
} }
} }
private NamedCsvReader getNamedCsvReader(File file) throws IOException { private CsvReader<NamedCsvRecord> getNamedCsvReader(File file) throws IOException {
var builder = NamedCsvReader.builder() var builder = CsvReader.builder()
.fieldSeparator(csvPreference.delimiterChar()); .fieldSeparator(csvPreference.delimiterChar());
if (csvPreference.quoteChar() != null) { if (csvPreference.quoteChar() != null) {
builder.quoteCharacter(csvPreference.quoteChar()); builder.quoteCharacter(csvPreference.quoteChar());
} }
return builder.build(file.toPath(), Charset.forName(fileEncoding)); return builder.ofNamedCsvRecord(file.toPath(), Charset.forName(fileEncoding));
} }
public CSVModel getContent() { public CSVModel getContent() {

View File

@@ -27,7 +27,7 @@
package ninja.javafx.smartcsv.csv; package ninja.javafx.smartcsv.csv;
import de.siegmar.fastcsv.writer.CsvWriter; import de.siegmar.fastcsv.writer.CsvWriter;
import de.siegmar.fastcsv.writer.QuoteStrategy; import de.siegmar.fastcsv.writer.QuoteStrategies;
import ninja.javafx.smartcsv.fx.table.model.CSVModel; import ninja.javafx.smartcsv.fx.table.model.CSVModel;
import ninja.javafx.smartcsv.fx.table.model.CSVRow; import ninja.javafx.smartcsv.fx.table.model.CSVRow;
@@ -52,9 +52,9 @@ public class CSVFileWriter extends CSVConfigurable implements ninja.javafx.smart
@Override @Override
public void write(File filename) throws IOException { public void write(File filename) throws IOException {
try (var writer = getCsvWriter(filename)){ try (var writer = getCsvWriter(filename)){
writer.writeRow(model.getHeader()); writer.writeRecord(model.getHeader());
for(CSVRow row: model.getRows()) { for(CSVRow row: model.getRows()) {
writer.writeRow(convertMapFromModel(row)); writer.writeRecord(convertMapFromModel(row));
} }
} }
} }
@@ -63,7 +63,7 @@ public class CSVFileWriter extends CSVConfigurable implements ninja.javafx.smart
var writer = CsvWriter.builder().fieldSeparator(csvPreference.delimiterChar()); var writer = CsvWriter.builder().fieldSeparator(csvPreference.delimiterChar());
if (csvPreference.quoteChar() != null) { if (csvPreference.quoteChar() != null) {
writer.quoteCharacter(csvPreference.quoteChar()); writer.quoteCharacter(csvPreference.quoteChar());
writer.quoteStrategy(QuoteStrategy.ALWAYS); writer.quoteStrategy(QuoteStrategies.ALWAYS);
} }
return writer.build(filename.toPath(), Charset.forName(fileEncoding)); return writer.build(filename.toPath(), Charset.forName(fileEncoding));

View 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 {

View File

@@ -1,5 +1,5 @@
application.name = SmartCSV.fx application.name = SmartCSV.fx
application.version = 1.3.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