changes to support databinding in FlexJS

Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/734f9bec
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/734f9bec
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/734f9bec

Branch: refs/heads/develop
Commit: 734f9bec02c81034eb39d85bff4595bc3870e0b5
Parents: 8611dcb
Author: Alex Harui <aha...@apache.org>
Authored: Sat Jun 22 07:21:08 2013 -0700
Committer: Alex Harui <aha...@apache.org>
Committed: Mon Jun 24 22:53:18 2013 -0700

----------------------------------------------------------------------
 .../flex/compiler/config/Configuration.java     | 122 +++++++++-
 .../internal/as/codegen/BindableHelper.java     |  14 +-
 .../as/codegen/MXMLClassDirectiveProcessor.java |  34 ++-
 .../databinding/MXMLBindingDirectiveHelper.java | 226 +++++++++++++++++++
 .../projects/FlexProjectConfigurator.java       |  45 ++++
 5 files changed, 424 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/734f9bec/compiler/src/org/apache/flex/compiler/config/Configuration.java
----------------------------------------------------------------------
diff --git a/compiler/src/org/apache/flex/compiler/config/Configuration.java 
b/compiler/src/org/apache/flex/compiler/config/Configuration.java
index 6cbb8a7..b8afa21 100644
--- a/compiler/src/org/apache/flex/compiler/config/Configuration.java
+++ b/compiler/src/org/apache/flex/compiler/config/Configuration.java
@@ -1551,7 +1551,127 @@ public class Configuration
         allowSourcePathOverlap = b;
     }
 
-/**
+    //
+    // 'compiler.binding-value-change-event' option
+    //
+
+    private String bindingValueChangeEvent = "mx.events.PropertyChangeEvent";
+
+    public String getBindingValueChangeEvent()
+    {
+        return bindingValueChangeEvent;
+    }
+
+    /**
+     * The change event class for generated binding code
+     */
+    @Config(advanced = true)
+    public void setCompilerBindingValueChangeEvent(ConfigurationValue cv, 
String b)
+    {
+        bindingValueChangeEvent = b;
+    }
+
+    //
+    // 'compiler.binding-value-change-event-kind' option
+    //
+
+    private String bindingValueChangeEventKind = 
"mx.events.PropertyChangeEventKind";
+
+    public String getBindingValueChangeEventKind()
+    {
+        return bindingValueChangeEventKind;
+    }
+
+    /**
+     * The change event kind for generated binding code
+     */
+    @Config(advanced = true)
+    public void setCompilerBindingValueChangeEventKind(ConfigurationValue cv, 
String b)
+    {
+        bindingValueChangeEventKind = b;
+    }
+
+    //
+    // 'compiler.binding-value-change-event-type' option
+    //
+
+    private String bindingValueChangeEventType = "propertyChange";
+
+    public String getBindingValueChangeEventType()
+    {
+        return bindingValueChangeEventType;
+    }
+
+    /**
+     * The change event type for generated binding code
+     */
+    @Config(advanced = true)
+    public void setCompilerBindingValueChangeEventType(ConfigurationValue cv, 
String b)
+    {
+        bindingValueChangeEventType = b;
+    }
+
+    //
+    // 'compiler.binding-event-handler-event' option
+    //
+
+    private String bindingEventHandlerEvent = "flash.events.Event";
+
+    public String getBindingEventHandlerEvent()
+    {
+        return bindingEventHandlerEvent;
+    }
+
+    /**
+     * The event handler event for generated binding code
+     */
+    @Config(advanced = true)
+    public void setCompilerBindingEventHandlerEvent(ConfigurationValue cv, 
String b)
+    {
+        bindingEventHandlerEvent = b;
+    }
+
+    //
+    // 'compiler.binding-event-handler-class' option
+    //
+
+    private String bindingEventHandlerClass = "flash.events.EventDispatcher";
+
+    public String getBindingEventHandlerClass()
+    {
+        return bindingEventHandlerClass;
+    }
+
+    /**
+     * The event handler class for generated binding code
+     */
+    @Config(advanced = true)
+    public void setCompilerBindingEventHandlerClass(ConfigurationValue cv, 
String b)
+    {
+        bindingEventHandlerClass = b;
+    }
+    
+    //
+    // 'compiler.binding-event-handler-interface' option
+    //
+
+    private String bindingEventHandlerInterface = 
"flash.events.IEventDispatcher";
+
+    public String getBindingEventHandlerInterface()
+    {
+        return bindingEventHandlerInterface;
+    }
+
+    /**
+     * The event handler interface for generated binding code
+     */
+    @Config(advanced = true)
+    public void setCompilerBindingEventHandlerInterface(ConfigurationValue cv, 
String b)
+    {
+        bindingEventHandlerInterface = b;
+    }
+    
+    /**
      * Syntax:<br/>
      * <code>-define=&lt;name&gt;,&lt;value&gt;</code>
      * where name is <code>NAMESPACE::name</code> and value is a legal 
definition value

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/734f9bec/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java 
b/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
index 67a33b4..21f5bda 100644
--- 
a/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
+++ 
b/compiler/src/org/apache/flex/compiler/internal/as/codegen/BindableHelper.java
@@ -528,13 +528,13 @@ public class BindableHelper
     /**
      * The mx.events package namespace
      */
