You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by gr...@apache.org on 2022/05/17 04:13:08 UTC

[royale-asjs] branch develop updated (d859f8d189 -> c90fbce7a8)

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

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


    from d859f8d189 Add VSlider
     new f95c6761e8 Revert "Avoid the possibility of infinite loops (in JS only, SWF untested) with xml watchers. This can happen if changes are made in watcher functions."
     new f533ae18ee Fix XMLList loop targets for JS in XMLNotifier
     new c90fbce7a8 mx MenuBar incremental improvements. Should fix mx-tests problem.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../MXRoyale/src/main/resources/defaults.css       |  2 +-
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |  1 +
 .../src/main/royale/mx/controls/MenuBar.as         | 16 +++--
 .../mx/controls/beads/models/MenuBarModel.as       | 19 +++++-
 ...ataItemRendererFactoryForICollectionViewData.as | 12 ++--
 ...taItemRendererFactoryForICollectionViewData.as} | 56 +++++++++------
 .../src/main/royale/mx/utils/XMLNotifier.as        | 79 +++++-----------------
 7 files changed, 90 insertions(+), 95 deletions(-)
 copy frameworks/projects/MXRoyale/src/main/royale/mx/controls/{listClasses/DataItemRendererFactoryForICollectionViewData.as => menuClasses/MenuDataItemRendererFactoryForICollectionViewData.as} (86%)


[royale-asjs] 03/03: mx MenuBar incremental improvements. Should fix mx-tests problem.

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit c90fbce7a83d96612c3fd73acdfbb3118854f46c
Author: greg-dove <gr...@gmail.com>
AuthorDate: Tue May 17 16:12:46 2022 +1200

    mx MenuBar incremental improvements. Should fix mx-tests problem.
---
 .../MXRoyale/src/main/resources/defaults.css       |  2 +-
 .../MXRoyale/src/main/royale/MXRoyaleClasses.as    |  1 +
 .../src/main/royale/mx/controls/MenuBar.as         | 16 ++++---
 .../mx/controls/beads/models/MenuBarModel.as       | 19 +++++++-
 ...ataItemRendererFactoryForICollectionViewData.as | 12 +++--
 ...taItemRendererFactoryForICollectionViewData.as} | 56 ++++++++++++++--------
 6 files changed, 72 insertions(+), 34 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/resources/defaults.css b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
index 8c46a61d8f..904f41102c 100644
--- a/frameworks/projects/MXRoyale/src/main/resources/defaults.css
+++ b/frameworks/projects/MXRoyale/src/main/resources/defaults.css
@@ -362,7 +362,7 @@ MenuBar {
 	IItemRenderer: ClassReference("mx.controls.menuClasses.MenuBarItemRenderer");			
 	IBeadController: ClassReference("mx.controls.beads.controllers.MenuBarMouseController");
 	IMenuFactory: ClassReference("mx.controls.menuClasses.CascadingMenuFactory");
-	IDataProviderItemRendererMapper: ClassReference("mx.controls.listClasses.DataItemRendererFactoryForICollectionViewData");
+	IDataProviderItemRendererMapper: ClassReference("mx.controls.menuClasses.MenuDataItemRendererFactoryForICollectionViewData");
 	IItemRendererClassFactory: ClassReference("org.apache.royale.core.ItemRendererClassFactory");
 	IItemRendererInitializer: ClassReference("org.apache.royale.html.beads.IndexedItemRendererInitializer");
 	IViewport: ClassReference("org.apache.royale.html.supportClasses.Viewport");
diff --git a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
index bf192520ff..10b8564c0a 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/MXRoyaleClasses.as
@@ -106,6 +106,7 @@ internal class MXRoyaleClasses
 	import mx.controls.treeClasses.TreeListData; TreeListData;
     import mx.controls.listClasses.ListVerticalLayout; ListVerticalLayout;
 	import mx.controls.listClasses.DataItemRendererFactoryForICollectionViewData; DataItemRendererFactoryForICollectionViewData;
+	import mx.controls.menuClasses.MenuDataItemRendererFactoryForICollectionViewData; MenuDataItemRendererFactoryForICollectionViewData;
     import mx.controls.listClasses.VirtualDataItemRendererFactoryForICollectionViewData; VirtualDataItemRendererFactoryForICollectionViewData;
     import mx.controls.listClasses.VirtualDataItemRendererFactoryForIListData; VirtualDataItemRendererFactoryForIListData;
 	import mx.controls.treeClasses.DataItemRendererFactoryForICollectionViewHierarchicalData; DataItemRendererFactoryForICollectionViewHierarchicalData;
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/MenuBar.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/MenuBar.as
index b1f9f602f4..0c4cb01043 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/MenuBar.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/MenuBar.as
@@ -48,6 +48,9 @@ import mx.managers.IFocusManagerComponent;
 import mx.styles.ISimpleStyleClient;
 import mx.styles.StyleProxy;
 import mx.controls.beads.models.MenuBarModel;
+import mx.controls.treeClasses.DefaultDataDescriptor;
+import mx.controls.menuClasses.IMenuDataDescriptor;
+
 
 import org.apache.royale.core.IBeadLayout;
 import org.apache.royale.core.IContainer;
@@ -528,6 +531,7 @@ public class MenuBar extends UIComponent implements IFocusManagerComponent, ICon
     //--------------------------------------------------------------------------
     //
     //  Overridden properties
+    //  Overridden properties
     //
     //--------------------------------------------------------------------------
     
@@ -605,10 +609,10 @@ public class MenuBar extends UIComponent implements IFocusManagerComponent, ICon
     /**
      *  @private
      */
-    /* mx_internal var _dataDescriptor:IMenuDataDescriptor =
+     mx_internal var _dataDescriptor:IMenuDataDescriptor =
         new DefaultDataDescriptor();
 
-    [Inspectable(category="Data")] */
+    [Inspectable(category="Data")]
 
     /**
      *  The object that accesses and manipulates data in the data provider. 
@@ -640,21 +644,21 @@ public class MenuBar extends UIComponent implements IFocusManagerComponent, ICon
      *  @playerversion AIR 1.1
      *  @productversion Royale 0.9.3
      */
-   /*  public function get dataDescriptor():IMenuDataDescriptor
+     public function get dataDescriptor():IMenuDataDescriptor
     {
         return IMenuDataDescriptor(_dataDescriptor);
-    } */
+    }
 
     /**
      *  @private
      */
