mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55ed382203 | |||
| 81d75a995b | |||
| f5ab096452 | |||
| 18335b9280 | |||
| 4e216b4792 | |||
| 3980e2951f | |||
| 1b39c9a08e |
4
.github/workflows/build-and-test.yml
vendored
4
.github/workflows/build-and-test.yml
vendored
@@ -9,10 +9,10 @@ jobs:
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 17
|
||||
- name: Set up JDK 25
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 17
|
||||
java-version: 25
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Build with Gradle
|
||||
|
||||
@@ -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.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.5.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.5.0/SmartCSV.fx-1.5.0.zip)
|
||||
|
||||
## Talks
|
||||
[Introduction](http://javafx.ninja/talks/introduction/)
|
||||
|
||||
63
build.gradle
63
build.gradle
@@ -3,43 +3,50 @@ plugins {
|
||||
id 'java'
|
||||
id 'groovy'
|
||||
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 {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
apply plugin: 'java'
|
||||
sourceCompatibility = 17
|
||||
targetCompatibility = 17
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(25)
|
||||
}
|
||||
}
|
||||
|
||||
javafx {
|
||||
version = "17"
|
||||
version = "25"
|
||||
modules = [ 'javafx.controls', 'javafx.fxml' ]
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api
|
||||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.8.2'
|
||||
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.8.2'
|
||||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.8.2'
|
||||
testImplementation group: 'org.hamcrest', name: 'hamcrest-library', version: '2.2'
|
||||
testImplementation group: 'org.mockito', name: 'mockito-core', version:'3.1.0'
|
||||
implementation group: 'org.apache.groovy', name: 'groovy', version: '4.0.0-rc-1'
|
||||
implementation group: 'org.springframework', name:'spring-context', version: '5.3.13'
|
||||
implementation group: 'de.siegmar', name: 'fastcsv', version: '2.1.0'
|
||||
implementation group: 'commons-validator', name: 'commons-validator', version: '1.7'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-commons', version: '11.0'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-fontawesome', version: '4.7.0-11'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '1.7.22-11'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-materialicons', version: '2.2.0-11'
|
||||
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.1.0'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.9'
|
||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1'
|
||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1'
|
||||
implementation group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.7'
|
||||
// updated testing libraries
|
||||
testImplementation group: 'org.junit.platform', name: 'junit-platform-launcher', version: '6.0.0'
|
||||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '6.0.0'
|
||||
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '6.0.0'
|
||||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '6.0.0'
|
||||
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '3.0'
|
||||
testImplementation group: 'org.mockito', name: 'mockito-core', version:'5.20.0'
|
||||
|
||||
// runtime libraries - bumped to recent stable versions where compatible
|
||||
implementation group: 'org.apache.groovy', name: 'groovy', version: '5.0.2'
|
||||
implementation group: 'org.springframework', name: 'spring-context', version: '6.2.12'
|
||||
implementation group: 'de.siegmar', name: 'fastcsv', version: '4.1.0'
|
||||
implementation group: 'commons-validator', name: 'commons-validator', version: '1.10.0'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-commons', version: '9.1.2'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-fontawesome', version: '4.7.0-9.1.2'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-materialdesignfont', version: '2.0.26-9.1.2'
|
||||
implementation group: 'de.jensd', name: 'fontawesomefx-materialicons', version: '2.2.0-9.1.2'
|
||||
implementation group: 'org.controlsfx', name: 'controlsfx', version: '11.2.2'
|
||||
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'
|
||||
version '1.3.0'
|
||||
mainClassName = 'ninja.javafx.smartcsv.Main'
|
||||
version '1.5.0'
|
||||
|
||||
application {
|
||||
mainClass = 'ninja.javafx.smartcsv.Main'
|
||||
applicationDefaultJvmArgs = ["--enable-native-access=javafx.graphics"]
|
||||
}
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
|
||||
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.fx.table.model.CSVModel;
|
||||
|
||||
@@ -49,7 +50,13 @@ public class CSVFileReader extends CSVConfigurable implements FileReader<CSVMode
|
||||
model = new CSVModel();
|
||||
|
||||
// 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);
|
||||
|
||||
csv.forEach(csvRow -> {
|
||||
@@ -66,14 +73,14 @@ public class CSVFileReader extends CSVConfigurable implements FileReader<CSVMode
|
||||
}
|
||||
}
|
||||
|
||||
private NamedCsvReader getNamedCsvReader(File file) throws IOException {
|
||||
var builder = NamedCsvReader.builder()
|
||||
private CsvReader<NamedCsvRecord> getNamedCsvReader(File file) throws IOException {
|
||||
var builder = CsvReader.builder()
|
||||
.fieldSeparator(csvPreference.delimiterChar());
|
||||
if (csvPreference.quoteChar() != null) {
|
||||
builder.quoteCharacter(csvPreference.quoteChar());
|
||||
}
|
||||
|
||||
return builder.build(file.toPath(), Charset.forName(fileEncoding));
|
||||
return builder.ofNamedCsvRecord(file.toPath(), Charset.forName(fileEncoding));
|
||||
}
|
||||
|
||||
public CSVModel getContent() {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
package ninja.javafx.smartcsv.csv;
|
||||
|
||||
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.CSVRow;
|
||||
|
||||
@@ -52,9 +52,9 @@ public class CSVFileWriter extends CSVConfigurable implements ninja.javafx.smart
|
||||
@Override
|
||||
public void write(File filename) throws IOException {
|
||||
try (var writer = getCsvWriter(filename)){
|
||||
writer.writeRow(model.getHeader());
|
||||
writer.writeRecord(model.getHeader());
|
||||
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());
|
||||
if (csvPreference.quoteChar() != null) {
|
||||
writer.quoteCharacter(csvPreference.quoteChar());
|
||||
writer.quoteStrategy(QuoteStrategy.ALWAYS);
|
||||
writer.quoteStrategy(QuoteStrategies.ALWAYS);
|
||||
}
|
||||
|
||||
return writer.build(filename.toPath(), Charset.forName(fileEncoding));
|
||||
|
||||
@@ -65,8 +65,8 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
|
||||
|
||||
@Override
|
||||
public void cancelEdit() {
|
||||
super.cancelEdit();
|
||||
setText(getItem().getValue());
|
||||
super.cancelEdit();
|
||||
setContentDisplay(ContentDisplay.TEXT_ONLY);
|
||||
}
|
||||
|
||||
@@ -113,16 +113,11 @@ public class EditableValidationCell extends TableCell<CSVRow, CSVValue> {
|
||||
textField.setMinWidth(this.getWidth() - this.getGraphicTextGap() * 2);
|
||||
textField.setOnKeyPressed(t -> {
|
||||
if (t.getCode() == KeyCode.ENTER) {
|
||||
commitEdit(textField.getValue());
|
||||
runLater(() -> commitEdit(textField.getValue()));
|
||||
} else if (t.getCode() == KeyCode.ESCAPE) {
|
||||
cancelEdit();
|
||||
}
|
||||
});
|
||||
textField.focusedProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue && textField != null) {
|
||||
commitEdit(textField.getValue());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static class ValueTextField extends TextField {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
application.name = SmartCSV.fx
|
||||
application.version = 1.3.0
|
||||
application.version = 1.4.0
|
||||
|
||||
# fxml views
|
||||
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml
|
||||
|
||||
Reference in New Issue
Block a user