12 Commits
0.8 ... 0.9

Author SHA1 Message Date
7c3f140491 Merge remote-tracking branch 'remotes/origin/fxlauncher' 2016-10-06 21:07:42 +02:00
16373a033a change updating text in fxlauncher 2016-10-06 21:07:01 +02:00
e9e71b5474 gradle task to rename the fxlauncher.jar and launcher without own ui 2016-10-06 15:33:00 +02:00
48c657b648 fxlauncher without customization 2016-10-06 14:01:52 +02:00
8bd90b47e1 renamed license file 2016-10-06 07:09:50 +02:00
44f36759a6 thx for contribution: Hasan Kara 2016-10-05 15:43:36 +02:00
Andreas Billmann
326e4d954b Merge pull request #14 from haisi/master
Fix typo
2016-10-05 15:35:56 +02:00
Hasan Kara
96446e4e75 Fix typo 2016-10-05 14:51:05 +02:00
Andreas Billmann
5eaf021632 fixed broken tests 2016-09-23 11:14:45 +02:00
Andreas Billmann
ef376d6c61 set constraints when created 2016-09-22 22:09:56 +02:00
Andreas Billmann
2676b523d3 clear groovy field if there is some text in it 2016-09-22 21:49:30 +02:00
Andreas Billmann
7e34ff8c59 fixed NPE when string has no format 2016-09-22 21:35:40 +02:00
13 changed files with 204 additions and 75 deletions

View File

View File

