mirror of
https://github.com/frosch95/SmartCSV.fx.git
synced 2026-04-11 13:38:23 +02:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 55ed382203 | |||
| 81d75a995b | |||
| f5ab096452 | |||
| 18335b9280 | |||
| 4e216b4792 | |||
| 3980e2951f | |||
| 1b39c9a08e | |||
| 0db16c0328 | |||
| bec55b6119 | |||
| 7dac3ce011 | |||
| 449f929f08 | |||
| 9e3561fedb | |||
| 9c1b110bfd | |||
| 398219a897 | |||
|
|
a79dde5421 | ||
| fb234fa50e | |||
| 43856dffab | |||
| 8cecca2172 | |||
|
|
35f395d44a |
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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
The MIT License (MIT)
|
||||
------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 Andreas Billmann <andreas.billmann@javafx.ninja>
|
||||
Copyright (c) 2015-2021 Andreas Billmann <andreas.billmann@javafx.ninja>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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.0.0)](https://github.com/frosch95/SmartCSV.fx/releases/download/1.0.0/SmartCSV.fx-1.0.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/)
|
||||
|
||||
62
build.gradle
62
build.gradle
@@ -3,41 +3,51 @@ plugins {
|
||||
id 'java'
|
||||
id 'groovy'
|
||||
id 'application'
|
||||
id 'org.openjfx.javafxplugin' version '0.0.8'
|
||||
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 = "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.5.2'
|
||||
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: '5.5.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.codehaus.groovy', name: 'groovy-all', version: '3.0.6'
|
||||
implementation group: 'org.springframework', name:'spring-context', version: '5.3.10'
|
||||
implementation group: 'net.sf.supercsv', name: 'super-csv', version: '2.4.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.0.2'
|
||||
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'
|
||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
|
||||
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
|
||||
implementation group: 'org.fxmisc.richtext', name: 'richtextfx', version: '0.10.5'
|
||||
// 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'
|
||||
|
||||
}
|
||||
|
||||
test {
|
||||
@@ -45,5 +55,9 @@ test {
|
||||
}
|
||||
|
||||
group 'ninja.javafx'
|
||||
version '1.0.1'
|
||||
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
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,22 +26,24 @@
|
||||
|
||||
package ninja.javafx.smartcsv.csv;
|
||||
|
||||
import org.supercsv.prefs.CsvPreference;
|
||||
import ninja.javafx.smartcsv.preferences.Preferences;
|
||||
|
||||
import static ninja.javafx.smartcsv.preferences.Preferences.defaultPreferences;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class CSVConfigurable {
|
||||
|
||||
protected CsvPreference csvPreference;
|
||||
protected Preferences csvPreference;
|
||||
|
||||
protected String fileEncoding;
|
||||
|
||||
public CSVConfigurable() {
|
||||
csvPreference = CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE;
|
||||
csvPreference = defaultPreferences();
|
||||
}
|
||||
|
||||
public void setCsvPreference(CsvPreference csvPreference) {
|
||||
public void setCsvPreference(Preferences csvPreference) {
|
||||
this.csvPreference = csvPreference;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,17 +26,14 @@
|
||||
|
||||
package ninja.javafx.smartcsv.csv;
|
||||
|
||||
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;
|
||||
import ninja.javafx.smartcsv.fx.table.model.CSVRow;
|
||||
import org.supercsv.exception.SuperCsvException;
|
||||
import org.supercsv.io.CsvMapReader;
|
||||
import org.supercsv.io.ICsvMapReader;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* reads the csv file and stores the values in csv model
|
||||
@@ -48,28 +45,44 @@ public class CSVFileReader extends CSVConfigurable implements FileReader<CSVMode
|
||||
@Override
|
||||
public void read(File file) throws IOException {
|
||||
|
||||
try (ICsvMapReader mapReader = new CsvMapReader(new java.io.FileReader(file.getAbsoluteFile(), Charset.forName(fileEncoding)),
|
||||
csvPreference)) {
|
||||
System.out.println(csvPreference);
|
||||
try (var csv = getNamedCsvReader(file)) {
|
||||
model = new CSVModel();
|
||||
|
||||
// the header columns are used as the keys to the Map
|
||||
String[] header = mapReader.getHeader(true);
|
||||
var firstRow = csv.stream().findFirst();
|
||||
|
||||
if (firstRow.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
var header = firstRow.get().getHeader().toArray(String[]::new);
|
||||
model.setHeader(header);
|
||||
|
||||
Map<String, String> customerMap;
|
||||
while ((customerMap = mapReader.read(header)) != null) {
|
||||
CSVRow row = model.addRow();
|
||||
csv.forEach(csvRow -> {
|
||||
var row = model.addRow();
|
||||
for (String column : header) {
|
||||
model.addValue(row, column, customerMap.get(column));
|
||||
model.addValue(row, column, csvRow.getField(column));
|
||||
}
|
||||
}
|
||||
} catch (IOException | SuperCsvException ex) {
|
||||
});
|
||||
|
||||
} catch (IOException ex) {
|
||||
// TODO perhaps a custom NinjaException that can properly identify and localize the exception message
|
||||
// is this a file not found? is this a corrupt csv? etc
|
||||
throw new IOException("Failed to read " + file + ": " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
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.ofNamedCsvRecord(file.toPath(), Charset.forName(fileEncoding));
|
||||
}
|
||||
|
||||
public CSVModel getContent() {
|
||||
return model;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -26,18 +26,17 @@
|
||||
|
||||
package ninja.javafx.smartcsv.csv;
|
||||
|
||||
import de.siegmar.fastcsv.writer.CsvWriter;
|
||||
import de.siegmar.fastcsv.writer.QuoteStrategies;
|
||||
import ninja.javafx.smartcsv.fx.table.model.CSVModel;
|
||||
import ninja.javafx.smartcsv.fx.table.model.CSVRow;
|
||||
import org.supercsv.io.CsvMapWriter;
|
||||
import org.supercsv.io.ICsvMapWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.stream.Collectors.toMap;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
/**
|
||||
* filewriter for the csv
|
||||
@@ -52,22 +51,22 @@ public class CSVFileWriter extends CSVConfigurable implements ninja.javafx.smart
|
||||
|
||||
@Override
|
||||
public void write(File filename) throws IOException {
|
||||
ICsvMapWriter mapWriter = null;
|
||||
try {
|
||||
mapWriter = new CsvMapWriter(new FileWriter(filename.getAbsolutePath(), Charset.forName(fileEncoding)),
|
||||
csvPreference);
|
||||
mapWriter.writeHeader(model.getHeader());
|
||||
|
||||
try (var writer = getCsvWriter(filename)){
|
||||
writer.writeRecord(model.getHeader());
|
||||
for(CSVRow row: model.getRows()) {
|
||||
Map<String, String> columns = convertMapFromModel(row);
|
||||
mapWriter.write(columns, model.getHeader());
|
||||
writer.writeRecord(convertMapFromModel(row));
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if( mapWriter != null ) {
|
||||
mapWriter.close();
|
||||
}
|
||||
}
|
||||
|
||||
private CsvWriter getCsvWriter(File filename) throws IOException {
|
||||
var writer = CsvWriter.builder().fieldSeparator(csvPreference.delimiterChar());
|
||||
if (csvPreference.quoteChar() != null) {
|
||||
writer.quoteCharacter(csvPreference.quoteChar());
|
||||
writer.quoteStrategy(QuoteStrategies.ALWAYS);
|
||||
}
|
||||
|
||||
return writer.build(filename.toPath(), Charset.forName(fileEncoding));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,13 +74,8 @@ public class CSVFileWriter extends CSVConfigurable implements ninja.javafx.smart
|
||||
* @param row the row to convert
|
||||
* @return a simple map for the supercvs writer
|
||||
*/
|
||||
private Map<String, String> convertMapFromModel(CSVRow row) {
|
||||
return row.getColumns().entrySet().stream()
|
||||
.collect(
|
||||
toMap(
|
||||
Map.Entry::getKey,
|
||||
e -> e.getValue().getValue().getValue() != null ? e.getValue().getValue().getValue() : ""
|
||||
)
|
||||
);
|
||||
private List<String> convertMapFromModel(CSVRow row) {
|
||||
return row.getColumns().values().stream().map(v -> v.get().getValue())
|
||||
.collect(toList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -85,6 +85,8 @@ public class SmartCSV extends Application {
|
||||
private void showUI(Stage primaryStage, String name, String version) {
|
||||
SmartCSVController smartCVSController = appContext.getBean(SmartCSVController.class);
|
||||
Scene scene = new Scene((Parent) smartCVSController.getView());
|
||||
var defaultThemeCss = getClass().getResource("/ninja/javafx/smartcsv/fx/smartcsv.css").toExternalForm();
|
||||
scene.getRoot().getStylesheets().add(defaultThemeCss);
|
||||
|
||||
primaryStage.setScene(scene);
|
||||
primaryStage.setTitle(String.format("%s %s", name, version));
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -36,6 +36,8 @@ import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.input.Dragboard;
|
||||
import javafx.scene.input.TransferMode;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.stage.FileChooser;
|
||||
@@ -64,7 +66,6 @@ import ninja.javafx.smartcsv.validation.configuration.ValidationConfiguration;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.supercsv.prefs.CsvPreference;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -79,6 +80,7 @@ import static javafx.application.Platform.exit;
|
||||
import static javafx.application.Platform.runLater;
|
||||
import static javafx.beans.binding.Bindings.*;
|
||||
import static javafx.scene.layout.AnchorPane.*;
|
||||
import static ninja.javafx.smartcsv.preferences.Preferences.defaultPreferences;
|
||||
|
||||
/**
|
||||
* main controller of the application
|
||||
@@ -208,6 +210,9 @@ public class SmartCSVController extends FXMLController {
|
||||
@FXML
|
||||
private Label currentLineNumber;
|
||||
|
||||
@FXML
|
||||
private Label totalNumberOfLines;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// members
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -222,7 +227,7 @@ public class SmartCSVController extends FXMLController {
|
||||
|
||||
private FileStorage<CSVModel> currentCsvFile = new FileStorage<>(csvFileReader, csvFileWriter);
|
||||
private FileStorage<ValidationConfiguration> currentConfigFile = new FileStorage<>(new ValidationFileReader(), new ValidationFileWriter());
|
||||
private FileStorage<CsvPreference> csvPreferenceFile = new FileStorage<>(new PreferencesFileReader(), new PreferencesFileWriter());
|
||||
private FileStorage<Preferences> csvPreferenceFile = new FileStorage<>(new PreferencesFileReader(), new PreferencesFileWriter());
|
||||
private FileStorage<String> fileEncodingFile = new FileStorage<>(new EncodingFileReader(), new EncodingFileWriter());
|
||||
|
||||
private ListChangeListener<ValidationError> errorListListener = c -> tableView.refresh();
|
||||
@@ -252,6 +257,34 @@ public class SmartCSVController extends FXMLController {
|
||||
fileEncodingFile.setFile(ENCODING_FILE);
|
||||
|
||||
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() {
|
||||
@@ -368,7 +401,7 @@ public class SmartCSVController extends FXMLController {
|
||||
Optional<ButtonType> result = alert.showAndWait();
|
||||
|
||||
if (result.get() == ButtonType.OK){
|
||||
CsvPreference csvPreference = preferencesController.getCsvPreference();
|
||||
Preferences csvPreference = preferencesController.getCsvPreference();
|
||||
setCsvPreference(csvPreference);
|
||||
saveCsvPreferences(csvPreference);
|
||||
String fileEncoding = CharsetHelper.getCharsetName(preferencesController.getFileEncoding());
|
||||
@@ -470,6 +503,22 @@ public class SmartCSVController extends FXMLController {
|
||||
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) {
|
||||
validationEditorController.setSelectedColumn(column);
|
||||
validationEditorController.updateForm();
|
||||
@@ -544,12 +593,12 @@ public class SmartCSVController extends FXMLController {
|
||||
loadEncodingFromFile();
|
||||
});
|
||||
} else {
|
||||
setCsvPreference(CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE);
|
||||
setCsvPreference(defaultPreferences());
|
||||
loadEncodingFromFile();
|
||||
}
|
||||
}
|
||||
|
||||
private void saveCsvPreferences(CsvPreference csvPreference) {
|
||||
private void saveCsvPreferences(Preferences csvPreference) {
|
||||
try {
|
||||
createPreferenceFile();
|
||||
csvPreferenceFile.setContent(csvPreference);
|
||||
@@ -572,7 +621,7 @@ public class SmartCSVController extends FXMLController {
|
||||
}
|
||||
}
|
||||
|
||||
private void setCsvPreference(CsvPreference csvPreference) {
|
||||
private void setCsvPreference(Preferences csvPreference) {
|
||||
preferencesController.setCsvPreference(csvPreference);
|
||||
csvFileReader.setCsvPreference(csvPreference);
|
||||
csvFileWriter.setCsvPreference(csvPreference);
|
||||
@@ -596,6 +645,10 @@ public class SmartCSVController extends FXMLController {
|
||||
|
||||
//Show open file dialog
|
||||
File file = fileChooser.showOpenDialog(applicationPane.getScene().getWindow());
|
||||
openFile(storageFile, file);
|
||||
}
|
||||
|
||||
private void openFile(FileStorage storageFile, File file) {
|
||||
if (file != null) {
|
||||
File previousFile = storageFile.getFile();
|
||||
storageFile.setFile(file);
|
||||
@@ -674,6 +727,8 @@ public class SmartCSVController extends FXMLController {
|
||||
tableView.getItems().setAll(currentCsvFile.getContent().getRows());
|
||||
tableView.setEditable(true);
|
||||
|
||||
totalNumberOfLines.textProperty().setValue("" + currentCsvFile.getContent().getRows().size());
|
||||
|
||||
setBottomAnchor(tableView, 0.0);
|
||||
setTopAnchor(tableView, 0.0);
|
||||
setLeftAnchor(tableView, 0.0);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -34,18 +34,15 @@ import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.TextField;
|
||||
import javafx.scene.control.TextFormatter;
|
||||
import ninja.javafx.smartcsv.fx.FXMLController;
|
||||
import ninja.javafx.smartcsv.preferences.Preferences;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.supercsv.prefs.CsvPreference;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
import static ninja.javafx.smartcsv.preferences.QuoteModeHelper.getQuoteMode;
|
||||
import static ninja.javafx.smartcsv.preferences.QuoteModeHelper.getQuoteModeName;
|
||||
|
||||
/**
|
||||
* controller for preferences
|
||||
*/
|
||||
@@ -58,15 +55,9 @@ public class PreferencesController extends FXMLController {
|
||||
@FXML
|
||||
private TextField delimiterChar;
|
||||
|
||||
@FXML
|
||||
private CheckBox surroundingSpacesNeedQuotes;
|
||||
|
||||
@FXML
|
||||
private CheckBox ignoreEmptyLines;
|
||||
|
||||
@FXML
|
||||
private ComboBox<String> quoteMode;
|
||||
|
||||
@FXML
|
||||
private ComboBox<String> fileEncoding;
|
||||
|
||||
@@ -83,7 +74,6 @@ public class PreferencesController extends FXMLController {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
quoteMode.getItems().addAll("normal", "always", "column");
|
||||
fileEncoding.getItems().addAll(Charset.availableCharsets().keySet());
|
||||
|
||||
UnaryOperator<TextFormatter.Change> allowOnlyOneCharacter = change -> {
|
||||
@@ -102,24 +92,23 @@ public class PreferencesController extends FXMLController {
|
||||
}
|
||||
|
||||
private void revalidate() {
|
||||
valid.setValue(quoteChar.getText().length() == 1 && delimiterChar.getText().length() == 1);
|
||||
valid.setValue(quoteChar.getText().length() <= 1 && delimiterChar.getText().length() == 1);
|
||||
}
|
||||
|
||||
public void setCsvPreference(CsvPreference csvPreference) {
|
||||
quoteChar.setText(Character.toString(csvPreference.getQuoteChar()));
|
||||
delimiterChar.setText(Character.toString((char)csvPreference.getDelimiterChar()));
|
||||
surroundingSpacesNeedQuotes.setSelected(csvPreference.isSurroundingSpacesNeedQuotes());
|
||||
ignoreEmptyLines.setSelected(csvPreference.isIgnoreEmptyLines());
|
||||
quoteMode.getSelectionModel().select(getQuoteModeName(csvPreference.getQuoteMode()));
|
||||
endOfLineSymbols = csvPreference.getEndOfLineSymbols();
|
||||
public void setCsvPreference(Preferences csvPreference) {
|
||||
if (csvPreference.quoteChar() != null) {
|
||||
quoteChar.setText(csvPreference.quoteChar().toString());
|
||||
} else {
|
||||
quoteChar.setText("");
|
||||
}
|
||||
delimiterChar.setText(Character.toString(csvPreference.delimiterChar()));
|
||||
ignoreEmptyLines.setSelected(csvPreference.ignoreEmptyLines());
|
||||
endOfLineSymbols = csvPreference.endOfLineSymbols();
|
||||
}
|
||||
|
||||
public CsvPreference getCsvPreference() {
|
||||
return new CsvPreference.Builder(quoteChar.getText().charAt(0), delimiterChar.getText().charAt(0), endOfLineSymbols)
|
||||
.useQuoteMode(getQuoteMode(quoteMode.getSelectionModel().getSelectedItem()))
|
||||
.surroundingSpacesNeedQuotes(surroundingSpacesNeedQuotes.isSelected())
|
||||
.ignoreEmptyLines(ignoreEmptyLines.isSelected())
|
||||
.build();
|
||||
public Preferences getCsvPreference() {
|
||||
var quote = quoteChar.getText().length() == 0 ? null : quoteChar.getText().charAt(0);
|
||||
return new Preferences(quote, delimiterChar.getText().charAt(0), endOfLineSymbols, ignoreEmptyLines.isSelected());
|
||||
}
|
||||
|
||||
public void setFileEncoding(String fileEncoding) {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -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 {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
@@ -21,36 +21,18 @@
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
package ninja.javafx.smartcsv.preferences;
|
||||
|
||||
import org.supercsv.quote.AlwaysQuoteMode;
|
||||
import org.supercsv.quote.ColumnQuoteMode;
|
||||
import org.supercsv.quote.NormalQuoteMode;
|
||||
import org.supercsv.quote.QuoteMode;
|
||||
public record Preferences(
|
||||
Character quoteChar,
|
||||
char delimiterChar,
|
||||
String endOfLineSymbols,
|
||||
boolean ignoreEmptyLines) {
|
||||
|
||||
/**
|
||||
* Helper class for mapping quote quoteModeName
|
||||
*/
|
||||
public class QuoteModeHelper {
|
||||
|
||||
public static QuoteMode getQuoteMode(String quoteModeName) {
|
||||
switch (quoteModeName) {
|
||||
case "always": return new AlwaysQuoteMode();
|
||||
case "column": return new ColumnQuoteMode();
|
||||
default: return new NormalQuoteMode();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getQuoteModeName(QuoteMode quoteMode) {
|
||||
if (quoteMode instanceof AlwaysQuoteMode) {
|
||||
return "always";
|
||||
} else if (quoteMode instanceof ColumnQuoteMode) {
|
||||
return "column";
|
||||
} else {
|
||||
return "normal";
|
||||
}
|
||||
public static Preferences defaultPreferences() {
|
||||
return new Preferences('\"',',', "\n", true);
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,27 +28,23 @@ package ninja.javafx.smartcsv.preferences;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ninja.javafx.smartcsv.FileReader;
|
||||
import org.supercsv.prefs.CsvPreference;
|
||||
import org.supercsv.quote.AlwaysQuoteMode;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static ninja.javafx.smartcsv.preferences.QuoteModeHelper.getQuoteMode;
|
||||
import static ninja.javafx.smartcsv.preferences.Preferences.defaultPreferences;
|
||||
|
||||
/**
|
||||
* file reader for the preferences
|
||||
*/
|
||||
public class PreferencesFileReader implements FileReader<CsvPreference> {
|
||||
public class PreferencesFileReader implements FileReader<Preferences> {
|
||||
|
||||
private CsvPreference csvPreference;
|
||||
private Preferences csvPreference;
|
||||
|
||||
public PreferencesFileReader() {
|
||||
csvPreference = new CsvPreference.
|
||||
Builder(CsvPreference.EXCEL_NORTH_EUROPE_PREFERENCE).
|
||||
useQuoteMode(new AlwaysQuoteMode()).build();
|
||||
csvPreference = defaultPreferences();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,22 +52,15 @@ public class PreferencesFileReader implements FileReader<CsvPreference> {
|
||||
Map config = new GsonBuilder().create().fromJson(new java.io.FileReader(filename), HashMap.class);
|
||||
|
||||
if (config != null) {
|
||||
char quoteChar = config.get("quoteChar").toString().charAt(0);
|
||||
Character quoteChar = config.get("quoteChar") == null ? null : config.get("quoteChar").toString().charAt(0);
|
||||
char delimiterChar = config.get("delimiterChar").toString().charAt(0);
|
||||
String endOfLineSymbols = config.get("endOfLineSymbols").toString();
|
||||
boolean surroundingSpacesNeedQuotes = (Boolean) config.get("surroundingSpacesNeedQuotes");
|
||||
boolean ignoreEmptyLines = (Boolean) config.get("ignoreEmptyLines");
|
||||
String quoteMode = config.get("quoteMode").toString();
|
||||
|
||||
csvPreference = new CsvPreference.Builder(quoteChar, delimiterChar, endOfLineSymbols)
|
||||
.useQuoteMode(getQuoteMode(quoteMode))
|
||||
.surroundingSpacesNeedQuotes(surroundingSpacesNeedQuotes)
|
||||
.ignoreEmptyLines(ignoreEmptyLines)
|
||||
.build();
|
||||
csvPreference = new Preferences(quoteChar, delimiterChar, endOfLineSymbols, ignoreEmptyLines);
|
||||
}
|
||||
}
|
||||
|
||||
public CsvPreference getContent() {
|
||||
public Preferences getContent() {
|
||||
return csvPreference;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,6 @@ package ninja.javafx.smartcsv.preferences;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import ninja.javafx.smartcsv.FileWriter;
|
||||
import org.supercsv.prefs.CsvPreference;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -40,22 +39,20 @@ import java.util.Map;
|
||||
/**
|
||||
* Save preferences to configuration file
|
||||
*/
|
||||
public class PreferencesFileWriter implements FileWriter<CsvPreference> {
|
||||
public class PreferencesFileWriter implements FileWriter<Preferences> {
|
||||
|
||||
private CsvPreference csvPreference;
|
||||
private Preferences csvPreference;
|
||||
|
||||
public void setContent(CsvPreference csvPreference) {
|
||||
public void setContent(Preferences csvPreference) {
|
||||
this.csvPreference = csvPreference;
|
||||
}
|
||||
|
||||
public void write(File file) throws IOException {
|
||||
Map<String, Object> preferences = new HashMap<>();
|
||||
preferences.put("quoteChar", Character.toString(csvPreference.getQuoteChar()));
|
||||
preferences.put("delimiterChar", Character.toString((char)csvPreference.getDelimiterChar()));
|
||||
preferences.put("endOfLineSymbols", csvPreference.getEndOfLineSymbols());
|
||||
preferences.put("surroundingSpacesNeedQuotes", csvPreference.isSurroundingSpacesNeedQuotes());
|
||||
preferences.put("ignoreEmptyLines", csvPreference.isIgnoreEmptyLines());
|
||||
preferences.put("quoteMode", QuoteModeHelper.getQuoteModeName(csvPreference.getQuoteMode()));
|
||||
preferences.put("quoteChar", csvPreference.quoteChar() == null ? null: csvPreference.quoteChar().toString());
|
||||
preferences.put("delimiterChar", Character.toString((char)csvPreference.delimiterChar()));
|
||||
preferences.put("endOfLineSymbols", csvPreference.endOfLineSymbols());
|
||||
preferences.put("ignoreEmptyLines", csvPreference.ignoreEmptyLines());
|
||||
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
Files.write(file.toPath(), gson.toJson(preferences).getBytes());
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
</Label>
|
||||
<Label text="AOE Takashi (https://github.com/aoetk)" />
|
||||
<Label text="Hasan Kara (https://github.com/haisi)" />
|
||||
<Label text="apixandru (https://github.com/apixandru)" />
|
||||
<Label text="3rd party software">
|
||||
<VBox.margin>
|
||||
<Insets top="8.0" />
|
||||
@@ -60,8 +61,8 @@
|
||||
<Hyperlink onAction="#openLinkInBrowser" text="http://www.groovy-lang.org/" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Label text="spring framework" GridPane.rowIndex="3" />
|
||||
<Hyperlink onAction="#openLinkInBrowser" text="https://spring.io/" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<Label text="supercsv" GridPane.rowIndex="4" />
|
||||
<Hyperlink onAction="#openLinkInBrowser" text="http://super-csv.github.io/super-csv/" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<Label text="FastCSV" GridPane.rowIndex="4" />
|
||||
<Hyperlink onAction="#openLinkInBrowser" text="https://github.com/osiegmar/FastCSV" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<Label text="Gson" GridPane.rowIndex="5" />
|
||||
<Hyperlink onAction="#openLinkInBrowser" text="https://github.com/google/gson/" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||
<Label text="commons-validator" GridPane.rowIndex="6" />
|
||||
@@ -89,7 +90,7 @@
|
||||
<Font size="18.0" />
|
||||
</font>
|
||||
</Label>
|
||||
<TextArea editable="false" prefHeight="200.0" prefWidth="200.0" text="Copyright (c) 2015-2019 Andreas Billmann <andreas.billmann@javafx.ninja> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." wrapText="true" />
|
||||
<TextArea editable="false" prefHeight="200.0" prefWidth="200.0" text="Copyright (c) 2015-2021 Andreas Billmann <andreas.billmann@javafx.ninja> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE." wrapText="true" />
|
||||
</children>
|
||||
<opaqueInsets>
|
||||
<Insets />
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
application.name = SmartCSV.fx
|
||||
application.version = 1.0.0
|
||||
application.version = 1.4.0
|
||||
|
||||
# fxml views
|
||||
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml
|
||||
|
||||
@@ -12,23 +12,17 @@
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="NEVER" />
|
||||
</rowConstraints>
|
||||
<children>
|
||||
<Label text="%preferences.quoteChar" />
|
||||
<TextField fx:id="quoteChar" GridPane.columnIndex="1" />
|
||||
<Label text="%preferences.delimiterChar" GridPane.rowIndex="1" />
|
||||
<TextField fx:id="delimiterChar" GridPane.columnIndex="1" GridPane.rowIndex="1" />
|
||||
<Label text="%preferences.surroundingSpacesNeedQuotes" GridPane.rowIndex="2" />
|
||||
<CheckBox fx:id="surroundingSpacesNeedQuotes" mnemonicParsing="false" text="" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Label text="%preferences.ignoreEmptyLines" GridPane.rowIndex="3" />
|
||||
<CheckBox fx:id="ignoreEmptyLines" mnemonicParsing="false" text="" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
<Label text="%preferences.quoteMode" GridPane.rowIndex="4" />
|
||||
<ComboBox fx:id="quoteMode" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="4" />
|
||||
<Label text="%preferences.fileEncoding" GridPane.rowIndex="5" />
|
||||
<ComboBox fx:id="fileEncoding" editable="true" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="5" />
|
||||
<Label text="%preferences.ignoreEmptyLines" GridPane.rowIndex="2" />
|
||||
<CheckBox fx:id="ignoreEmptyLines" mnemonicParsing="false" text="" GridPane.columnIndex="1" GridPane.rowIndex="2" />
|
||||
<Label text="%preferences.fileEncoding" GridPane.rowIndex="3" />
|
||||
<ComboBox fx:id="fileEncoding" editable="true" prefWidth="150.0" GridPane.columnIndex="1" GridPane.rowIndex="3" />
|
||||
</children>
|
||||
<padding>
|
||||
<Insets bottom="8.0" left="8.0" right="8.0" top="8.0" />
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.*?>
|
||||
<?import javafx.scene.layout.*?>
|
||||
<?import java.net.URL?>
|
||||
<BorderPane fx:id="applicationPane" maxHeight="-Infinity" maxWidth="1000.0" minHeight="700.0" minWidth="-Infinity" prefHeight="700.0" prefWidth="1000.0" xmlns="http://javafx.com/javafx/8.0.101" xmlns:fx="http://javafx.com/fxml/1">
|
||||
<top>
|
||||
<VBox id="background" prefWidth="100.0" BorderPane.alignment="CENTER">
|
||||
@@ -265,9 +264,6 @@
|
||||
</center>
|
||||
<left>
|
||||
</left>
|
||||
<stylesheets>
|
||||
<URL value="@/ninja/javafx/smartcsv/fx/smartcsv.css" />
|
||||
</stylesheets>
|
||||
<bottom>
|
||||
<GridPane hgap="8.0" BorderPane.alignment="CENTER">
|
||||
<columnConstraints>
|
||||
@@ -279,7 +275,9 @@
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" />
|
||||
<ColumnConstraints hgrow="NEVER" minWidth="10.0" />
|
||||
<ColumnConstraints fillWidth="false" halignment="RIGHT" hgrow="NEVER" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints fillWidth="false" halignment="RIGHT" hgrow="NEVER" minWidth="10.0" prefWidth="100.0" />
|
||||
<ColumnConstraints hgrow="ALWAYS" minWidth="10.0" prefWidth="100.0" />
|
||||
</columnConstraints>
|
||||
<rowConstraints>
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
@@ -293,6 +291,8 @@
|
||||
<Label fx:id="configurationName" GridPane.columnIndex="5" GridPane.hgrow="ALWAYS" />
|
||||
<Label text="%lineNumber" GridPane.columnIndex="7" />
|
||||
<Label fx:id="currentLineNumber" text="" GridPane.columnIndex="8" />
|
||||
<Label text="%totalNumberOfLines" GridPane.columnIndex="9" />
|
||||
<Label fx:id="totalNumberOfLines" text="0" GridPane.columnIndex="10" />
|
||||
</children>
|
||||
<BorderPane.margin>
|
||||
<Insets bottom="4.0" left="8.0" right="8.0" top="4.0" />
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -87,6 +91,7 @@ dialog.validation.rules.header = Validation rules of column "{0}"
|
||||
context.menu.edit.column.rules = Edit rules
|
||||
|
||||
lineNumber = Selected line:
|
||||
totalNumberOfLines = Lines:
|
||||
|
||||
log.header.message = {0} has {1} errors
|
||||
log.message = row {0} column {1} : {2}
|
||||
|
||||
@@ -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:
|
||||
@@ -97,6 +101,7 @@ dialog.validation.rules.header = Pr\u00fcfregeln f\u00fcr die Spalte "{0}"
|
||||
context.menu.edit.column.rules = Pr\u00fcfregeln bearbeiten
|
||||
|
||||
lineNumber = Ausgew\u00e4hlte Zeile:
|
||||
totalNumberOfLines = Zeilen:
|
||||
|
||||
log.header.message = {0} hat {1} Fehler
|
||||
log.message = Zeile {0} Spalte {1} : {2}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -28,8 +28,9 @@ package ninja.javafx.smartcsv.fx.table.model;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* unit test for the csv model
|
||||
|
||||
@@ -2,9 +2,10 @@ package ninja.javafx.smartcsv.fx.table.model;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.hasKey;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
|
||||
/**
|
||||
* unit test for row class
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
The MIT License (MIT)
|
||||
-----------------------------------------------------------------------------
|
||||
|
||||
Copyright (c) 2015-2019 javafx.ninja <info@javafx.ninja>
|
||||
Copyright (c) 2015-2021 javafx.ninja <info@javafx.ninja>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -38,9 +38,10 @@ import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.Collections.singletonList;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
|
||||
/**
|
||||
* unit test for header validator
|
||||
|
||||
@@ -12,9 +12,9 @@ import java.util.stream.Stream;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static java.util.stream.Collectors.joining;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* unit test for validator
|
||||
|
||||
Reference in New Issue
Block a user