-    private static final Namespace NAMESPACE_MX_EVENTS = new 
Namespace(CONSTANT_PackageNs, "mx.events");
+    public static Namespace NAMESPACE_MX_EVENTS = new 
Namespace(CONSTANT_PackageNs, "mx.events");
 
     //
     // Following Names are constants to use for various types & properties 
used in the code generated for Bindable
     //
-    private static final Name NAME_PROPERTY_CHANGE_EVENT = new 
Name(CONSTANT_Qname, new Nsset(NAMESPACE_MX_EVENTS), "PropertyChangeEvent");
-    private static final Name NAME_PROPERTY_CHANGE_EVENT_KIND = new 
Name(CONSTANT_Qname, new Nsset(NAMESPACE_MX_EVENTS), "PropertyChangeEventKind");
+    public static Name NAME_PROPERTY_CHANGE_EVENT = new Name(CONSTANT_Qname, 
new Nsset(NAMESPACE_MX_EVENTS), "PropertyChangeEvent");
+    public static Name NAME_PROPERTY_CHANGE_EVENT_KIND = new 
Name(CONSTANT_Qname, new Nsset(NAMESPACE_MX_EVENTS), "PropertyChangeEventKind");
     private static final Name NAME_CREATE_UPDATE_EVENT = new 
Name("createUpdateEvent");
 
     private static final Name NAME_STRING = new 
Name(IASLanguageConstants.String);
@@ -544,17 +544,17 @@ public class BindableHelper
     private static final Name NAME_VOID = new Name(IASLanguageConstants.void_);
 
 
-    private static final Name NAME_EVENT = new Name(CONSTANT_Qname, new 
Nsset(new Namespace(CONSTANT_PackageNs, "flash.events")), "Event");
+    public static Name NAME_EVENT = new Name(CONSTANT_Qname, new Nsset(new 
Namespace(CONSTANT_PackageNs, "flash.events")), "Event");
     private static final Name NAME_ADDEVENT_LISTENER = new 
Name("addEventListener");
     private static final Name NAME_DISPATCH_EVENT = new Name("dispatchEvent");
     private static final Name NAME_HAS_EVENT_LISTENER = new 
Name("hasEventListener");
     private static final Name NAME_REMOVE_EVENT_LISTENER = new 
Name("removeEventListener");
     private static final Name NAME_WILL_TRIGGER = new Name("willTrigger");
-    private static final Name NAME_EVENT_DISPATCHER = new Name(CONSTANT_Qname, 
new Nsset(new Namespace(CONSTANT_PackageNs, "flash.events")), 
"EventDispatcher");
-    private static final Name NAME_IEVENT_DISPATCHER = new 
Name(CONSTANT_Qname, new Nsset(new Namespace(CONSTANT_PackageNs, 
"flash.events")), "IEventDispatcher");
+    public static Name NAME_EVENT_DISPATCHER = new Name(CONSTANT_Qname, new 
Nsset(new Namespace(CONSTANT_PackageNs, "flash.events")), "EventDispatcher");
+    public static Name NAME_IEVENT_DISPATCHER = new Name(CONSTANT_Qname, new 
Nsset(new Namespace(CONSTANT_PackageNs, "flash.events")), "IEventDispatcher");
     private static final Name NAME_BINDING_EVENT_DISPATCHER = new 
