Author: kmorin Date: 2009-05-15 14:01:35 +0000 (Fri, 15 May 2009) New Revision: 1405 Added: guix/trunk/guix-runtime/ guix/trunk/guix-runtime/pom.xml guix/trunk/guix-runtime/src/ guix/trunk/guix-runtime/src/main/ guix/trunk/guix-runtime/src/main/java/ guix/trunk/guix-runtime/src/main/java/org/ guix/trunk/guix-runtime/src/main/java/org/nuiton/ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java guix/trunk/guix-runtime/src/test/ guix/trunk/guix-runtime/src/test/java/ guix/trunk/guix-runtime/src/test/java/org/ guix/trunk/guix-runtime/src/test/java/org/nuiton/ guix/trunk/guix-runtime/src/test/java/org/nuiton/guix/ Log: Ajout du module (pas encore fonctionnel) guix-runtime Property changes on: guix/trunk/guix-runtime ___________________________________________________________________ Name: svn:ignore + target Added: guix/trunk/guix-runtime/pom.xml =================================================================== --- guix/trunk/guix-runtime/pom.xml (rev 0) +++ guix/trunk/guix-runtime/pom.xml 2009-05-15 14:01:35 UTC (rev 1405) @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project> + <modelVersion>4.0.0</modelVersion> + + <!-- ************************************************************* --> + <!-- *** POM Relationships *************************************** --> + <!-- ************************************************************* --> + <parent> + <groupId>org.nuiton.guix</groupId> + <artifactId>guix</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + + <artifactId>guix-runtime</artifactId> + + <!-- ************************************************************* --> + <!-- *** Project Information ************************************* --> + <!-- ************************************************************* --> + <name>guix-runtime</name> + <description>Guix runtime</description> + + <!-- ************************************************************* --> + <!-- *** Build Settings ****************************************** --> + <!-- ************************************************************* --> + + <packaging>jar</packaging> + + <!-- ************************************************************* --> + <!-- *** Build Environment ************************************** --> + <!-- ************************************************************* --> + <scm> + <connection>scm:svn:svn://anonymous@labs.libre-entreprise.org/svnroot/buix/guix/trunk/guix-runtime</connection> + <!--developerConnection>scm:svn:svn+ssh://sletellier@labs.libre-entreprise.org/svnroot/buix/guix/trunk</developerConnection--> + <!--url>http://labs.libre-entreprise.org/plugins/scmsvn/viewcvs.php/guix/trunk/?root=buix</url--> + </scm> +</project> \ No newline at end of file Added: guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java =================================================================== --- guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java (rev 0) +++ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingListener.java 2009-05-15 14:01:35 UTC (rev 1405) @@ -0,0 +1,42 @@ +package org.nuiton.guix; + +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 GuixObject 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(GuixObject 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 Added: guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java =================================================================== --- guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java (rev 0) +++ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/DataBindingUpdateListener.java 2009-05-15 14:01:35 UTC (rev 1405) @@ -0,0 +1,46 @@ +/* + * Copyright 2006 Ethan Nicholas. All rights reserved. + * Use is subject to license terms. + */ +package org.nuiton.guix; + +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 GuixObject 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(GuixObject 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 Added: guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java =================================================================== --- guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java (rev 0) +++ guix/trunk/guix-runtime/src/main/java/org/nuiton/guix/GuixObject.java 2009-05-15 14:01:35 UTC (rev 1405) @@ -0,0 +1,46 @@ +package org.nuiton.guix; + +/** The <code>GuixObject</code> interface is implemented by all classes produced by the Guix compiler. */ +public interface GuixObject { + /** + * 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); + + /** + * Pretrieves the dictonary of knwon objects indexed by their ids. + * + * @return the dictonary of objects. + */ + public java.util.Map<String, Object> get$objectMap(); + + 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>GuixObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and + * furthermore (for technical reasons) must allow code in outside packages, specifically the Guix 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