flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject git commit: [flex-asjs] [refs/heads/develop] - Added missing pieces to make custom itemRenderers work.
Date Wed, 13 Nov 2013 16:23:14 GMT
Updated Branches:
  refs/heads/develop 2d8d5e441 -> e19986a62


Added missing pieces to make custom itemRenderers work.


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

Branch: refs/heads/develop
Commit: e19986a621093e3370183ddfad4547f6d6ed136e
Parents: 2d8d5e4
Author: Peter Ent <pent@apache.org>
Authored: Wed Nov 13 11:22:59 2013 -0500
Committer: Peter Ent <pent@apache.org>
Committed: Wed Nov 13 11:22:59 2013 -0500

----------------------------------------------------------------------
 .../core/IDataProviderItemRendererMapper.js     | 23 +++++++++++++++
 .../flex/core/IItemRendererClassFactory.js      | 23 +++++++++++++++
 .../flex/core/ItemRendererClassFactory.js       |  2 ++
 .../org/apache/flex/html/staticControls/List.js | 26 +++++++++++++----
 .../DataItemRendererFactoryForArrayData.js      | 30 +++++++++++++-------
 .../flex/html/staticControls/beads/ListView.js  |  1 +
 .../TextItemRendererFactoryForArrayData.js      |  4 +--
 .../supportClasses/DataItemRenderer.js          |  2 ++
 .../supportClasses/StringItemRenderer.js        |  2 ++
 9 files changed, 96 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/core/IDataProviderItemRendererMapper.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IDataProviderItemRendererMapper.js
b/frameworks/js/FlexJS/src/org/apache/flex/core/IDataProviderItemRendererMapper.js
new file mode 100644
index 0000000..e31a184
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IDataProviderItemRendererMapper.js
@@ -0,0 +1,23 @@
+/**
+ * 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('org.apache.flex.core.IDataProviderItemRendererMapper');
+
+
+
+/**
+ * @interface
+ */
+org.apache.flex.core.IDataProviderItemRendererMapper = function() {
+};

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererClassFactory.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererClassFactory.js b/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererClassFactory.js
new file mode 100644
index 0000000..caa243d
--- /dev/null
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/IItemRendererClassFactory.js
@@ -0,0 +1,23 @@
+/**
+ * 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('org.apache.flex.core.IItemRendererClassFactory');
+
+
+
+/**
+ * @interface
+ */
+org.apache.flex.core.IItemRendererClassFactory = function() {
+};

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/core/ItemRendererClassFactory.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/core/ItemRendererClassFactory.js b/frameworks/js/FlexJS/src/org/apache/flex/core/ItemRendererClassFactory.js
index 47a9f55..eefa209 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/core/ItemRendererClassFactory.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/core/ItemRendererClassFactory.js
@@ -14,12 +14,14 @@
 
 goog.provide('org.apache.flex.core.ItemRendererClassFactory');
 
