Author: tchemit
Date: 2008-04-18 19:47:39 +0000 (Fri, 18 Apr 2008)
New Revision: 565
Added:
trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java
trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingListener.java
trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java
trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObject.java
trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java
trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/Util.java
Removed:
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/ComponentDescriptor.java
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingListener.java
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingUpdateListener.java
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java
trunk/lutinjaxx/core/src/main/java/jaxx/runtime/Util.java
Log:
no default provider default module runtime instead with nothing to provide :) )
core module provides default handler for Object.class
Deleted: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/ComponentDescriptor.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/ComponentDescriptor.java 2008-04-18 19:47:05 UTC (rev 564)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/ComponentDescriptor.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.runtime;
-
-import java.io.Serializable;
-
-public class ComponentDescriptor implements Serializable {
- String id;
- String javaClassName;
- String styleClass;
- ComponentDescriptor parent;
- private static final long serialVersionUID = 3001121176691770788L;
-
-
- public ComponentDescriptor(String id, String javaClassName, String styleClass, ComponentDescriptor parent) {
- this.id = id;
- this.javaClassName = javaClassName;
- this.styleClass = styleClass;
- this.parent = parent;
- }
-
-
- public String getId() {
- return id;
- }
-
-
- public String getJavaClassName() {
- return javaClassName;
- }
-
-
- public String getStyleClass() {
- return styleClass;
- }
-
-
- public ComponentDescriptor getParent() {
- return parent;
- }
-
-
- @Override
- public String toString() {
- return "ComponentDescriptor[" + id + ", " + javaClassName + ", " + styleClass + "]";
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingListener.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingListener.java 2008-04-18 19:47:05 UTC (rev 564)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingListener.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -1,46 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.runtime;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-
-/**
- * A <code>PropertyChangeListener</code> which processes a data binding when it receives a
- * <code>PropertyChangeEvent</code>.
- */
-public class DataBindingListener implements PropertyChangeListener {
- private JAXXObject object;
- private String dest;
-
- /**
- * Creates a new <code>DataBindingListener</code> which will run the given data binding
- * when it receives a <code>PropertyChangeEvent</code>.
- *
- * @param object the object in which the data binding exists
- * @param dest the name of the data binding to run
- */
- public DataBindingListener(JAXXObject object, String dest) {
- this.object = object;
- this.dest = dest;
- }
-
-
- /**
- * Processes the data binding in response to a <code>PropertyChangeEvent</code>.
- *
- * @param e the event which triggered the binding
- */
- public void propertyChange(PropertyChangeEvent e) {
- object.processDataBinding(dest);
-
- // for now, handle dependency changes by always removing & reapplying
- // the binding. We should be more efficient and only do this when it's
- // actually necessary
- object.removeDataBinding(dest);
- object.applyDataBinding(dest);
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingUpdateListener.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2008-04-18 19:47:05 UTC (rev 564)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -1,46 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.runtime;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-
-
-/**
- * A <code>PropertyChangeListener</code> which removes and re-applies a data binding
- * when it receives a <code>PropertyChangeEvent</code>.
- */
-public class DataBindingUpdateListener implements PropertyChangeListener {
- private JAXXObject object;
- private String dest;
-
- /**
- * Creates a new <code>DataBindingUpdateListener</code> which will remove and re-apply a
- * data binding when it receives a <code>PropertyChangeEvent</code>.
- *
- * @param object the object in which the data binding exists
- * @param dest the name of the data binding to reapply
- */
- public DataBindingUpdateListener(JAXXObject object, String dest) {
- this.object = object;
- this.dest = dest;
- }
-
-
- public String getBindingName() {
- return dest;
- }
-
-
- /**
- * Updates the data binding in response to a <code>PropertyChangeEvent</code>.
- *
- * @param e the event which triggered the binding
- */
- public void propertyChange(PropertyChangeEvent e) {
- object.removeDataBinding(dest);
- object.applyDataBinding(dest);
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java 2008-04-18 19:47:05 UTC (rev 564)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.runtime;
-
-/** The <code>JAXXObject</code> interface is implemented by all classes produced by the JAXX compiler. */
-public interface JAXXObject {
- /**
- * Retrieves an object defined in an XML tag by its ID.
- *
- * @param id the id of the component to retrieve
- * @return the object
- */
- public Object getObjectById(String id);
-
-
- public void applyDataBinding(String id);
-
-
- public void removeDataBinding(String id);
-
-
- /**
- * Processes a data binding by name. Data binding names are comprised of an object ID and a property name:
- * for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is
- * named <code>"label.text"</code>. Processing a data binding causes it to reevaluate its expression, in this
- * case <code>foo.getText()</code>.
- *
- * @param dest the name of the data binding to run
- */
- public void processDataBinding(String dest);
-
-
- /**
- * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
- * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime,
- * to trigger these events.
- *
- * @param name the name of the property which changed
- * @param oldValue the old value of the property
- * @param newValue the new value of the property
- */
- public void firePropertyChange(String name, Object oldValue, Object newValue);
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2008-04-18 19:47:05 UTC (rev 564)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -1,32 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.runtime;
-
-import jaxx.css.Stylesheet;
-
-import java.io.Serializable;
-
-public class JAXXObjectDescriptor implements Serializable {
- private ComponentDescriptor[] descriptors;
- private Stylesheet stylesheet;
- private static final long serialVersionUID = -1706159556633801154L;
-
-
- public JAXXObjectDescriptor(ComponentDescriptor[] descriptors,
- Stylesheet stylesheet) {
- this.descriptors = descriptors;
- this.stylesheet = stylesheet;
- }
-
-
- public ComponentDescriptor[] getComponentDescriptors() {
- return descriptors;
- }
-
-
- public Stylesheet getStylesheet() {
- return stylesheet;
- }
-}
\ No newline at end of file
Deleted: trunk/lutinjaxx/core/src/main/java/jaxx/runtime/Util.java
===================================================================
--- trunk/lutinjaxx/core/src/main/java/jaxx/runtime/Util.java 2008-04-18 19:47:05 UTC (rev 564)
+++ trunk/lutinjaxx/core/src/main/java/jaxx/runtime/Util.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -1,253 +0,0 @@
-package jaxx.runtime;
-
-import javax.swing.JComponent;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.EventListener;
-import java.util.zip.GZIPInputStream;
-
-public class Util {
- // Maps root objects to lists of event listeners
- private static Map<Object, WeakReference<List<EventListenerDescriptor>>> eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>();
- private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>();
-
-
- private static class EventListenerDescriptor {
- Class listenerClass;
- String listenerMethodName;
- String methodName;
- Object eventListener;
- }
-
-
- /**
- * Decodes the serialized representation of a JAXXObjectDescriptor. The string must be a byte-to-character mapping
- * of the binary serialization data for a JAXXObjectDescriptor. See the comments in JAXXCompiler.createJAXXObjectDescriptorField
- * for the rationale behind this (admittedly ugly) approach.
- *
- * @param descriptor descriptor to decode
- * @return the dedoced descriptor
- */
- public static JAXXObjectDescriptor decodeJAXXObjectDescriptor(String descriptor) {
- try {
- byte[] data = new byte[descriptor.length()];
- // copy low-order bytes into the array. The high-order bytes should all be zero.
- System.arraycopy(descriptor.getBytes(),0,data,0,data.length);
- //descriptor.getBytes(0, descriptor.length(), data, 0);
- ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
- return (JAXXObjectDescriptor) in.readObject();
- }
- catch (IOException e) {
- throw new RuntimeException("Internal error: can't-happen error", e);
- }
- catch (ClassNotFoundException e) {
- throw new RuntimeException("Internal error: can't-happen error", e);
- }
- }
-
-
- public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor(String descriptor) {
- try {
- byte[] data = new byte[descriptor.length()];
- // copy low-order bytes into the array. The high-order bytes should all be zero.
- System.arraycopy(descriptor.getBytes(),0,data,0,data.length);
- //descriptor.getBytes(0, descriptor.length(), data, 0);
- ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
- return (JAXXObjectDescriptor) in.readObject();
- }
- catch (IOException e) {
- throw new RuntimeException("Internal error: can't-happen error", e);
- }
- catch (ClassNotFoundException e) {
- throw new RuntimeException("Internal error: can't-happen error", e);
- }
- }
-
-
- public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) {
- WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer);
- List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null;
- if (descriptors == null) {
- descriptors = new ArrayList<EventListenerDescriptor>();
- eventListeners.put(methodContainer, new WeakReference<List<EventListenerDescriptor>>(descriptors));
- } else {
- for (EventListenerDescriptor descriptor : descriptors) {
- if (listenerClass == descriptor.listenerClass &&
- (listenerMethodName == null ? descriptor.listenerMethodName == null : listenerMethodName.equals(descriptor.listenerMethodName)) &&
- methodName.equals(descriptor.methodName)) {
- return descriptor.eventListener;
- }
- }
- }
-
- // else we need to create a new listener
- final EventListenerDescriptor descriptor = new EventListenerDescriptor();
- descriptor.listenerClass = listenerClass;
- descriptor.listenerMethodName = listenerMethodName;
- descriptor.methodName = methodName;
- try {
- final List<Method> listenerMethods = Arrays.asList(listenerClass.getMethods());
- Method listenerMethod = null;
- if (listenerMethodName != null) {
- for (Method listenerMethod1 : listenerMethods) {
- if ((listenerMethod1).getName().equals(listenerMethodName)) {
- listenerMethod = listenerMethod1;
- break;
- }
- }
- }
- if (listenerMethodName != null && listenerMethod == null)
- throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName());
- Class[] parameterTypes = listenerMethods.get(0).getParameterTypes();
- Class<?> methodContainerClass = methodContainer.getClass();
- final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes);
- descriptor.eventListener = Proxy.newProxyInstance(listenerClass.getClassLoader(),
- new Class[]{listenerClass},
- new InvocationHandler() {
- public Object invoke(Object proxy, Method method, Object[] args) {
- String methodName = method.getName();
- if ((listenerMethodName == null && listenerMethods.contains(method)) || methodName.equals(listenerMethodName)) {
- try {
- return targetMethod.invoke(methodContainer, args);
- }
- catch (IllegalAccessException e) {
- throw new RuntimeException(e);
- }
- catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
- if (methodName.equals("toString")) {
- return toString();
- }
- if (methodName.equals("equals")) {
- return descriptor.eventListener == args[0];
- }
- if (methodName.equals("hashCode")) {
- return hashCode();
- }
- return null;
- }
- });
- descriptors.add(descriptor);
- return descriptor.eventListener;
- }
- catch (NoSuchMethodException e) {
- throw new RuntimeException(e);
- }
- }
-
-
- public static Object getEventListener(Class<? extends EventListener> listenerClass, final Object methodContainer, final String methodName) {
- return getEventListener(listenerClass, null, methodContainer, methodName);
- }
-
-
- public static DataBindingUpdateListener getDataBindingUpdateListener(JAXXObject object, String bindingName) {
- WeakReference<List<DataBindingUpdateListener>> ref = dataBindingUpdateListeners.get(object);
- List<DataBindingUpdateListener> listeners = ref == null ? null : ref.get();
- if (listeners == null) {
- listeners = new ArrayList<DataBindingUpdateListener>();
- dataBindingUpdateListeners.put(object, new WeakReference<List<DataBindingUpdateListener>>(listeners));
- } else {
- for (DataBindingUpdateListener listener : listeners) {
- if (bindingName.equals(listener.getBindingName()))
- return listener;
- }
- }
- DataBindingUpdateListener listener = new DataBindingUpdateListener(object, bindingName);
- listeners.add(listener);
- return listener;
- }
-
-
- public static void setComponentWidth(Component component, int width) {
- component.setSize(width, component.getHeight());
- if (component instanceof JComponent) {
- JComponent jcomponent = (JComponent) component;
- jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height));
- jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height));
- if (jcomponent.isDisplayable())
- jcomponent.revalidate();
- }
- }
-
-
- public static void setComponentHeight(Component component, int height) {
- component.setSize(component.getWidth(), height);
- if (component instanceof JComponent) {
- JComponent jcomponent = (JComponent) component;
- jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height));
- jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height));
- if (jcomponent.isDisplayable())
- jcomponent.revalidate();
- }
- }
-
-
- public static boolean assignment(boolean value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static byte assignment(byte value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static short assignment(short value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static int assignment(int value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static long assignment(long value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static float assignment(float value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static double assignment(double value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static char assignment(char value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-
-
- public static java.lang.Object assignment(java.lang.Object value, String name, JAXXObject src) {
- src.firePropertyChange(name.trim(), null, "dummy value");
- return value;
- }
-}
Copied: trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java (from rev 560, trunk/lutinjaxx/core/src/main/java/jaxx/runtime/ComponentDescriptor.java)
===================================================================
--- trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java (rev 0)
+++ trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/ComponentDescriptor.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime;
+
+import java.io.Serializable;
+
+public class ComponentDescriptor implements Serializable {
+ String id;
+ String javaClassName;
+ String styleClass;
+ ComponentDescriptor parent;
+ private static final long serialVersionUID = 3001121176691770788L;
+
+
+ public ComponentDescriptor(String id, String javaClassName, String styleClass, ComponentDescriptor parent) {
+ this.id = id;
+ this.javaClassName = javaClassName;
+ this.styleClass = styleClass;
+ this.parent = parent;
+ }
+
+
+ public String getId() {
+ return id;
+ }
+
+
+ public String getJavaClassName() {
+ return javaClassName;
+ }
+
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+
+ public ComponentDescriptor getParent() {
+ return parent;
+ }
+
+
+ @Override
+ public String toString() {
+ return "ComponentDescriptor[" + id + ", " + javaClassName + ", " + styleClass + "]";
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingListener.java (from rev 560, trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingListener.java)
===================================================================
--- trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingListener.java (rev 0)
+++ trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+
+/**
+ * A <code>PropertyChangeListener</code> which processes a data binding when it receives a
+ * <code>PropertyChangeEvent</code>.
+ */
+public class DataBindingListener implements PropertyChangeListener {
+ private JAXXObject object;
+ private String dest;
+
+ /**
+ * Creates a new <code>DataBindingListener</code> which will run the given data binding
+ * when it receives a <code>PropertyChangeEvent</code>.
+ *
+ * @param object the object in which the data binding exists
+ * @param dest the name of the data binding to run
+ */
+ public DataBindingListener(JAXXObject object, String dest) {
+ this.object = object;
+ this.dest = dest;
+ }
+
+
+ /**
+ * Processes the data binding in response to a <code>PropertyChangeEvent</code>.
+ *
+ * @param e the event which triggered the binding
+ */
+ public void propertyChange(PropertyChangeEvent e) {
+ object.processDataBinding(dest);
+
+ // for now, handle dependency changes by always removing & reapplying
+ // the binding. We should be more efficient and only do this when it's
+ // actually necessary
+ object.removeDataBinding(dest);
+ object.applyDataBinding(dest);
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java (from rev 560, trunk/lutinjaxx/core/src/main/java/jaxx/runtime/DataBindingUpdateListener.java)
===================================================================
--- trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java (rev 0)
+++ trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+
+/**
+ * A <code>PropertyChangeListener</code> which removes and re-applies a data binding
+ * when it receives a <code>PropertyChangeEvent</code>.
+ */
+public class DataBindingUpdateListener implements PropertyChangeListener {
+ private JAXXObject object;
+ private String dest;
+
+ /**
+ * Creates a new <code>DataBindingUpdateListener</code> which will remove and re-apply a
+ * data binding when it receives a <code>PropertyChangeEvent</code>.
+ *
+ * @param object the object in which the data binding exists
+ * @param dest the name of the data binding to reapply
+ */
+ public DataBindingUpdateListener(JAXXObject object, String dest) {
+ this.object = object;
+ this.dest = dest;
+ }
+
+
+ public String getBindingName() {
+ return dest;
+ }
+
+
+ /**
+ * Updates the data binding in response to a <code>PropertyChangeEvent</code>.
+ *
+ * @param e the event which triggered the binding
+ */
+ public void propertyChange(PropertyChangeEvent e) {
+ object.removeDataBinding(dest);
+ object.applyDataBinding(dest);
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObject.java (from rev 560, trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObject.java)
===================================================================
--- trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObject.java (rev 0)
+++ trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObject.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime;
+
+/** The <code>JAXXObject</code> interface is implemented by all classes produced by the JAXX compiler. */
+public interface JAXXObject {
+ /**
+ * Retrieves an object defined in an XML tag by its ID.
+ *
+ * @param id the id of the component to retrieve
+ * @return the object
+ */
+ public Object getObjectById(String id);
+
+
+ public void applyDataBinding(String id);
+
+
+ public void removeDataBinding(String id);
+
+
+ /**
+ * Processes a data binding by name. Data binding names are comprised of an object ID and a property name:
+ * for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is
+ * named <code>"label.text"</code>. Processing a data binding causes it to reevaluate its expression, in this
+ * case <code>foo.getText()</code>.
+ *
+ * @param dest the name of the data binding to run
+ */
+ public void processDataBinding(String dest);
+
+
+ /**
+ * All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
+ * furthermore (for technical reasons) must allow code in outside packages, specifically the JAXX runtime,
+ * to trigger these events.
+ *
+ * @param name the name of the property which changed
+ * @param oldValue the old value of the property
+ * @param newValue the new value of the property
+ */
+ public void firePropertyChange(String name, Object oldValue, Object newValue);
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java (from rev 560, trunk/lutinjaxx/core/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java)
===================================================================
--- trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java (rev 0)
+++ trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime;
+
+import jaxx.css.Stylesheet;
+
+import java.io.Serializable;
+
+public class JAXXObjectDescriptor implements Serializable {
+ private ComponentDescriptor[] descriptors;
+ private Stylesheet stylesheet;
+ private static final long serialVersionUID = -1706159556633801154L;
+
+
+ public JAXXObjectDescriptor(ComponentDescriptor[] descriptors,
+ Stylesheet stylesheet) {
+ this.descriptors = descriptors;
+ this.stylesheet = stylesheet;
+ }
+
+
+ public ComponentDescriptor[] getComponentDescriptors() {
+ return descriptors;
+ }
+
+
+ public Stylesheet getStylesheet() {
+ return stylesheet;
+ }
+}
\ No newline at end of file
Copied: trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/Util.java (from rev 560, trunk/lutinjaxx/core/src/main/java/jaxx/runtime/Util.java)
===================================================================
--- trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/Util.java (rev 0)
+++ trunk/lutinjaxx/runtime/src/main/java/jaxx/runtime/Util.java 2008-04-18 19:47:39 UTC (rev 565)
@@ -0,0 +1,253 @@
+package jaxx.runtime;
+
+import javax.swing.JComponent;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.lang.ref.WeakReference;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+import java.util.EventListener;
+import java.util.zip.GZIPInputStream;
+
+public class Util {
+ // Maps root objects to lists of event listeners
+ private static Map<Object, WeakReference<List<EventListenerDescriptor>>> eventListeners = new WeakHashMap<Object, WeakReference<List<EventListenerDescriptor>>>();
+ private static Map<JAXXObject, WeakReference<List<DataBindingUpdateListener>>> dataBindingUpdateListeners = new WeakHashMap<JAXXObject, WeakReference<List<DataBindingUpdateListener>>>();
+
+
+ private static class EventListenerDescriptor {
+ Class listenerClass;
+ String listenerMethodName;
+ String methodName;
+ Object eventListener;
+ }
+
+
+ /**
+ * Decodes the serialized representation of a JAXXObjectDescriptor. The string must be a byte-to-character mapping
+ * of the binary serialization data for a JAXXObjectDescriptor. See the comments in JAXXCompiler.createJAXXObjectDescriptorField
+ * for the rationale behind this (admittedly ugly) approach.
+ *
+ * @param descriptor descriptor to decode
+ * @return the dedoced descriptor
+ */
+ public static JAXXObjectDescriptor decodeJAXXObjectDescriptor(String descriptor) {
+ try {
+ byte[] data = new byte[descriptor.length()];
+ // copy low-order bytes into the array. The high-order bytes should all be zero.
+ System.arraycopy(descriptor.getBytes(),0,data,0,data.length);
+ //descriptor.getBytes(0, descriptor.length(), data, 0);
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
+ return (JAXXObjectDescriptor) in.readObject();
+ }
+ catch (IOException e) {
+ throw new RuntimeException("Internal error: can't-happen error", e);
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException("Internal error: can't-happen error", e);
+ }
+ }
+
+
+ public static JAXXObjectDescriptor decodeCompressedJAXXObjectDescriptor(String descriptor) {
+ try {
+ byte[] data = new byte[descriptor.length()];
+ // copy low-order bytes into the array. The high-order bytes should all be zero.
+ System.arraycopy(descriptor.getBytes(),0,data,0,data.length);
+ //descriptor.getBytes(0, descriptor.length(), data, 0);
+ ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new ByteArrayInputStream(data)));
+ return (JAXXObjectDescriptor) in.readObject();
+ }
+ catch (IOException e) {
+ throw new RuntimeException("Internal error: can't-happen error", e);
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException("Internal error: can't-happen error", e);
+ }
+ }
+
+
+ public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) {
+ WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer);
+ List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null;
+ if (descriptors == null) {
+ descriptors = new ArrayList<EventListenerDescriptor>();
+ eventListeners.put(methodContainer, new WeakReference<List<EventListenerDescriptor>>(descriptors));
+ } else {
+ for (EventListenerDescriptor descriptor : descriptors) {
+ if (listenerClass == descriptor.listenerClass &&
+ (listenerMethodName == null ? descriptor.listenerMethodName == null : listenerMethodName.equals(descriptor.listenerMethodName)) &&
+ methodName.equals(descriptor.methodName)) {
+ return descriptor.eventListener;
+ }
+ }
+ }
+
+ // else we need to create a new listener
+ final EventListenerDescriptor descriptor = new EventListenerDescriptor();
+ descriptor.listenerClass = listenerClass;
+ descriptor.listenerMethodName = listenerMethodName;
+ descriptor.methodName = methodName;
+ try {
+ final List<Method> listenerMethods = Arrays.asList(listenerClass.getMethods());
+ Method listenerMethod = null;
+ if (listenerMethodName != null) {
+ for (Method listenerMethod1 : listenerMethods) {
+ if ((listenerMethod1).getName().equals(listenerMethodName)) {
+ listenerMethod = listenerMethod1;
+ break;
+ }
+ }
+ }
+ if (listenerMethodName != null && listenerMethod == null)
+ throw new IllegalArgumentException("no method named " + listenerMethodName + " found in class " + listenerClass.getName());
+ Class[] parameterTypes = listenerMethods.get(0).getParameterTypes();
+ Class<?> methodContainerClass = methodContainer.getClass();
+ final Method targetMethod = methodContainerClass.getMethod(methodName, parameterTypes);
+ descriptor.eventListener = Proxy.newProxyInstance(listenerClass.getClassLoader(),
+ new Class[]{listenerClass},
+ new InvocationHandler() {
+ public Object invoke(Object proxy, Method method, Object[] args) {
+ String methodName = method.getName();
+ if ((listenerMethodName == null && listenerMethods.contains(method)) || methodName.equals(listenerMethodName)) {
+ try {
+ return targetMethod.invoke(methodContainer, args);
+ }
+ catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ if (methodName.equals("toString")) {
+ return toString();
+ }
+ if (methodName.equals("equals")) {
+ return descriptor.eventListener == args[0];
+ }
+ if (methodName.equals("hashCode")) {
+ return hashCode();
+ }
+ return null;
+ }
+ });
+ descriptors.add(descriptor);
+ return descriptor.eventListener;
+ }
+ catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public static Object getEventListener(Class<? extends EventListener> listenerClass, final Object methodContainer, final String methodName) {
+ return getEventListener(listenerClass, null, methodContainer, methodName);
+ }
+
+
+ public static DataBindingUpdateListener getDataBindingUpdateListener(JAXXObject object, String bindingName) {
+ WeakReference<List<DataBindingUpdateListener>> ref = dataBindingUpdateListeners.get(object);
+ List<DataBindingUpdateListener> listeners = ref == null ? null : ref.get();
+ if (listeners == null) {
+ listeners = new ArrayList<DataBindingUpdateListener>();
+ dataBindingUpdateListeners.put(object, new WeakReference<List<DataBindingUpdateListener>>(listeners));
+ } else {
+ for (DataBindingUpdateListener listener : listeners) {
+ if (bindingName.equals(listener.getBindingName()))
+ return listener;
+ }
+ }
+ DataBindingUpdateListener listener = new DataBindingUpdateListener(object, bindingName);
+ listeners.add(listener);
+ return listener;
+ }
+
+
+ public static void setComponentWidth(Component component, int width) {
+ component.setSize(width, component.getHeight());
+ if (component instanceof JComponent) {
+ JComponent jcomponent = (JComponent) component;
+ jcomponent.setPreferredSize(new Dimension(width, jcomponent.getPreferredSize().height));
+ jcomponent.setMinimumSize(new Dimension(width, jcomponent.getPreferredSize().height));
+ if (jcomponent.isDisplayable())
+ jcomponent.revalidate();
+ }
+ }
+
+
+ public static void setComponentHeight(Component component, int height) {
+ component.setSize(component.getWidth(), height);
+ if (component instanceof JComponent) {
+ JComponent jcomponent = (JComponent) component;
+ jcomponent.setPreferredSize(new Dimension(jcomponent.getPreferredSize().width, height));
+ jcomponent.setMinimumSize(new Dimension(jcomponent.getPreferredSize().width, height));
+ if (jcomponent.isDisplayable())
+ jcomponent.revalidate();
+ }
+ }
+
+
+ public static boolean assignment(boolean value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static byte assignment(byte value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static short assignment(short value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static int assignment(int value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static long assignment(long value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static float assignment(float value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static double assignment(double value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static char assignment(char value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+
+
+ public static java.lang.Object assignment(java.lang.Object value, String name, JAXXObject src) {
+ src.firePropertyChange(name.trim(), null, "dummy value");
+ return value;
+ }
+}