[snow-cvs] r9 - in trunk: src/java/snow/example src/lisp/snow test/src/snow
Alessio Stalla
astalla at common-lisp.net
Tue Oct 20 22:09:46 UTC 2009
Author: astalla
Date: Tue Oct 20 18:09:45 2009
New Revision: 9
Log:
Added EL to example (no reader macro yet), updated binding test
Modified:
trunk/src/java/snow/example/SnowExample.java
trunk/src/java/snow/example/example.lisp
trunk/src/lisp/snow/data-binding.lisp
trunk/test/src/snow/BindingTest.java
Modified: trunk/src/java/snow/example/SnowExample.java
==============================================================================
--- trunk/src/java/snow/example/SnowExample.java (original)
+++ trunk/src/java/snow/example/SnowExample.java Tue Oct 20 18:09:45 2009
@@ -34,4 +34,13 @@
firePropertyChange("property1", oldValue, property1);
}
+ private SnowExample nested = null;
+
+ public SnowExample getNested() {
+ if(nested == null) {
+ nested = new SnowExample();
+ }
+ return nested;
+ }
+
}
Modified: trunk/src/java/snow/example/example.lisp
==============================================================================
--- trunk/src/java/snow/example/example.lisp (original)
+++ trunk/src/java/snow/example/example.lisp Tue Oct 20 18:09:45 2009
@@ -7,6 +7,9 @@
(defvar *object* (new "snow.example.SnowExample"))
(defvar *variable* (make-var "42"))
(defvar *cells-object* (make-instance 'my-model))
+(setq *bean-factory* #'(lambda (x) ;dummy
+ (declare (ignore x))
+ *object*))
(with-gui (:swing)
(let ((myframe
@@ -26,18 +29,35 @@
:layout (jfield "java.awt.BorderLayout" "EAST")))
(scroll ()
(panel ()
- (label :binding (make-bean-binding *object* "property1"))
- (label :binding (make-cells-binding (c? (aaa *cells-object*))))
- (label :binding (make-cells-binding (c? (bbb *cells-object*))))
- (label :binding (make-simple-binding *variable*))
+ (label :text "bean binding")
+ (label :binding (make-bean-data-binding *object* "property1")
+ :layout "wrap")
+ (label :text "EL binding")
+ (label :binding (make-el-data-binding "bean.nested.property1")
+ :layout "wrap")
+ (label :text "cells bindings: aaa and bbb")
+ (label :binding (make-cells-data-binding (c? (aaa *cells-object*))))
+ (label :binding (make-cells-data-binding (c? (bbb *cells-object*)))
+ :layout "wrap")
+ (label :text "simple binding to a variable")
+ (label :binding (make-simple-data-binding *variable*)
+ :layout "wrap")
(button :text "another one" :layout "wrap")
- (text-field :binding (make-bean-binding *object* "property1")
- :layout "growx")
+ (label :text "set property1")
+ (text-field :binding (make-bean-data-binding *object* "property1")
+ :layout "growx, wrap")
+ (label :text "set nested.property1")
+ (text-field :binding (make-el-data-binding "bean.nested.property1")
+ :layout "growx, wrap")
(button :text "Test!"
:layout "wrap"
:on-action (lambda (event)
(setf (jproperty-value *object* "property1")
"Test property")
+ (setf (jproperty-value
+ (jproperty-value *object* "nested")
+ "property1")
+ "Nested property")
(setf (var *variable*) "Test var")
(setf (aaa *cells-object*) "Test cell"))))))))
(pack myframe)))
@@ -49,13 +69,13 @@
:on-action (lambda (event)
(print "Hello, world!")
(print event)))
- (text-field :binding (make-bean-binding *object* "property1"))
+ (text-field :binding (make-bean-data-binding *object* "property1"))
(text-field :binding
- (make-cells-binding (c? (aaa *cells-object*))
+ (make-cells-data-binding (c? (aaa *cells-object*))
#'(lambda (x)
(setf (aaa *cells-object*) x))))
- (text-field :binding (make-slot-binding *cells-object* 'aaa))
- (text-field :binding (make-simple-binding *variable*)
+ (text-field :binding (make-slot-data-binding *cells-object* 'aaa))
+ (text-field :binding (make-simple-data-binding *variable*)
:layout "wrap")
(label :text "haha")
(panel (:layout-manager :mig :layout "grow")
Modified: trunk/src/lisp/snow/data-binding.lisp
==============================================================================
--- trunk/src/lisp/snow/data-binding.lisp (original)
+++ trunk/src/lisp/snow/data-binding.lisp Tue Oct 20 18:09:45 2009
@@ -133,14 +133,14 @@
(obj (funcall *bean-factory* (car splitted-expr)))
(path (cdr splitted-expr)))
(make-instance 'simple-data-binding
- :variable (make-bean-property-path-binding obj path))))
+ :variable (new "snow.binding.BeanPropertyPathBinding"
+ obj (apply #'jvector "java.lang.String" path)))))
-(defun make-bean-property-path-binding (object path)
- (new "snow.binding.BeanPropertyPathBinding"
- object (apply #'jvector "java.lang.String" path)))
+;(defun make-bean-property-path-data-binding (object path)
+;)
;;Default binding types
-(defun default-data-binding-types ()
+#|(defun default-data-binding-types ()
(let ((ht (make-hash-table)))
(setf (gethash :simple ht) 'simple-data-binding)
(setf (gethash :bean ht) 'bean-data-binding)
@@ -155,3 +155,4 @@
(defun make-data-binding (type &rest options)
(apply #'make-instance (get-data-binding-class type) options))
+|#
\ No newline at end of file
Modified: trunk/test/src/snow/BindingTest.java
==============================================================================
--- trunk/test/src/snow/BindingTest.java (original)
+++ trunk/test/src/snow/BindingTest.java Tue Oct 20 18:09:45 2009
@@ -68,12 +68,12 @@
});
bean.getBean().setProperty("value2");
if(flag[0]) {
- Assert.fail("value was set but listener didn't fire");
+ fail("value was set but listener didn't fire");
}
flag[0] = true;
bean.getBean().setProperty("value2");
if(!flag[0]) {
- Assert.fail("value was set to same value and listener fired");
+ fail("value was set to same value and listener fired");
}
model.setValue("42");
assertEquals("42", bean.getBean().getProperty());
More information about the snow-cvs
mailing list