This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git


The following commit(s) were added to refs/heads/develop by this push:
     new 19d6627  jewel-combobox: make possible item renderers in combobox 
popup list
19d6627 is described below

commit 19d6627845675dea4f95265be39a893439a5754f
Author: Carlos Rovira <carlosrov...@apache.org>
AuthorDate: Sat Feb 8 12:50:56 2020 +0100

    jewel-combobox: make possible item renderers in combobox popup list
---
 .../royale/jewel/beads/views/ComboBoxPopUpView.as  | 43 +++++++++++++++++-----
 .../royale/jewel/beads/views/ComboBoxView.as       | 13 +++++--
 .../jewel/beads/views/VirtualComboBoxPopUpView.as  |  1 +
 .../jewel/supportClasses/combobox/ComboBoxPopUp.as | 10 +++++
 4 files changed, 53 insertions(+), 14 deletions(-)

diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
index d5c443b..fa50508 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxPopUpView.as
@@ -19,9 +19,12 @@
 package org.apache.royale.jewel.beads.views
 {
     import org.apache.royale.core.BeadViewBase;
+    import org.apache.royale.core.ClassFactory;
     import org.apache.royale.core.IBeadModel;
+    import org.apache.royale.core.IItemRendererClassFactory;
     import org.apache.royale.core.IParent;
     import org.apache.royale.core.IStrand;
+    import org.apache.royale.core.ItemRendererClassFactory;
     import org.apache.royale.jewel.List;
     import org.apache.royale.jewel.supportClasses.combobox.ComboBoxPopUp;
     import 
org.apache.royale.jewel.supportClasses.combobox.IComboBoxPresentationModel;
@@ -64,34 +67,54 @@ package org.apache.royale.jewel.beads.views
         override public function set strand(value:IStrand):void
                {
             _strand = value;
-            
+
+            // set model
             var model:IBeadModel = _strand.getBeadByType(IBeadModel) as 
IBeadModel;
             list.model = model;
 
+            // set rowHeight
             var _presentationModel:IComboBoxPresentationModel = (_strand as 
ComboBoxPopUp).presentationModel as IComboBoxPresentationModel;
             list.rowHeight = _presentationModel.rowHeight;
 
-            // use rowCount to configure height
+            // set height based on rowCount
             var rowCount:int = _presentationModel.rowCount;
-
-            // var view:IListView = list.view as IListView;
-            // var dataGroup:IItemRendererParent = view.dataGroup;
-
-            // var factory:IItemRendererClassFactory = 
loadBeadFromValuesManager(IItemRendererClassFactory, 
"iItemRendererClassFactory", list) as IItemRendererClassFactory;
-            // var ir:ISelectableItemRenderer = 
factory.createItemRenderer(dataGroup) as ISelectableItemRenderer;
-            list.height = rowCount * list.rowHeight; //(ir as IUIBase).height;
+            list.height = rowCount * list.rowHeight;
 
             IParent(_strand).addElement(list);
                }
-
+        
         protected var _list:List;
+        /**
+         *  The list part
+         * @return 
+         */
         public function get list():List
         {
             if(!_list) {
                 _list = new List();
+                _list.addEventListener("beadsAdded", beadsAddedHandler);
             }
             return _list;
         }
 
+        /**
+         *  If  user defines item render in the combo, this must be pased to 
popup list
+         *  Modify the item renderer class to instantiate renderers configured 
in the ComboBox instance
+         * 
+         *  @param event 
+         */
+        public function beadsAddedHandler(event:Event):void
+               {
+            _list.removeEventListener("beadsAdded", beadsAddedHandler);
+            
+            // ComboBoxView pass the itemRendererClass to the ComboBoxPopUp
+            var itemRendererClass:Class = (_strand as 
ComboBoxPopUp).itemRendererClass;
+
+            if(itemRendererClass)
+            {
+                var factory:ItemRendererClassFactory = 
list.getBeadByType(IItemRendererClassFactory) as ItemRendererClassFactory;
+                factory.itemRendererFactory = new 
ClassFactory(itemRendererClass);
+            }
+        }
     }
 }
\ No newline at end of file
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
index 7f164b1..c547abb 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/ComboBoxView.as
@@ -191,18 +191,23 @@ package org.apache.royale.jewel.beads.views
 
                     _comboPopUp = new _popUpClass() as ComboBoxPopUp;
                                        _comboPopUp.addBead(_presentationModel);
-                    _comboPopUp.model = model;
-
+                                       _comboPopUp.model = model;
+                                       
+                                       // if  user defines item render for 
combo must be pased to popup list
+                                       var itemRendererClass:Class = 
ValuesManager.valuesImpl.getValue(_strand, "iItemRenderer") as Class;
+                                       if(itemRendererClass != null)
+                                               _comboPopUp.itemRendererClass = 
itemRendererClass;
+                                       
                                        UIUtils.addPopUp(_comboPopUp, host);
                     // var popupHost:IPopUpHost = 
UIUtils.findPopUpHost(_strand as IUIBase);
                     // popupHost.popUpParent.addElement(_comboPopUp);
 
                     // popup is ComboBoxPopUp that fills 100% of browser 
window-> We want the internal List inside its view to adjust height
                     _list = (_comboPopUp.view as ComboBoxPopUpView).list;
+                                       
                                        //popup width needs to be set before 
position inside bounding client to work ok
                                        _list.width = host.width;
-                    // _list.model = _comboPopUp.model;
-
+                    
                     COMPILE::JS
                     {
                                        // Fix temporary: when soft keyboard 
opens in ios devices browser is not resized, so popup gets under the keyboard
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
index cf11311..3774e9d 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualComboBoxPopUpView.as
@@ -48,6 +48,7 @@ package org.apache.royale.jewel.beads.views
         {
             if(!_list) {
                 _list = new VirtualList();
+                               _list.addEventListener("beadsAdded", 
beadsAddedHandler);
             }
             return _list;
         }
diff --git 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
index e542f22..787fa9b 100644
--- 
a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
+++ 
b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/supportClasses/combobox/ComboBoxPopUp.as
@@ -180,5 +180,15 @@ package org.apache.royale.jewel.supportClasses.combobox
                        }
                        return presModel;
                }
+
+               /**
+                *  Used in the ComboBoxPopUp to configure user defined 
renderers for the popup list
+                * 
+                *  @langversion 3.0
+                *  @playerversion Flash 10.2
+                *  @playerversion AIR 2.6
+                *  @productversion Royale 0.9.7
+                */
+               public var itemRendererClass:Class;
        }
 }

Reply via email to