jacek99 / javabuilders Goto Github PK
View Code? Open in Web Editor NEWMax productivity with minimum code for Java desktop UI development
License: Other
Max productivity with minimum code for Java desktop UI development
License: Other
I've noticed that PropertyUtils only looks for properties that contain only a set Method. However, are there any plans in the future to support an immutable object? (Read-only)
Starting from Swing sample PersonApp, if you just add a simple int property to class PersonApp:
[PersonApp.java]
private int number;
public void setNumber(int number) {
this.number = number;
}
public int getNumber() {
return number;
}
[PersonApp.yml]
JFrame(name=frame, title=frame.title, size=packed, defaultCloseOperation=exitOnClose):
- JButton(name=save, text=button.save, onAction=[$validate,save,done])
- JButton(name=cancel, text=button.cancel, onAction=[$confirm,cancel])
- MigLayout: |
[pref] [grow,100] [pref] [grow,100]
"label.firstName" txtFirstName "label.lastName" txtLastName
"label.email" txtEmail+*
>save+*=1,cancel=1
- number: 1
bind:
- txtFirstName.text: person.firstName
- txtLastName.text: person.lastName
- txtEmail.text: person.emailAddress
validate:
- txtFirstName.text: {mandatory: true, label: label.firstName}
- txtLastName.text: {mandatory: true, label: label.lastName}
- txtEmail.text: {mandatory: true, emailAddress: true, label: label.email}
results in a NPE
Unable to process property PersonApp.number : null
java.lang.NullPointerException: null
at org.javabuilders.Builder.handleProperty(Builder.java:862)
at org.javabuilders.Builder.processDocumentNode(Builder.java:560)
at org.javabuilders.Builder.processDocumentNode(Builder.java:543)
at org.javabuilders.Builder.handleType(Builder.java:708)
at org.javabuilders.Builder.processDocumentNode(Builder.java:510)
at org.javabuilders.Builder.executeBuild(Builder.java:449)
at org.javabuilders.Builder.buildFromString(Builder.java:324)
at org.javabuilders.Builder.build(Builder.java:265)
at org.javabuilders.Builder.build(Builder.java:185)
at org.javabuilders.Builder.build(Builder.java:144)
at org.javabuilders.swing.SwingJavaBuilder.build(SwingJavaBuilder.java:89)
at person.app.PersonApp.<init>(PersonApp.java:47)
at person.app.PersonApp$1.run(PersonApp.java:98)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.lang.NullPointerException
at org.javabuilders.Builder.handleProperty(Builder.java:850)
... 26 more
changing Buider.java, lines 850 to (bold text) could resolve problem..:
String sValue = parent.getStringProperty(currentKey); if (sValue != null && sValue.matches(asValueHandler.getRegex())) { //replace the value from the file with the corresponding object instance parent.getProperties().put(currentKey, asValueHandler.getValue(process, parent, currentKey, parent.getProperty(currentKey))); } else { throw new BuildException("Invalid {0} value \"{1}\" for {2}.{3}. Must in be in \"{4}\" format, e.g. \"{5}\"", propertyType.getSimpleName(), sValue, parent.getMainObject().getClass().getSimpleName(), currentKey, asValueHandler.getRegex(), asValueHandler.getInputValueSample()); }
unfortunately, this does not solve the issue.. the subsequent exception is throws:
Invalid int value "null" for PersonApp.number. Must in be in "\d+|[a-zA-Z0-9_]+" format, e.g. "3 | SOME_CONSTANT_VALUE | someConstantValue"
at org.javabuilders.Builder.handleProperty(Builder.java:855)
... 26 more
My question at this point is, is it possible to use properties other than String in yml files, and assign them to java class?
I see that support for absolute layout is missing in the project.
In my case I would find it very useful in order to provide customers with a simple embedded swing editor in my application, oriented to only particular components (like SCADAs).
I think it would be enough to support a syntax for the Component#setLocation(Point p) or Component#setLocation(int x, int y) methods. All other stuffs are already working.. (more generally speaking, as you already support a special syntax for Dimension (like 800x600), a similar syntax should be fine for Point as well..).
In addition, Container#setLayout(null) must be called somewhere.. something like this:
JFrame(name=frame, title=frame.title, size=800x600, defaultCloseOperation=exitOnClose):
- AbsoluteLayout()
- JButton(name=button, text=button.acton, location=100;50)
(I don't know which char to use to separate x from y in location... ; should fit be maybe..)
what do you think about that?
Add stream API support so that we don't have to write custom methods for doing simple stuff.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.