Updated Branches:
refs/heads/develop eb3bcdb05 -> 457e2db51
Added IFactory and ClassFactory. Added itemRenderer property to List component.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/74b671af
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/74b671af
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/74b671af
Branch: refs/heads/develop
Commit: 74b671af714fc5a548cc0913166f606e4ff62073
Parents: eb3bcdb
Author: Peter Ent <pent@apache.org>
Authored: Wed Jan 8 14:06:30 2014 -0500
Committer: Peter Ent <pent@apache.org>
Committed: Wed Jan 8 14:06:30 2014 -0500
----------------------------------------------------------------------
.../as/projects/FlexJSUI/src/FlexJSUIClasses.as | 1 +
.../FlexJSUI/src/mx/core/ClassFactory.as | 47 ++++++++++++++++++++
.../projects/FlexJSUI/src/mx/core/IFactory.as | 25 +++++++++++
.../flex/core/ItemRendererClassFactory.as | 23 ++++++++--
.../org/apache/flex/html/staticControls/List.as | 12 +++++
.../js/FlexJS/src/mx/core/ClassFactory.js | 47 ++++++++++++++++++++
frameworks/js/FlexJS/src/mx/core/IFactory.js | 45 +++++++++++++++++++
7 files changed, 196 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
index 829c091..22fa85d 100644
--- a/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
+++ b/frameworks/as/projects/FlexJSUI/src/FlexJSUIClasses.as
@@ -101,6 +101,7 @@ internal class FlexJSUIClasses
import org.apache.flex.utils.Timer; Timer;
import org.apache.flex.core.SimpleStatesImpl; SimpleStatesImpl;
+ import mx.core.ClassFactory; ClassFactory;
import mx.states.AddItems; AddItems;
import mx.states.SetProperty; SetProperty;
import mx.states.State; State;
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/as/projects/FlexJSUI/src/mx/core/ClassFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/mx/core/ClassFactory.as b/frameworks/as/projects/FlexJSUI/src/mx/core/ClassFactory.as
new file mode 100644
index 0000000..7287a7a
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/mx/core/ClassFactory.as
@@ -0,0 +1,47 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package mx.core
+{
+ import mx.core.IFactory;
+
+ public class ClassFactory implements IFactory
+ {
+ public var generator:Class;
+ public var properties:Object;
+
+ public function ClassFactory(generator:Class=null)
+ {
+ this.generator = generator;
+ }
+
+ public function newInstance():*
+ {
+ var obj:* = new generator();
+
+ if (properties) {
+ for (var prop:String in properties) {
+ obj[prop] = properties[prop];
+ }
+ }
+
+ return obj;
+ }
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/as/projects/FlexJSUI/src/mx/core/IFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/mx/core/IFactory.as b/frameworks/as/projects/FlexJSUI/src/mx/core/IFactory.as
new file mode 100644
index 0000000..492a530
--- /dev/null
+++ b/frameworks/as/projects/FlexJSUI/src/mx/core/IFactory.as
@@ -0,0 +1,25 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package mx.core
+{
+ public interface IFactory
+ {
+ function newInstance():*;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/ItemRendererClassFactory.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/ItemRendererClassFactory.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/ItemRendererClassFactory.as
index 0dc1959..e561d38 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/ItemRendererClassFactory.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/core/ItemRendererClassFactory.as
@@ -21,6 +21,8 @@ package org.apache.flex.core
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
+ import mx.core.ClassFactory;
+
import org.apache.flex.utils.MXMLDataInterpreter;
[DefaultProperty("mxmlContent")]
@@ -36,9 +38,22 @@ package org.apache.flex.core
public function set strand(value:IStrand):void
{
_strand = value;
- itemRendererClass = ValuesManager.valuesImpl.getValue(_strand, "iItemRenderer")
as Class;
- if (itemRendererClass)
+
+ // see if the _strand has an itemRenderer property that isn't empty. if that's
+ // true, use that value instead of pulling it from the the style
+ if (Object(_strand).hasOwnProperty("itemRenderer")) {
+ itemRendererClassFactory = Object(_strand)["itemRenderer"] as ClassFactory;
+ if (itemRendererClassFactory) {
+ createFunction = createFromClass;
+ return;
+ }
+ }
+
+ var itemRendererClass:Class = ValuesManager.valuesImpl.getValue(_strand, "iItemRenderer")
as Class;
+ if (itemRendererClass) {
+ itemRendererClassFactory = new ClassFactory(itemRendererClass);
createFunction = createFromClass;
+ }
}
public function get MXMLDescriptor():Array
@@ -65,11 +80,11 @@ package org.apache.flex.core
return MXMLDataInterpreter.generateMXMLArray(document, parent as IParent, MXMLDescriptor,
true)[0];
}
- public var itemRendererClass:Class;
+ public var itemRendererClassFactory:ClassFactory;
public function createFromClass(parent:IItemRendererParent):IItemRenderer
{
- var renderer:IItemRenderer = new itemRendererClass();
+ var renderer:IItemRenderer = itemRendererClassFactory.newInstance();
parent.addElement(renderer);
return renderer;
}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/List.as
----------------------------------------------------------------------
diff --git a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/List.as
b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/List.as
index c44101e..a74d65a 100644
--- a/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/List.as
+++ b/frameworks/as/projects/FlexJSUI/src/org/apache/flex/html/staticControls/List.as
@@ -18,6 +18,8 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html.staticControls
{
+ import mx.core.IFactory;
+
import org.apache.flex.core.IDataProviderItemRendererMapper;
import org.apache.flex.core.IRollOverModel;
import org.apache.flex.core.ISelectionModel;
@@ -76,6 +78,16 @@ package org.apache.flex.html.staticControls
ISelectionModel(model).selectedItem = value;
}
+ private var _itemRenderer:IFactory;
+ public function get itemRenderer():IFactory
+ {
+ return _itemRenderer;
+ }
+ public function set itemRenderer(value:IFactory):void
+ {
+ _itemRenderer = value;
+ }
+
override public function addedToParent():void
{
super.addedToParent();
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/js/FlexJS/src/mx/core/ClassFactory.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/mx/core/ClassFactory.js b/frameworks/js/FlexJS/src/mx/core/ClassFactory.js
new file mode 100644
index 0000000..f87f327
--- /dev/null
+++ b/frameworks/js/FlexJS/src/mx/core/ClassFactory.js
@@ -0,0 +1,47 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the 'License');
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an 'AS IS' BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+goog.provide('mx.core.ClassFactory');
+
+goog.require('mx.core.IFactory');
+
+
+
+/**
+ * @constructor
+ * @implements {mx.core.IFactory}
+ */
+mx.core.ClassFactory = function() {
+ this.generator = null;
+ this.properties = null;
+};
+
+
+/**
+ * @expose
+ * @return {Object} The new instance of the class described by generator.
+ */
+mx.core.ClassFactory.
+ prototype.newInstance = function() {
+ var obj = new generator();
+
+ if (properties) {
+ var prop;
+ for each(prop in properties) {
+ obj[prop] = properties[prop];
+ }
+ }
+
+ return obj;
+};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/74b671af/frameworks/js/FlexJS/src/mx/core/IFactory.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/mx/core/IFactory.js b/frameworks/js/FlexJS/src/mx/core/IFactory.js
new file mode 100644
index 0000000..d74f47f
--- /dev/null
+++ b/frameworks/js/FlexJS/src/mx/core/IFactory.js
@@ -0,0 +1,45 @@
+/**
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @fileoverview
+ * @suppress {checkTypes}
+ */
+
+goog.provide('mx.core.IFactory');
+
+
+
+/**
+ * @interface
+ */
+mx.core.IFactory = function() {
+};
+
+
+/**
+ * @expose
+ * @return {Object} A new instance of the itemRenderer.
+ */
+mx.core.IFactory.prototype.newInstance = function() {};
+
+
+/**
+ * Metadata
+ *
+ * @type {Object.<string, Array.<Object>>}
+ */
+mx.core.IFactory.prototype.FLEXJS_CLASS_INFO =
+ { names: [{ name: 'IFactory',
+ qName: 'mx.core.IFactory' }] };
\ No newline at end of file
|