-   /*  public function set dataDescriptor(value:IMenuDataDescriptor):void
+     public function set dataDescriptor(value:IMenuDataDescriptor):void
     {
         _dataDescriptor = value;
         
         //force all the menus to be re-created with the new dataDescriptor
         menus = [];
-    } */
+    }
     
     //----------------------------------
     //  dataProvider
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/models/MenuBarModel.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/models/MenuBarModel.as
index b18834e963..113a2f0ce2 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/models/MenuBarModel.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/beads/models/MenuBarModel.as
@@ -21,6 +21,8 @@ package mx.controls.beads.models
     import mx.collections.ArrayCollection;
     import mx.collections.ICollectionView;
     import mx.collections.XMLListCollection;
+    import mx.controls.MenuBar;
+    import mx.controls.menuClasses.IMenuDataDescriptor;
     import mx.events.CollectionEvent;
     import mx.events.CollectionEventKind;
 
@@ -71,6 +73,14 @@ package mx.controls.beads.models
             dispatchEvent(new Event("submenuFieldChanged"));
         }
 
+
+        public function get dataDescriptor():IMenuDataDescriptor
+        {
+            return MenuBar(_strand).dataDescriptor;
+        }
+
+
+
         private var _showRoot:Boolean = true;
 		
         /**
@@ -87,7 +97,14 @@ package mx.controls.beads.models
 		}
         public function set showRoot(value:Boolean):void
         {
-            _showRoot = value;
+            if (_showRoot != value) {
+                _showRoot = value;
+                if (_rootModel) {
+
+                }
+            }
+
+
         }
 
 
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as
index b854e5cf6c..05907b6966 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as
@@ -87,24 +87,26 @@ package mx.controls.listClasses
         {
             if (!dataProviderModel)
                 return;
+			var dped:IEventDispatcher = dp as IEventDispatcher;
             dp = dataProviderModel.dataProvider as ICollectionView;
             if (!dp)
             {
-                // temporary until descriptor is used in MenuBarModel
+              /*  // temporary until descriptor is used in MenuBarModel
                 var obj:Object = dataProviderModel.dataProvider;
                 if (obj is Array)
                 {
                     dp = new ArrayCollection(obj as Array);
                 }
-                else
+                else*/
                     return;
             }
             
             // listen for individual items being added in the future.
-            var dped:IEventDispatcher = dp as IEventDispatcher;
-			//First remove if it's already added
-			dped.removeEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
 
+			//First remove if it's already added to previous dp instance
+			if (dped) dped.removeEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
+
+			dped = dp as IEventDispatcher; // get latest
 			dped.addEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
             
             super.dataProviderChangeHandler(event);            
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/menuClasses/MenuDataItemRendererFactoryForICollectionViewData.as
similarity index 86%
copy from frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as
copy to frameworks/projects/MXRoyale/src/main/royale/mx/controls/menuClasses/MenuDataItemRendererFactoryForICollectionViewData.as
index b854e5cf6c..1a54b6120b 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/listClasses/DataItemRendererFactoryForICollectionViewData.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/menuClasses/MenuDataItemRendererFactoryForICollectionViewData.as
@@ -16,13 +16,15 @@
 //  limitations under the License.
 //
 ////////////////////////////////////////////////////////////////////////////////