+goog.require('org.apache.flex.core.IItemRendererClassFactory');
 goog.require('org.apache.flex.core.ValuesManager');
 
 
 
 /**
  * @constructor
+ * @implements {org.apache.flex.core.IItemRendererClassFactory}
  */
 org.apache.flex.core.ItemRendererClassFactory = function() {
   this.itemRendererClass = null;

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js
index 39470f8..b24d3bf 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/List.js
@@ -14,12 +14,16 @@
 
 goog.provide('org.apache.flex.html.staticControls.List');
 
-goog.require('org.apache.flex.core.IItemRenderer');
+goog.require('org.apache.flex.core.IDataProviderItemRendererMapper');
+goog.require('org.apache.flex.core.IItemRendererClassFactory');
+goog.require('org.apache.flex.core.ItemRendererClassFactory');
 goog.require('org.apache.flex.core.ListBase');
+goog.require('org.apache.flex.core.ValuesManager');
 goog.require('org.apache.flex.html.staticControls.beads.ListView');
 goog.require('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData');
 goog.require('org.apache.flex.html.staticControls.beads.controllers.ListSingleSelectionMouseController');
 goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel');
+goog.require('org.apache.flex.html.staticControls.supportClasses.DataItemRenderer');
 
 
 
@@ -53,12 +57,24 @@ org.apache.flex.html.staticControls.List.prototype.addedToParent =
     function() {
   goog.base(this, 'addedToParent');
 
-  var c = this.getBeadByType(org.apache.flex.core.IItemRenderer);
+  var c = this.getBeadByType(org.apache.flex.core.IDataProviderItemRendererMapper);
   if (c == null) {
-    this.addBead(new
-                 org.apache.flex.html.staticControls.beads.
-                 TextItemRendererFactoryForArrayData());
+    c = org.apache.flex.core.ValuesManager.valuesImpl.getValue(this,'iDataProviderItemRendererMapper');
+    if (c) {
+      var bead = new c;
+      this.addBead(bead);
+    }
   }
+//  var c = this.getBeadByType(org.apache.flex.core.IItemRenderer);
+//  if (c == null) {
+//    c = this.getBeadByType(
+//          org.apache.flex.html.staticControls.supportClasses.DataItemRenderer);
+//    if (c == null) {
+//      this.addBead(new
+//                   org.apache.flex.html.staticControls.beads.
+//                   TextItemRendererFactoryForArrayData());
+//    }
+//  }
 };
 
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForArrayData.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForArrayData.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForArrayData.js
index 93e4602..cbbc2c7 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForArrayData.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/DataItemRendererFactoryForArrayData.js
@@ -14,6 +14,7 @@
 
 goog.provide('org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData');
 
+goog.require('org.apache.flex.core.IDataProviderItemRendererMapper');
 goog.require('org.apache.flex.events.EventDispatcher');
 goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel');
 goog.require('org.apache.flex.html.staticControls.beads.ListView');
@@ -23,16 +24,11 @@ goog.require('org.apache.flex.html.staticControls.supportClasses.ButtonBarButton
 
 /**
  * @constructor
- * @extends {org.apache.flex.events.EventDispatcher}
+ * @implements {org.apache.flex.core.IDataProviderItemRendererMapper}
  */
 org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData =
     function() {
-  goog.base(this);
 };
-goog.inherits(
-    org.apache.flex.html.staticControls.
-        beads.DataItemRendererFactoryForArrayData,
-    org.apache.flex.events.EventDispatcher);
 
 
 /**
@@ -60,6 +56,14 @@ org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData.
 
   this.model.addEventListener('dataProviderChanged',
       goog.bind(this.dataProviderChangedHandler, this));
+      
+  if (this.itemRendererFactory_ == null) {
+    var c = org.apache.flex.core.ValuesManager.valuesImpl.getValue(this.strand_,'iItemRendererClassFactory');
+    this.itemRendererFactory_ = new c;
+    this.strand_.addBead(this.itemRendererFactory_);
+  }
+      
+  this.dataProviderChangedHandler(null);
 };
 
 
@@ -69,6 +73,12 @@ org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData.
  */
 org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData.
     prototype.get_itemRendererClass = function() {
+  if (this.itemRendererClass_ == null) {
+    var c = org.apache.flex.core.ValuesManager.valuesImpl.getValue(this.strand_,'iItemRenderer');
+    if (c) {
+      this.itemRendererClass_ = c;
+    }
+  }
   return this.itemRendererClass_;
 };
 
@@ -94,10 +104,10 @@ org.apache.flex.html.staticControls.beads.DataItemRendererFactoryForArrayData.
   dp = this.model.get_dataProvider();
   n = dp.length;
   for (i = 0; i < n; i++) {
-    var expr = 'new ' + String(this.itemRendererClass_) + '()';
-    opt = eval(expr);
-    this.dataGroup.addElement(opt);
-    opt.set_data(dp[i]);
+    var ir = this.itemRendererFactory_.createItemRenderer(this.dataGroup);
+    ir.set_index(i);
+    ir.set_data(dp[i]);
+    this.dataGroup.addElement(ir);
   }
 
   var newEvent = new org.apache.flex.events.Event('itemsCreated');

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js
index 884389c..62e7ccb 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/ListView.js
@@ -57,6 +57,7 @@ org.apache.flex.html.staticControls.beads.ListView.prototype.set_strand
=
 
   this.dataGroup_ = new
       org.apache.flex.html.staticControls.supportClasses.NonVirtualDataGroup();
+  this.dataGroup_.set_strand(this);
   this.strand_.addElement(this.dataGroup_);
 };
 

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js
index 1d7578d..6ff106d 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/beads/TextItemRendererFactoryForArrayData.js
@@ -14,7 +14,7 @@
 
 goog.provide('org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData');
 
-goog.require('org.apache.flex.core.IItemRenderer');
+goog.require('org.apache.flex.core.IDataProviderItemRendererMapper');
 goog.require('org.apache.flex.events.EventDispatcher');
 goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionModel');
 
@@ -27,7 +27,7 @@ goog.require('org.apache.flex.html.staticControls.beads.models.ArraySelectionMod
  */
 org.apache.flex.html.staticControls.beads.TextItemRendererFactoryForArrayData =
     function() {
-  goog.base(this);
+    goog.base(this);
 };
 goog.inherits(
     org.apache.flex.html.staticControls.

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.js
index 1d5a3a3..07417b2 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/DataItemRenderer.js
@@ -14,6 +14,7 @@
 
 goog.provide('org.apache.flex.html.staticControls.supportClasses.DataItemRenderer');
 
+goog.require('org.apache.flex.core.IItemRenderer');
 goog.require('org.apache.flex.core.UIBase');
 goog.require('org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController');
 
@@ -22,6 +23,7 @@ goog.require('org.apache.flex.html.staticControls.beads.controllers.ItemRenderer
 /**
  * @constructor
  * @extends {org.apache.flex.core.UIBase}
+ * @implements {org.apache.flex.core.IItemRenderer}
  */
 org.apache.flex.html.staticControls.supportClasses.DataItemRenderer =
     function() {

http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/e19986a6/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js
----------------------------------------------------------------------
diff --git a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js
b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js
index dd37f50..cdf61da 100644
--- a/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js
+++ b/frameworks/js/FlexJS/src/org/apache/flex/html/staticControls/supportClasses/StringItemRenderer.js
@@ -14,6 +14,7 @@
 
 goog.provide('org.apache.flex.html.staticControls.supportClasses.StringItemRenderer');
 
+goog.require('org.apache.flex.core.IItemRenderer');
 goog.require('org.apache.flex.core.UIBase');
 goog.require('org.apache.flex.html.staticControls.beads.controllers.ItemRendererMouseController');
 
@@ -22,6 +23,7 @@ goog.require('org.apache.flex.html.staticControls.beads.controllers.ItemRenderer
 /**
  * @constructor
  * @extends {org.apache.flex.core.UIBase}
+ * @implements {org.apache.flex.core.IItemRenderer}
  */
 org.apache.flex.html.staticControls.supportClasses.StringItemRenderer =
     function() {


Mime
View raw message