Name(CONSTANT_Qname, new Nsset(bindablePrivateNamespace), 
"_bindingEventDispatcher");
     private static final Name NAME_STATIC_EVENT_DISPATCHER = new 
Name("staticEventDispatcher");
 
-    private static final String PROPERTY_CHANGE = "propertyChange";
+    public static String PROPERTY_CHANGE = "propertyChange";
 
 }

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/734f9bec/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
 
b/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
index 88773a5..708376a 100644
--- 
a/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
+++ 
b/compiler/src/org/apache/flex/compiler/internal/as/codegen/MXMLClassDirectiveProcessor.java
@@ -3245,6 +3245,7 @@ public class MXMLClassDirectiveProcessor extends 
ClassDirectiveProcessor
                                 
                 context.stopUsing(IL.PROPERTIES, 1);
                                 
+                context.isStateDescriptor = false;
             }
             else if (propertyName.equals("model"))
             {
@@ -3274,15 +3275,26 @@ public class MXMLClassDirectiveProcessor extends 
ClassDirectiveProcessor
             }
             else
             {
-                context.startUsing(IL.PROPERTIES);
-                
-                context.addInstruction(OP_pushstring, propertyName);
-                
-                context.isContentFactory = false;
-                
-                traverse(propertyNode, context);
-                
-                context.stopUsing(IL.PROPERTIES, 1);
+                if (!isDataboundProp(propertyNode))
+                {
+                    context.startUsing(IL.PROPERTIES);
+                    
+                    context.addInstruction(OP_pushstring, propertyName);
+                    
+                    context.isContentFactory = false;
+                    
+                    traverse(propertyNode, context);
+                    
+                    context.stopUsing(IL.PROPERTIES, 1);
+                }
+                else
+                {
+                    IMXMLInstanceNode instanceNode = 
propertyNode.getInstanceNode();
+                    if (instanceNode instanceof IMXMLSingleDataBindingNode)
+                        
processMXMLDataBinding((IMXMLSingleDataBindingNode)instanceNode, context);
+                    else if (instanceNode instanceof 
IMXMLConcatenatedDataBindingNode)
+                        
processMXMLConcatenatedDataBinding((IMXMLConcatenatedDataBindingNode)instanceNode,
 context);
+                }
             }
             return;
         }
@@ -3889,6 +3901,10 @@ public class MXMLClassDirectiveProcessor extends 
ClassDirectiveProcessor
                 context.parentContext.incrementCounter(IL.MXML_STATES_ARRAY, 
numElements);
             }
         }
+        if (getProject().getTargetSettings().getMxmlChildrenAsData())
+        {
+            context.isStateDescriptor = false;
+        }
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/734f9bec/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
 
b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
index 488f475..daee6d5 100644
--- 
a/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
+++ 
b/compiler/src/org/apache/flex/compiler/internal/codegen/databinding/MXMLBindingDirectiveHelper.java
@@ -21,6 +21,7 @@ package org.apache.flex.compiler.internal.codegen.databinding;
 
 import static org.apache.flex.abc.ABCConstants.*;
 
+import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
@@ -39,7 +40,12 @@ import 
org.apache.flex.compiler.internal.as.codegen.MXMLClassDirectiveProcessor;
 import 
org.apache.flex.compiler.internal.codegen.databinding.WatcherInfoBase.WatcherType;
 import org.apache.flex.compiler.internal.projects.FlexProject;
 import org.apache.flex.compiler.internal.scopes.ASScope;
+import org.apache.flex.compiler.internal.tree.as.FunctionCallNode;
+import org.apache.flex.compiler.internal.tree.as.IdentifierNode;
+import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode;
 import org.apache.flex.compiler.mxml.IMXMLTypeConstants;
+import org.apache.flex.compiler.tree.as.IASNode;
+import org.apache.flex.compiler.tree.as.IExpressionNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLBindingNode;
 import org.apache.flex.compiler.tree.mxml.IMXMLDataBindingNode;
 import org.apache.flex.compiler.workspaces.IWorkspace;
@@ -140,6 +146,9 @@ public class MXMLBindingDirectiveHelper
         // Just comment it out before checking
         //System.out.println("db: " + bindingDataBase);
         
