Skip to content

Commit b74bfa0

Browse files
committed
💚 Merge branch 'master' of
https://github.com/JsonSchema-JavaUI/asf-java-ui.git Conflicts: demo/src/main/java/io/asfjava/ui/demo/screen/DemoForm.java
2 parents 70ff734 + ad6870c commit b74bfa0

18 files changed

+1038
-606
lines changed

demo/src/main/java/io/asfjava/ui/demo/screen/DemoForm.java

+100-101
Original file line numberDiff line numberDiff line change
@@ -2,91 +2,93 @@
22

33
import java.io.Serializable;
44

5-
import io.asfjava.ui.core.form.Index;
5+
import io.asfjava.ui.core.form.CheckBox;
6+
import io.asfjava.ui.core.form.ComboBox;
7+
import io.asfjava.ui.core.form.Number;
68
import io.asfjava.ui.core.form.Password;
9+
import io.asfjava.ui.core.form.RadioBox;
10+
import io.asfjava.ui.core.form.Tab;
11+
import io.asfjava.ui.core.form.TextArea;
712
import io.asfjava.ui.core.form.TextField;
813

914
public class DemoForm implements Serializable {
1015

11-
@Index(3)
12-
@TextField(title = "Personal Website")
16+
17+
@TextField(title = "Pesonal Website",fieldAddonLeft="http://", description = "This is TextField with fieldAddonLeft")
1318
private String webSite;
14-
15-
@Index(2)
16-
@TextField(title = "Your Github Mail")
19+
20+
@TextField(title = "Your Github Mail",fieldAddonRight="@github.com", description = "This is TextField with fieldAddonRight")
1721
private String gitHub;
18-
19-
@Index(4)
20-
@Password(title = "Password")
22+
23+
// @Tab(title = "Contact", index = 2)
24+
@Password(title = "Password", placeHolder = "Please set you password", description = "This is password")
2125
private String password;
2226

23-
@Index(0)
24-
@TextField(title = "First Name")
27+
@Tab(title = "Info", index = 1)
28+
@TextField(title = "First Name", placeHolder = "Your first name", description = "This is a description for your first name field")
2529
private String firstName;
2630

27-
// @Tab(title = "Info", index = 1)
28-
// @TextField(title = "Last Name", placeHolder = "Your last name")
29-
// private String lastName;
30-
//
31-
// @Tab(title = "Contact", index = 2)
32-
// @TextField(title = "eMail", placeHolder = "Your email", pattern =
33-
// "^\\S+@\\S+$", validationMessage = "Your mail must be in this format
34-
// [email protected]", description = "This is Text Field with pattern and
35-
// validation message")
36-
// private String email;
37-
//
38-
// @Tab(title = "Additional Info", index = 3)
39-
// @Number(title = "Number of children", placeHolder = "Number of children",
40-
// description = "This is a number")
41-
// private Integer number;
42-
//
43-
//
44-
// @Tab(title = "Info", index = 1)
45-
// @ComboBox(title = "Gender", titleMap = GenderTitleMap.class)
46-
// private String gender;
47-
//
48-
//// @Tab(title = "Additional Info", index = 3)
49-
// @ComboBox(title = "Currency", values = { "euro", "dollar" })
50-
// private String currency;
51-
//
52-
// @Tab(title = "Additional Info", index = 3)
53-
// @RadioBox(title = "Civil State", titleMap = CivilStateTitelsMap.class)
54-
// private String civilState;
55-
//
56-
//// @Tab(title = "Contact", index = 2)
57-
// @TextArea(title = "Address", placeHolder = "Fill your address please",
58-
// description = "This is textarea")
59-
// private String address;
60-
61-
// @Tab(title = "Additional Info", index = 3)
62-
// @CheckBox(title = "Color", values = { "red", "bleu", "green" },
63-
// defaultvalue = "red")
64-
// private String color;
31+
// @Tab(title = "Info", index = 1)
32+
@TextField(title = "Last Name", placeHolder = "Your last name")
33+
private String lastName;
34+
35+
@Tab(title = "Contact", index = 2)
36+
@TextField(title = "eMail", placeHolder = "Your email", pattern = "^\\S+@\\S+$", validationMessage = "Your mail must be in this format [email protected]", description = "This is Text Field with pattern and validation message")
37+
private String email;
38+
39+
@Tab(title = "Additional Info", index = 3)
40+
@Number(title = "Number of children", placeHolder = "Number of children", description = "This is a number")
41+
private Integer number;
42+
43+
44+
@Tab(title = "Info", index = 1)
45+
@ComboBox(title = "Gender", titleMap = GenderTitleMap.class)
46+
private String gender;
47+
48+
// @Tab(title = "Additional Info", index = 3)
49+
@ComboBox(title = "Currency", values = { "euro", "dollar" })
50+
private String currency;
51+
52+
@Tab(title = "Additional Info", index = 3)
53+
@RadioBox(title = "Civil State", titleMap = CivilStateTitelsMap.class)
54+
private String civilState;
55+
56+
// @Tab(title = "Contact", index = 2)
57+
@TextArea(title = "Address", placeHolder = "Fill your address please", description = "This is textarea")
58+
private String address;
59+
60+
@Tab(title = "Additional Info", index = 3)
61+
@CheckBox(title = "Color", values = { "red", "bleu", "green" }, defaultvalue = "red")
62+
private String color;
63+
64+
public String getFirstName() {
65+
return firstName;
66+
}
6567

6668
public void setFirstName(String firstName) {
6769
this.firstName = firstName;
6870
}
6971

70-
// public String getLastName() {
71-
// return lastName;
72-
// }
73-
//
74-
// public void setEmail(String eMail) {
75-
// this.email = eMail;
76-
// }
77-
//
78-
// public String getEmail() {
79-
// return email;
80-
// }
72+
public String getLastName() {
73+
return lastName;
74+
}
8175

76+
public void setEmail(String eMail) {
77+
this.email = eMail;
78+
}
79+
80+
public String getEmail() {
81+
return email;
82+
}
83+
8284
public void setGitHub(String github) {
8385
this.gitHub = github;
8486
}
8587

8688
public String getGitHub() {
8789
return gitHub;
8890
}
89-
91+
9092
public void setWebSite(String website) {
9193
this.webSite = website;
9294
}
@@ -95,20 +97,17 @@ public String getWebSite() {
9597
return webSite;
9698
}
9799

98-
public String getFirstName() {
99-
return firstName;
100+
public void setLastName(String lastName) {
101+
this.lastName = lastName;
102+
}
103+
104+
public Integer getNumber() {
105+
return number;
106+
}
107+
108+
public void setNumber(Integer number) {
109+
this.number = number;
100110
}
101-
// public void setLastName(String lastName) {
102-
// this.lastName = lastName;
103-
// }
104-
//
105-
// public Integer getNumber() {
106-
// return number;
107-
// }
108-
//
109-
// public void setNumber(Integer number) {
110-
// this.number = number;
111-
// }
112111

113112
public String getPassword() {
114113
return password;
@@ -118,33 +117,33 @@ public void setPassword(String password) {
118117
this.password = password;
119118
}
120119

121-
// public String getGender() {
122-
// return gender;
123-
// }
124-
//
125-
// public String getAddress() {
126-
// return address;
127-
// }
128-
//
129-
// public void setAddress(String address) {
130-
// this.address = address;
131-
// }
132-
//
133-
// public String getCivilState() {
134-
// return civilState;
135-
// }
136-
//
137-
// public void setCivilState(String civilState) {
138-
// this.civilState = civilState;
139-
// }
140-
//
141-
// public String getCurrency() {
142-
// return currency;
143-
// }
144-
145-
// public String getColor() {
146-
// return color;
147-
// }
120+
public String getGender() {
121+
return gender;
122+
}
123+
124+
public String getAddress() {
125+
return address;
126+
}
127+
128+
public void setAddress(String address) {
129+
this.address = address;
130+
}
131+
132+
public String getCivilState() {
133+
return civilState;
134+
}
135+
136+
public void setCivilState(String civilState) {
137+
this.civilState = civilState;
138+
}
139+
140+
public String getCurrency() {
141+
return currency;
142+
}
143+
144+
public String getColor() {
145+
return color;
146+
}
148147

149148
private static final long serialVersionUID = -5073515619469444978L;
150149
}

pom.xml

+10
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3838
<maven.compiler.source>1.8</maven.compiler.source>
3939
<maven.compiler.target>1.8</maven.compiler.target>
40+
<runSuite>**/UiFormSchemaGeneratorTest.class</runSuite>
4041
</properties>
4142
<dependencies>
4243
<dependency>
@@ -77,6 +78,15 @@
7778
</dependencies>
7879
<build>
7980
<plugins>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-surefire-plugin</artifactId>
84+
<configuration>
85+
<includes>
86+
<include>${runSuite}</include>
87+
</includes>
88+
</configuration>
89+
</plugin>
8090
<plugin>
8191
<groupId>org.jacoco</groupId>
8292
<artifactId>jacoco-maven-plugin</artifactId>

src/main/java/io/asfjava/ui/core/form/Password.java

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515

1616
String description() default "";
1717

18+
int minLenght() default 0;
19+
20+
int maxLenght() default Integer.MAX_VALUE;
21+
22+
String pattern() default "";
23+
1824
String fieldAddonLeft() default"";
1925

2026
String fieldAddonRight() default"";

src/main/java/io/asfjava/ui/core/form/TextArea.java

+8
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@
1414
String placeHolder() default "";
1515

1616
String description() default "";
17+
18+
int minLenght() default 0;
19+
20+
int maxLenght() default Integer.MAX_VALUE;
21+
22+
String fieldAddonLeft() default"";
23+
24+
String fieldAddonRight() default"";
1725

1826
boolean noTitle() default false;
1927

src/main/java/io/asfjava/ui/core/form/TextField.java

+4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
String description() default "";
1717

18+
int minLenght() default 0;
19+
20+
int maxLenght() default Integer.MAX_VALUE;
21+
1822
String fieldAddonLeft() default"";
1923

2024
String fieldAddonRight() default"";

src/main/java/io/asfjava/ui/core/generators/TextAreaGenerator.java

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,16 @@ public void generate(ObjectNode fieldFormDefinition, Field field) {
1414
fieldFormDefinition.put("key", field.getName());
1515
fieldFormDefinition.put("type", "textarea");
1616

17+
String fieldAddonLeft = annotation.fieldAddonLeft();
18+
if (!fieldAddonLeft.isEmpty()) {
19+
fieldFormDefinition.put("fieldAddonLeft", fieldAddonLeft);
20+
}
21+
22+
String fieldAddonRight = annotation.fieldAddonRight();
23+
if (!fieldAddonRight.isEmpty()) {
24+
fieldFormDefinition.put("fieldAddonRight", fieldAddonRight);
25+
}
26+
1727
String description = annotation.description();
1828
if (!description.isEmpty()) {
1929
fieldFormDefinition.put("description", description);

src/main/java/io/asfjava/ui/core/schema/decorators/PasswordSchemaDecorator.java

+9
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
1414
if (annotation != null && annotation.title() != null) {
1515
((StringSchema) jsonschema).setTitle(annotation.title());
1616
}
17+
if (annotation.pattern() != null) {
18+
((StringSchema) jsonschema).setPattern(annotation.pattern());
19+
}
20+
if (annotation.minLenght() != 0) {
21+
((StringSchema) jsonschema).setMinLength(annotation.minLenght());
22+
}
23+
if (annotation.maxLenght() != Integer.MAX_VALUE) {
24+
((StringSchema) jsonschema).setMaxLength(annotation.maxLenght());
25+
}
1726
}
1827

1928
@Override

src/main/java/io/asfjava/ui/core/schema/decorators/TextAreaSchemaDecorator.java

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
1414
if (annotation != null && annotation.title() != null) {
1515
((StringSchema) jsonschema).setTitle(annotation.title());
1616
}
17+
18+
if (annotation.minLenght() != 0) {
19+
((StringSchema) jsonschema).setMinLength(annotation.minLenght());
20+
}
21+
if (annotation.maxLenght() != Integer.MAX_VALUE) {
22+
((StringSchema) jsonschema).setMaxLength(annotation.maxLenght());
23+
}
1724
}
1825

1926
@Override

src/main/java/io/asfjava/ui/core/schema/decorators/TextFieldSchemaDecorator.java

+6
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ public void customizeSchema(BeanProperty property, JsonSchema jsonschema) {
1818
if (annotation.pattern() != null) {
1919
((StringSchema) jsonschema).setPattern(annotation.pattern());
2020
}
21+
if (annotation.minLenght() != 0) {
22+
((StringSchema) jsonschema).setMinLength(annotation.minLenght());
23+
}
24+
if (annotation.maxLenght() != Integer.MAX_VALUE) {
25+
((StringSchema) jsonschema).setMaxLength(annotation.maxLenght());
26+
}
2127
}
2228
}
2329

0 commit comments

Comments
 (0)