@@ -14,7 +14,8 @@ 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 (0.8)](https://github.com/frosch95/SmartCSV.fx/releases/download/0.8/SmartCSV.fx-0.8-SNAPSHOT.zip)
binary distribution of the [SmartCSV.fx launcher](http://www.javafx.ninja/SmartCSV.fx/SmartCSV.fx.jar)
copy the jar to an appropriate place and start the application with a double click on the jar (or java -jar SmartCSV.fx.jar on command line)
##Talks
[Introduction](http://javafx.ninja/talks/introduction/)

View File

@@ -1,14 +1,34 @@
group 'ninja.javafx'
version '0.8-SNAPSHOT'
version '0.9-SNAPSHOT'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'no.tornado:fxlauncher-gradle-plugin:1.0.12'
}
}
apply plugin: 'java'
apply plugin: 'groovy'
apply plugin: 'application'
apply plugin: 'idea'
apply plugin: 'no.tornado.fxlauncher'
sourceCompatibility = 1.8
mainClassName = 'ninja.javafx.smartcsv.fx.SmartCSV'
def fxlauncherPathName = getBuildDir().absolutePath + File.separatorChar + 'fxlauncher' + File.separatorChar
fxlauncher {
applicationVendor 'Andreas Billmann (andreas.billmann@javafx.ninja)'
applicationUrl 'http://javafx.ninja/SmartCSV.fx/'
applicationMainClass mainClassName
acceptDowngrade false
cacheDir 'USERLIB/SmartCSV.fx'
}
repositories {
mavenCentral()
jcenter()
@@ -17,7 +37,6 @@ repositories {
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'org.mockito', name: 'mockito-all', version: '1.10.19'
compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.4.7'
compile group: 'org.springframework', name:'spring-context', version: '4.3.1.RELEASE'
compile group: 'net.sf.supercsv', name: 'super-csv', version: '2.4.0'
@@ -34,5 +53,21 @@ dependencies {
}
task wrapper(type: Wrapper) {
gradleVersion = '2.14.1' //version required
gradleVersion = '3.1' //version required
}
task buildSmartCSV(dependsOn: ['clean','embedApplicationManifest']) << {
def file = new File(fxlauncherPathName + 'fxlauncher.jar')
file.renameTo(fxlauncherPathName + 'SmartCSV.fx.jar')
}
task modifyAppXML(dependsOn: 'generateApplicationManifest') << {
String contents = new File( fxlauncherPathName + 'app.xml' ).getText( 'UTF-8' )
contents = contents.replaceAll( 'Updating...', 'Updating SmartCSV.fx ...' )
contents = contents.replaceAll( '-fx-spacing: 10; -fx-padding: 25;', '-fx-spacing: 10; -fx-padding: 25;-fx-font-size: 0.9em;' )
new File( fxlauncherPathName + 'app.xml' ).write( contents, 'UTF-8' )
}
embedApplicationManifest.dependsOn modifyAppXML
defaultTasks 'buildSmartCSV'

View File

@@ -1,6 +1,6 @@
#Sat Jul 23 09:35:51 CEST 2016
#Thu Oct 06 15:00:38 CEST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

View File

@@ -11,7 +11,7 @@ import java.io.File;
import java.io.IOException;
/**
* This class stores files and there state
* This class stores files and their state
* @author abi
*/
public class FileStorage<E> {
@@ -26,7 +26,7 @@ public class FileStorage<E> {
private BooleanProperty fileChanged = new SimpleBooleanProperty(true);
private ObjectProperty<File> file = new SimpleObjectProperty<>();
private ObjectProperty<E> content = new SimpleObjectProperty<E>();
private ObjectProperty<E> content = new SimpleObjectProperty<>();
public boolean isFileChanged() {
return fileChanged.get();

View File

@@ -298,6 +298,7 @@ public class ValidationEditorController extends FXMLController {
Constraints constraints = config.getConstraints();
if (constraints == null) {
constraints = new Constraints();
config.setConstraints(constraints);
}
if (enableNotEmptyRule.isSelected()) {
@@ -442,7 +443,7 @@ public class ValidationEditorController extends FXMLController {
ruleEnabled.setSelected(false);
} else {
ruleEnabled.setSelected(true);
rule.replaceText(0, 0, value);
rule.replaceText(0, rule.getLength(), value);
}
}

View File

@@ -1,5 +1,7 @@
package ninja.javafx.smartcsv.validation;
import java.text.SimpleDateFormat;
/**
* @author abi
*/
@@ -31,6 +33,13 @@ public class ValidationFormatHelper {
format = format.replace("%j", "DDD");
format = format.replace("%U", "ww");
return format;
} else {
try {
new SimpleDateFormat(format);
return format;
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
}
}
return defaultFormat;

View File

@@ -133,6 +133,15 @@ public class Validator {
validationMap.put(validation.getType(), validation);
}
private void remove(String column, Validation.Type type) {
Map<Validation.Type, Validation> validationMap = columnValidationMap.get(column);
if (validationMap == null) {
validationMap = new HashMap<>();
columnValidationMap.put(column, validationMap);
}
validationMap.remove(type);
}
private void clear(String column) {
Map<Validation.Type, Validation> validationMap = columnValidationMap.get(column);
if (validationMap != null) {
@@ -172,12 +181,12 @@ public class Validator {
}
if (column.getType() == DATE) {
String format = dateFormat(column.getFormat(), "YYYY-MM-DD");
String format = dateFormat(column.getFormat(), "yyyy-MM-dd");
add(column.getName(), new DateValidation(format));
}
if (column.getType() == DATETIME) {
String format = dateFormat(column.getFormat(), "YYYY-MM-DDThh:mm:ssZ");
String format = dateFormat(column.getFormat(), "yyyy-MM-ddThh:mm:ssZ");
add(column.getName(), new DateValidation(format));
}
@@ -186,6 +195,10 @@ public class Validator {
add(column.getName(), new DateValidation(format));
}
if (column.getType() == STRING && column.getFormat() == null) {
remove(column.getName(), Validation.Type.STRING);
} else {
if (column.getType() == STRING && column.getFormat().equalsIgnoreCase(EMAIL.getExternalValue())) {
add(column.getName(), new EmailValidation());
}
@@ -202,8 +215,6 @@ public class Validator {
add(column.getName(), new BinaryValidation());
}
if (column.getType() == STRING && column.getFormat() == null) {
columnValidationMap.get(column).remove(Validation.Type.STRING);
}
}

View File

@@ -25,6 +25,7 @@
</VBox.margin>
</Label>
<Label text="AOE Takashi (https://github.com/aoetk)" />
<Label text="Hasan Kara (https://github.com/haisi)" />
<Label text="3rd party software">
<VBox.margin>
<Insets top="8.0" />

View File

@@ -1,5 +1,5 @@
application.name = SmartCSV.fx
application.version = 0.8
application.version = 0.9
# fxml views
fxml.smartcvs.view = /ninja/javafx/smartcsv/fx/smartcsv.fxml

View File

@@ -82,7 +82,7 @@ public class HeaderValidationTest {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Before
public void initialize() {
sut = new Validator(config);
sut = new Validator(config, new TestColumnValueProvider());
}
@@ -116,7 +116,21 @@ public class HeaderValidationTest {
}
public static String json(String... headerNames) {
return "{\"headers\":{\"list\":[" + asList(headerNames).stream().collect(joining(", ")) + "]}}";
String json = "{ \"fields\": [";
for (String headerName: headerNames) {
json += "{\"name\" : \""+headerName+"\" },";
}
if (headerNames != null && headerNames.length > 0) {
json = json.substring(0, json.length() - 1);
}
json += "]}";
return json;
}
}

View File

@@ -0,0 +1,18 @@
package ninja.javafx.smartcsv.validation;
import ninja.javafx.smartcsv.fx.table.model.ColumnValueProvider;
/**
* @author abi
*/
public class TestColumnValueProvider implements ColumnValueProvider {
@Override
public String getValue(int row, String column) {
return null;
}
@Override
public int getNumberOfRows() {
return 0;
}
}

View File

@@ -26,8 +26,7 @@ public class ValidatorTest {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// parameters
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
private ValidationConfiguration config;
private String column;
private String config;
private String value;
private Boolean expectedResult;
private ValidationMessage expectedError;
@@ -43,14 +42,10 @@ public class ValidatorTest {
// parameterized constructor
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
public ValidatorTest(String config,
String column,
String value,
Boolean expectedResult,
ValidationMessage expectedError) {
System.out.println(config);
Gson gson = new GsonBuilder().create();
this.config = gson.fromJson(config, ValidationConfiguration.class);
this.column = column;
this.config = config;
this.value = value;
this.expectedResult = expectedResult;
this.expectedError = expectedError;
@@ -62,7 +57,9 @@ public class ValidatorTest {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Before
public void initialize() {
sut = new Validator(config);
Gson gson = new GsonBuilder().create();
ValidationConfiguration validationConfiguration = gson.fromJson(config, ValidationConfiguration.class);
sut = new Validator(validationConfiguration, new TestColumnValueProvider());
}
@@ -71,10 +68,14 @@ public class ValidatorTest {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@Test
public void validation() {
System.out.println(column + " " + value + " " + expectedResult + " " + expectedError);
System.out.println("===================================================");
System.out.println(config);
System.out.println(value + " " + expectedResult + " " + expectedError);
System.out.println("===================================================\n");
// execution
ValidationError result = sut.isValid(0, column, value);
ValidationError result = sut.isValid(0, "column", value);
// assertion
assertThat(result == null, is(expectedResult));
@@ -89,33 +90,49 @@ public class ValidatorTest {
@Parameterized.Parameters
public static Collection validationConfigurations() {
return asList(new Object[][] {
{ json("column", "not empty", true), "column", "value", true, null },
{ json("column", "not empty", true), "column", "", false, new ValidationMessage("validation.message.not.empty") },
{ json("column", "not empty", true), "column", null, false, new ValidationMessage("validation.message.not.empty") },
{ json("column", "integer", true), "column", "999", true, null },
{ json("column", "integer", true), "column", "a", false, new ValidationMessage("validation.message.integer") },
{ json("column", "double", true), "column", "999", true, null },
{ json("column", "double", true), "column", "999.000", true, null },
{ json("column", "double", true), "column", "a", false, new ValidationMessage("validation.message.double") },
{ json("column", "minlength", 2), "column", "12", true, null },
{ json("column", "minlength", 2), "column", "1", false, new ValidationMessage("validation.message.min.length", "2") },
{ json("column", "maxlength", 2), "column", "12", true, null },
{ json("column", "maxlength", 2), "column", "123", false, new ValidationMessage("validation.message.max.length", "2") },
{ json("column", "date", "yyyyMMdd"), "column", "20151127", true, null },
{ json("column", "date", "yyyyMMdd"), "column", "27.11.2015", false, new ValidationMessage("validation.message.date.format", "yyyyMMdd") },
{ json("column", "alphanumeric", true), "column", "abcABC123", true, null },
{ json("column", "alphanumeric", true), "column", "-abcABC123", false, new ValidationMessage("validation.message.alphanumeric") },
{ json("column", "regexp", "[a-z]*"), "column", "abc", true, null },
{ json("column", "regexp", "[a-z]*"), "column", "abcA", false, new ValidationMessage("validation.message.regexp", "[a-z]*") },
{ json("column", "groovy", "value.contains('a')? 'true' : 'no a inside'"), "column", "abcdef", true, null },
{ json("column", "groovy", "value.contains('a')? 'true' : 'no a inside'"), "column", "bcdefg", false, new ValidationMessage("no a inside") },
{ json("column", "value of", asList("a","b","c","d","e")), "column", "c", true, null },
{ json("column", "value of", asList("a","b","c","d","e")), "column", "f", false, new ValidationMessage("validation.message.value.of", "f", "a, b, c, d, e") },
{ constraintsJSON("string", "required", true), "value", true, null },
{ constraintsJSON("string", "required", true), "", false, new ValidationMessage("validation.message.not.empty") },
{ constraintsJSON("string", "required", true), null, false, new ValidationMessage("validation.message.not.empty") },
{ constraintsJSON("integer", null, true), "999", true, null },
{ constraintsJSON("integer", null, true), "a", false, new ValidationMessage("validation.message.integer") },
{ constraintsJSON("number", null, true), "999", true, null },
{ constraintsJSON("number", null, true), "999.000", true, null },
{ constraintsJSON("number", null, true), "a", false, new ValidationMessage("validation.message.double") },
{ constraintsJSON("string", "minLength", 2), "12", true, null },
{ constraintsJSON("string", "minLength", 2), "1", false, new ValidationMessage("validation.message.min.length", "2") },
{ constraintsJSON("string", "maxLength", 2), "12", true, null },
{ constraintsJSON("string", "maxLength", 2), "123", false, new ValidationMessage("validation.message.max.length", "2") },
{ constraintsJSON("string", "pattern", "[a-z]*"), "abc", true, null },
{ constraintsJSON("string", "pattern", "[a-z]*"), "abcA", false, new ValidationMessage("validation.message.regexp", "[a-z]*") },
{ constraintsJSON("string", "enum", asList("a","b","c","d","e")), "c", true, null },
{ constraintsJSON("string", "enum", asList("a","b","c","d","e")), "f", false, new ValidationMessage("validation.message.value.of", "f", "a, b, c, d, e") },
{ formatJSON("string", null), "some string", true, null },
{ formatJSON("string", "email"), "test@javafx.ninja", true, null },
{ formatJSON("string", "email"), "wrong email", false, new ValidationMessage("validation.message.email") },
{ formatJSON("string", "uri"), "http://www.javafx.ninja", true, null },
{ formatJSON("string", "uri"), "!$%&/()", false, new ValidationMessage("validation.message.uri") },
{ formatJSON("string", "binary"), "dGVzdA==", true, null },
{ formatJSON("string", "binary"), "no binary", false, new ValidationMessage("validation.message.binary") },
{ formatJSON("string", "uuid"), "6ba7b810-9dad-11d1-80b4-00c04fd430c8", true, null },
{ formatJSON("string", "uuid"), "no uuid", false, new ValidationMessage("validation.message.uuid") },
{ formatJSON("date", null), "2015-11-27", true, null },
{ formatJSON("date", null), "27.11.2015", false, new ValidationMessage("validation.message.date.format", "yyyy-MM-dd") },
{ formatJSON("date", "yyyyMMdd"), "20151127", true, null },
{ formatJSON("date", "yyyyMMdd"), "27.11.2015", false, new ValidationMessage("validation.message.date.format", "yyyyMMdd") },
{ customAttributeJSON( "groovy", "value.contains('a')? 'true' : 'no a inside'"), "abcdef", true, null },
{ customAttributeJSON( "groovy", "value.contains('a')? 'true' : 'no a inside'"), "bcdefg", false, new ValidationMessage("no a inside") },
});
}
public static String json(String column, String rule, Object value) {
String json = "{\"headers\": { \"list\": [\""+column+"\"]},\"columns\":{\"" + column + "\":{\"" + rule + "\":";
public static String constraintsJSON(String type, String constraint, Object value) {
String json = "{\"fields\": [ { \"name\": \"column\", \"type\" : \"" + type +"\"";
if (constraint != null) {
json += ", \"constraints\": { \"" + constraint + "\":";
if (value instanceof String) {
json += "\"" + value + "\"";
} else if (value instanceof List) {
@@ -124,7 +141,29 @@ public class ValidatorTest {
} else {
json += value;
}
json += "}}}";
json += "}";
}
json += "}]}";
return json;
}
public static String formatJSON(String type, String format) {
String json = "{\"fields\": [ { \"name\": \"column\", \"type\" : \"" + type +"\"";
if (format != null) {
json += ", \"format\": \"" + format + "\"";
}
json += "}]}";
return json;
}
public static String customAttributeJSON(String attribute, String value) {
String json = "{\"fields\": [ { \"name\": \"column\", \"type\" : \"string\"";
if (attribute != null) {
json += ", \""+attribute+"\": \"" + value + "\"";
}
json += "}]}";
return json;
}
}