+        if (host.getProject().getTargetSettings().getMxmlChildrenAsData())
+            return outputBindingInfoAsData();
+        
         InstructionList ret = new InstructionList();
         
         makeSpecialMemberVariablesForBinding();
@@ -155,6 +164,223 @@ public class MXMLBindingDirectiveHelper
         return ret;
     }
     
+    private InstructionList outputBindingInfoAsData()
+    {
+        host.addVariableTrait(IMXMLTypeConstants.NAME_BINDINGS, 
NAME_ARRAYTYPE);
+
+        InstructionList ret = new InstructionList();
+        int propertyCount = 0;
+        
+        Set<BindingInfo> bindingInfo = bindingDataBase.getBindingInfo();
+        ret.pushNumericConstant(bindingInfo.size()); // number of bindings
+        propertyCount++;
+        
+        for (BindingInfo bi : bindingInfo)
+        {
+            String s;
+            s = bi.getSourceString();
+            if (s == null)
+                s = 
getSourceStringFromGetter(bi.getExpressionNodesForGetter());
+            if (s.contains("."))
+            {
+                String[] parts = s.split("\\.");
+                for (String part : parts)
+                    ret.addInstruction(OP_pushstring, part);
+                ret.addInstruction(OP_newarray, parts.length);
+            }
+            else
+                ret.addInstruction(OP_pushstring, s);
+            
+            s = bi.getDestinationString();
+            if (s.contains("."))
+            {
+                String[] parts = s.split("\\.");
+                for (String part : parts)
+                    ret.addInstruction(OP_pushstring, part);
+                ret.addInstruction(OP_newarray, parts.length);
+            }
+            else
+                ret.addInstruction(OP_pushstring, s);
+            propertyCount += 2;
+        }
+        Set<Entry<Object, WatcherInfoBase>> watcherChains = 
bindingDataBase.getWatcherChains();
+        for (Entry<Object, WatcherInfoBase> entry : watcherChains)
+        {
+            WatcherInfoBase watcherInfoBase = entry.getValue();
+            propertyCount += encodeWatcher(ret, watcherInfoBase);
+        }
+        ret.addInstruction(OP_newarray,  propertyCount); 
+        // now save array to _bindings property
+        ret.addInstruction(OP_getlocal0);
+        // stack : this, bindings
+        ret.addInstruction(OP_swap);
+        // stack : bindings, this
+        ret.addInstruction(OP_setproperty, IMXMLTypeConstants.NAME_BINDINGS);
+
+        return ret;
+    }
+
+    private int encodeWatcher(InstructionList ret, WatcherInfoBase 
watcherInfoBase)
+    {
+        ret.pushNumericConstant(watcherInfoBase.getIndex());
+        WatcherType type = watcherInfoBase.getType();
+        int propertyCount = 1;            
+        if (type == WatcherType.FUNCTION)
+        {
+            ret.pushNumericConstant(0);
+
+            FunctionWatcherInfo functionWatcherInfo = 
(FunctionWatcherInfo)watcherInfoBase;
+           
+            ret.addInstruction(OP_pushstring, 
functionWatcherInfo.getFunctionName());
+            outputEventNames(ret, functionWatcherInfo.getEventNames());
+            outputBindings(ret, functionWatcherInfo.getBindings());
+            propertyCount += 4;
+        }
+        else if ((type == WatcherType.STATIC_PROPERTY) || (type == 
WatcherType.PROPERTY))
+        {
+            ret.pushNumericConstant(type == WatcherType.STATIC_PROPERTY ? 1 : 
2);
+
+            PropertyWatcherInfo propertyWatcherInfo = 
(PropertyWatcherInfo)watcherInfoBase;
+           
+            boolean makeStaticWatcher = (watcherInfoBase.getType() == 
WatcherType.STATIC_PROPERTY);
+            
+            // round up the getter function for the watcher, or null if we 
don't need one
+            MethodInfo propertyGetterFunction = null;
+            if (watcherInfoBase.isRoot && !makeStaticWatcher)
+            {
+                propertyGetterFunction = this.propertyGetter;
+                assert propertyGetterFunction != null;
+            }
+            else if (watcherInfoBase.isRoot && makeStaticWatcher)
+            {
+                 // TOTO: implement getter func for static watcher.
+            }
+            ret.addInstruction(OP_pushstring, 
propertyWatcherInfo.getPropertyName());
+            outputEventNames(ret, propertyWatcherInfo.getEventNames());
+            outputBindings(ret, propertyWatcherInfo.getBindings());
+            if (propertyGetterFunction == null)
+                ret.addInstruction(OP_pushnull);            // null is valid
+            else 
+                ret.addInstruction(OP_newfunction, propertyGetterFunction);
+            propertyCount += 5;
+        }
+        else if (type == WatcherType.XML)
+        {
+            ret.pushNumericConstant(3);
+
+            XMLWatcherInfo xmlWatcherInfo = (XMLWatcherInfo)watcherInfoBase;
+            ret.addInstruction(OP_pushstring, 
xmlWatcherInfo.getPropertyName());
+            outputBindings(ret, xmlWatcherInfo.getBindings());
+            propertyCount += 3;
+        }
+        else assert false;     
+
+        // then recurse into children
+        Set<Entry<Object, WatcherInfoBase>> children = 
watcherInfoBase.getChildren();
+        if (children != null)
+        {
+            int childCount = 0;
+            for ( Entry<Object, WatcherInfoBase> ent : children)
+            {
+                childCount += encodeWatcher(ret, ent.getValue());
+            }
+            ret.addInstruction(OP_newarray, childCount);
+            propertyCount++;
+        }
+        else
+        {
+            ret.addInstruction(OP_pushnull);
+            propertyCount++;
+        }
+
+        return propertyCount;
+    }
+    
+    private String 
getSourceStringFromMemberAccessExpressionNode(MemberAccessExpressionNode node)
+    {
+        String s = "";
+        
+        IExpressionNode left = node.getLeftOperandNode();
+        if (left instanceof FunctionCallNode) //  probably a cast
+        {
+            IASNode child = 
((FunctionCallNode)left).getArgumentsNode().getChild(0);
+            if (child instanceof IdentifierNode)
+                s = getSourceStringFromIdentifierNode((IdentifierNode)child);
+            else if (child instanceof MemberAccessExpressionNode)
+                s = 
getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)child);
+        }
+        else if (left instanceof MemberAccessExpressionNode)
+            s = 
getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)left);
+        else if (left instanceof IdentifierNode)
+            s = getSourceStringFromIdentifierNode((IdentifierNode)left);
+        else
+            System.out.println("expected binding member access left node" + 
node.toString());
+        s += ".";
+        
+        IExpressionNode right = node.getRightOperandNode();
+        if (right instanceof FunctionCallNode) //  probably a cast
+        {
+            IASNode child = 
((FunctionCallNode)right).getArgumentsNode().getChild(0);
+            if (child instanceof IdentifierNode)
+                s += getSourceStringFromIdentifierNode((IdentifierNode)child);
+            else if (child instanceof MemberAccessExpressionNode)
+                s += 
getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)child);
+        }
+        else if (right instanceof MemberAccessExpressionNode)
+            s += 
getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)right);
+        else if (right instanceof IdentifierNode)
+            s += getSourceStringFromIdentifierNode((IdentifierNode)right);
+        else
+            System.out.println("expected binding member access right node" + 
node.toString());
+        
+        return s;
+    }
+    
+    private String getSourceStringFromIdentifierNode(IdentifierNode node)
+    {
+        return node.getName();
+    }
+    
+    private String getSourceStringFromGetter(List<IExpressionNode> nodes)
+    {
+        String s = "";
+        IExpressionNode node = nodes.get(0);
+        if (node instanceof MemberAccessExpressionNode)
+        {
+            s = 
getSourceStringFromMemberAccessExpressionNode((MemberAccessExpressionNode)node);
+        }
+        return s;
+    }
+    
+    private void outputEventNames(InstructionList ret, List<String> events)
+    {
+        if (events.size() > 1)
+        {
+            for (String event : events)
+                ret.addInstruction(OP_pushstring, event);
+            ret.addInstruction(OP_newarray, events.size());
+        }
+        else if (events.size() == 1)
+            ret.addInstruction(OP_pushstring, events.get(0));
+        else
+            ret.addInstruction(OP_pushnull);
+    }
+    
+    private void outputBindings(InstructionList ret, List<BindingInfo> 
bindings)
+    {
+        if (bindings.size() > 1)
+        {
+            for (BindingInfo binding : bindings)
+                ret.pushNumericConstant(binding.getIndex());
+            ret.addInstruction(OP_newarray, bindings.size());
+        }
+        else if (bindings.size() == 1)
+            ret.pushNumericConstant(bindings.get(0).getIndex());
+        else
+            ret.addInstruction(OP_pushnull);
+        
+    }
+    
     /**
      * Generates all the Binding objects, and and "getter" functions required 
to implement them
      * puts Binding into this._bindings

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/734f9bec/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
----------------------------------------------------------------------
diff --git 
a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
 
b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
index ad04252..1c247f2 100644
--- 
a/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
+++ 
b/compiler/src/org/apache/flex/compiler/internal/projects/FlexProjectConfigurator.java
@@ -19,10 +19,17 @@
 
 package org.apache.flex.compiler.internal.projects;
 
+import static org.apache.flex.abc.ABCConstants.CONSTANT_PackageNs;
+import static org.apache.flex.abc.ABCConstants.CONSTANT_Qname;
+
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.flex.abc.semantics.Name;
+import org.apache.flex.abc.semantics.Namespace;
+import org.apache.flex.abc.semantics.Nsset;
 import org.apache.flex.compiler.config.Configuration;
+import org.apache.flex.compiler.internal.as.codegen.BindableHelper;
 import org.apache.flex.compiler.mxml.IMXMLTypeConstants;
 
 /**
@@ -170,5 +177,43 @@ public class FlexProjectConfigurator
         project.setRepeaterClass(IMXMLTypeConstants.Repeater);
         
         project.setNamedColors(NAMED_COLORS);
+        
+        if (configuration != null)
+        {
+            String configValue = configuration.getBindingEventHandlerEvent();
+            int dotIndex;
+            dotIndex = configValue.lastIndexOf(".");
+            String packageName = configValue.substring(0, dotIndex - 1);
+            String className = configValue.substring(dotIndex + 1);
+            BindableHelper.NAME_EVENT = new Name(CONSTANT_Qname, new Nsset(new 
Namespace(CONSTANT_PackageNs, packageName)), className);
+            
+            configValue = configuration.getBindingEventHandlerClass();
+            dotIndex = configValue.lastIndexOf(".");
+            packageName = configValue.substring(0, dotIndex - 1);
+            className = configValue.substring(dotIndex + 1);
+            BindableHelper.NAME_EVENT_DISPATCHER = new Name(CONSTANT_Qname, 
new Nsset(new Namespace(CONSTANT_PackageNs, packageName)), className);
+    
+            configValue = configuration.getBindingEventHandlerInterface();
+            dotIndex = configValue.lastIndexOf(".");
+            packageName = configValue.substring(0, dotIndex - 1);
+            className = configValue.substring(dotIndex + 1);
+            BindableHelper.NAME_IEVENT_DISPATCHER = new Name(CONSTANT_Qname, 
new Nsset(new Namespace(CONSTANT_PackageNs, packageName)), className);
+    
+            configValue = configuration.getBindingValueChangeEvent();
+            dotIndex = configValue.lastIndexOf(".");
+            packageName = configValue.substring(0, dotIndex - 1);
+            className = configValue.substring(dotIndex + 1);
+            BindableHelper.NAME_PROPERTY_CHANGE_EVENT = new 
Name(CONSTANT_Qname, new Nsset(new Namespace(CONSTANT_PackageNs, packageName)), 
className);
+            BindableHelper.NAMESPACE_MX_EVENTS = new 
Namespace(CONSTANT_PackageNs, packageName);
+            
+            configValue = configuration.getBindingValueChangeEventKind();
+            dotIndex = configValue.lastIndexOf(".");
+            packageName = configValue.substring(0, dotIndex - 1);
+            className = configValue.substring(dotIndex + 1);
+            BindableHelper.NAME_PROPERTY_CHANGE_EVENT_KIND = new 
Name(CONSTANT_Qname, new Nsset(new Namespace(CONSTANT_PackageNs, packageName)), 
className);
+        
+            configValue = configuration.getBindingValueChangeEventType();
+            BindableHelper.PROPERTY_CHANGE = configValue;
+        }
     }
 }

Reply via email to