-package mx.controls.listClasses
+package mx.controls.menuClasses
 {
     import mx.collections.ArrayCollection;
     import mx.collections.ICollectionView;
     import mx.collections.IViewCursor;
 	import mx.events.CollectionEvent;
 	import mx.events.CollectionEventKind;
+
+	import mx.controls.beads.models.MenuBarModel;
     
     import org.apache.royale.core.IBead;
     import org.apache.royale.core.IBeadModel;
@@ -60,7 +62,7 @@ package mx.controls.listClasses
      *  @playerversion AIR 2.6
      *  @productversion Royale 0.0
      */
-	public class DataItemRendererFactoryForICollectionViewData extends DataItemRendererFactoryBase
+	public class MenuDataItemRendererFactoryForICollectionViewData extends DataItemRendererFactoryBase
 	{
         /**
          *  Constructor.
@@ -70,7 +72,7 @@ package mx.controls.listClasses
          *  @playerversion AIR 2.6
          *  @productversion Royale 0.0
          */
-		public function DataItemRendererFactoryForICollectionViewData()
+		public function MenuDataItemRendererFactoryForICollectionViewData()
 		{
 			super();
 		}
@@ -87,25 +89,36 @@ package mx.controls.listClasses
         {
             if (!dataProviderModel)
                 return;
-            dp = dataProviderModel.dataProvider as ICollectionView;
-            if (!dp)
-            {
-                // temporary until descriptor is used in MenuBarModel
-                var obj:Object = dataProviderModel.dataProvider;
-                if (obj is Array)
-                {
-                    dp = new ArrayCollection(obj as Array);
-                }
-                else
-                    return;
-            }
-            
-            // listen for individual items being added in the future.
-            var dped:IEventDispatcher = dp as IEventDispatcher;
-			//First remove if it's already added
-			dped.removeEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
+			var menuBarModel:MenuBarModel =MenuBarModel(dataProviderModel);
+			if (dp) {
+				//First remove if it's already added
+				dp.removeEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
+			}
+            dp = menuBarModel.dataProvider as ICollectionView;
 
-			dped.addEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
+			if (dp) {
+				if (menuBarModel.hasRoot && !menuBarModel.showRoot) {
+					//this corresponds roughly to part of the code inside commitProperties in the original Flex MenuBar code:
+					var rootItem:* = dp.createCursor().current;
+					var tmpCollection:ICollectionView;
+					if (rootItem != null &&
+							menuBarModel.dataDescriptor.isBranch(rootItem, dp) &&
+							menuBarModel.dataDescriptor.hasChildren(rootItem, dp))
+					{
+						// then get rootItem children
+						tmpCollection =
+								menuBarModel.dataDescriptor.getChildren(rootItem, dp);
+
+						dp = tmpCollection;
+					}
+					//not part of the original Flex code, but should we not do this? (it is a root node with no children - i.e. should it not be an empty menubar? ) :
+					/*else {
+						dp = new ArrayCollection();
+					}*/
+				}
+
+				dp.addEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, collectionChangeHandler);
+			}
             
             super.dataProviderChangeHandler(event);            
         }
@@ -116,6 +129,7 @@ package mx.controls.listClasses
         // assumes will be called in a loop, not random access
         override protected function get dataProviderLength():int
         {
+			if (!dp) return 0;
             cursor = dp.createCursor();
             return dp.length;
         }


[royale-asjs] 02/03: Fix XMLList loop targets for JS in XMLNotifier

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f533ae18ee298d5c3369ce012e5d4e6aa1a01233
Author: greg-dove <gr...@gmail.com>
AuthorDate: Tue May 17 15:08:14 2022 +1200

    Fix XMLList loop targets for JS in XMLNotifier
---
 .../projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as
index 5bc8a13fa1..0aaa546fba 100644
--- a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as
+++ b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as
@@ -152,12 +152,14 @@ public class XMLNotifier
      *  @playerversion Flash 9
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
+     *
+     *  @royaleignorecoercion XMLList
      */
     public function watchXML(xml:Object, notifiable:IXMLNotifiable, uid:String = null):void
     {
         if ((xml is XMLList) && xml.length() > 1)
         {
-            for each(var item:Object in xml)
+            for each(var item:Object in (xml as XMLList))
             {
                 watchXML(item, notifiable, uid);
             }
@@ -201,12 +203,14 @@ public class XMLNotifier
      *  @playerversion Flash 9
      *  @playerversion AIR 1.1
      *  @productversion Flex 3
+     *
+     *  @royaleignorecoercion XMLList
      */
     public function unwatchXML(xml:Object, notifiable:IXMLNotifiable):void
     {
         if ((xml is XMLList) && xml.length() > 1)
         {
-            for each(var item:Object in xml)
+            for each(var item:Object in (xml as XMLList))
             {
                 unwatchXML(item, notifiable);
             }


[royale-asjs] 01/03: Revert "Avoid the possibility of infinite loops (in JS only, SWF untested) with xml watchers. This can happen if changes are made in watcher functions."

Posted by gr...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f95c6761e8701d3886e15606b8fa9aef52a9c6b6
Author: greg-dove <gr...@gmail.com>
AuthorDate: Tue May 17 14:24:53 2022 +1200

    Revert "Avoid the possibility of infinite loops (in JS only, SWF untested) with xml watchers. This can happen if changes are made in watcher functions."
    
    This reverts commit acab343f73b939bb3b28a13f9142cba4f799104a.
---
 .../src/main/royale/mx/utils/XMLNotifier.as        | 71 ++++------------------
 1 file changed, 12 insertions(+), 59 deletions(-)

diff --git a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as
index c4d033b476..5bc8a13fa1 100644
--- a/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as
+++ b/frameworks/projects/MXRoyaleBase/src/main/royale/mx/utils/XMLNotifier.as
@@ -20,14 +20,10 @@
 package mx.utils
 {
 
-//import org.apache.royale.utils.ObjectMap;
+import org.apache.royale.utils.ObjectMap;
 import mx.core.mx_internal;
 import mx.utils.IXMLNotifiable;
 
-COMPILE::SWF{
-    import flash.utils.Dictionary;
-}
-
 use namespace mx_internal;
 
 /**
@@ -102,32 +98,13 @@ public class XMLNotifier
             {
                 callee = notificationFunction;
             }
-            //var xmlWatchers:ObjectMap = callee["watched"];
-
-            COMPILE::SWF{
-                var xmlWatchers:Dictionary = callee["watched"];
-                for (var notifiable:Object in xmlWatchers) {
+            var xmlWatchers:ObjectMap = callee["watched"];
+            if (xmlWatchers != null)
+            {
+                xmlWatchers.forEach( function(truevalue:Object,notifiable:Object,map:Object):void {
                     IXMLNotifiable(notifiable).xmlNotification(currentTarget, ty, tar, value, detail);
-                }
+                } );
             }
-
-            COMPILE::JS{
-                var xmlWatchers:Map = callee["watched"];
-                if (xmlWatchers != null)
-                {
-                    var collected:Array = [];
-                    //note, if we don't collect these first and try to iterate directly, then there can be the case that iterating is infinite if the function caLL also somehow affects the xmlWatchers Map:
-                    xmlWatchers.forEach( function(truevalue:Object,notifiable:Object,map:Object):void {
-                        collected.push(notifiable);
-                    } );
-
-                    while(collected.length){
-                        IXMLNotifiable(collected.shift()).xmlNotification(currentTarget, ty, tar, value, detail);
-                    }
-                }
-            }
-
-
         }
 
         return notificationFunction;
@@ -204,25 +181,13 @@ public class XMLNotifier
             }
 
             // Watch lists are maintained on the notification function.
-            if (watcherFunction["watched"] == undefined) {
-               // watcherFunction["watched"] = xmlWatchers = new ObjectMap(true,true);
-                COMPILE::SWF{
-                    var xmlWatchers:Dictionary = watcherFunction["watched"] = new Dictionary();
-                }
-
-                COMPILE::JS{
-                    var xmlWatchers:Map= watcherFunction["watched"] = new Map();
-                }
-            }
+            var xmlWatchers:ObjectMap;
+            if (watcherFunction["watched"] == undefined)
+                watcherFunction["watched"] = xmlWatchers = new ObjectMap(true,true);
             else
                 xmlWatchers = watcherFunction["watched"];
 
-            COMPILE::SWF{
-                xmlWatchers[notifiable]=true;
-            }
-            COMPILE::JS{
-                xmlWatchers.set(notifiable, true);
-            }
+            xmlWatchers.set(notifiable, true);
         }
     }
 
@@ -258,24 +223,12 @@ public class XMLNotifier
             if (!(watcherFunction is Function))
                 return;
 
-            COMPILE::SWF{
-                var xmlWatchers:Dictionary;
-            }
-
-            COMPILE::JS{
-                var xmlWatchers:Map;
-            }
+            var xmlWatchers:ObjectMap;
 
             if (watcherFunction["watched"] != undefined)
             {
                 xmlWatchers = watcherFunction["watched"];
-                COMPILE::SWF{
-                    delete xmlWatchers[notifiable];
-                }
-                COMPILE::JS{
-                    xmlWatchers.delete(notifiable);
-                }
-
+                xmlWatchers.delete(notifiable);
             }           
         }
     }