[snow-cvs] r45 - in trunk: src/lisp/snow/swing test/src/snow
Alessio Stalla
astalla at common-lisp.net
Mon Jan 18 21:51:07 UTC 2010
Author: astalla
Date: Mon Jan 18 16:51:06 2010
New Revision: 45
Log:
Fixed action listener creation with backing bean
Minimal test for backing bean support
Modified:
trunk/src/lisp/snow/swing/swing.lisp
trunk/test/src/snow/BindingTest.java
Modified: trunk/src/lisp/snow/swing/swing.lisp
==============================================================================
--- trunk/src/lisp/snow/swing/swing.lisp (original)
+++ trunk/src/lisp/snow/swing/swing.lisp Mon Jan 18 16:51:06 2010
@@ -49,7 +49,7 @@
(unless *backing-bean*
(error "No backing bean specified while action listener is a method name: ~A~%" obj))
(make-action-listener (jmethod (jclass-of *backing-bean*) obj
- (jclass "java.awt.ActionEvent"))))
+ (jclass "java.awt.event.ActionEvent"))))
((jinstance-of-p obj (jclass "java.lang.reflect.Method"))
(unless *backing-bean*
(error "No backing bean specified while action listener is a jmethod: ~A~%" obj))
Modified: trunk/test/src/snow/BindingTest.java
==============================================================================
--- trunk/test/src/snow/BindingTest.java (original)
+++ trunk/test/src/snow/BindingTest.java Mon Jan 18 16:51:06 2010
@@ -1,12 +1,8 @@
package snow;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
+import java.awt.event.*;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JTextField;
+import javax.swing.*;
import net.miginfocom.swing.MigLayout;
@@ -18,6 +14,7 @@
import com.jgoodies.binding.beans.PropertyAdapter;
import com.jgoodies.binding.value.ValueModel;
import java.beans.*;
+import java.io.*;
import snow.binding.*;
public class BindingTest {
@@ -50,7 +47,7 @@
frame.add(resetButton);
frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
frame.pack();
- frame.setVisible(true);
+ //frame.setVisible(true);
}
@Test
@@ -78,6 +75,31 @@
model.setValue("42");
assertEquals("42", bean.getBean().getProperty());
}
+
+ public static class BackingBean {
+ private JButton button;
+ public boolean buttonPressed = false;
+ public void setButtonProperty(JButton b) {
+ button = b;
+ }
+ public JButton getButtonProperty() {
+ return button;
+ }
+ public void buttonAction(ActionEvent e) {
+ buttonPressed = true;
+ }
+ }
+
+ @Test
+ public void testBackingBean() {
+ Snowlet s = Snow.getInterpretedSnowlet(new StringReader("(in-package :snow-user) (setq *debugger-hook* nil) (button :id button-property :on-action \"buttonAction\")"));
+ BackingBean b = new BackingBean();
+ s.setBackingBean(b);
+ Object result = s.eval();
+ assertEquals(result, b.getButtonProperty());
+ b.getButtonProperty().doClick();
+ assertTrue(b.buttonPressed);
+ }
public static void main(String[] args) {
new BindingTest().testBinding();
More information about the snow-cvs
mailing list