royale-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From carlosrov...@apache.org
Subject [royale-asjs] branch develop updated: add mx ItemResponder and ItemPendingError
Date Wed, 24 Oct 2018 17:38:02 GMT
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 4cc9cf8  add mx ItemResponder and ItemPendingError
4cc9cf8 is described below

commit 4cc9cf8a5e04720b6609f1c5f2d5ce42797d3f1e
Author: Carlos Rovira <carlosrovira@apache.org>
AuthorDate: Wed Oct 24 19:37:54 2018 +0200

    add mx ItemResponder and ItemPendingError
---
 .../main/royale/mx/collections/ItemResponder.as    | 168 +++++++++++++++++++++
 .../royale/mx/collections/ListCollectionView.as    |  10 +-
 .../mx/collections/errors/ItemPendingError.as      | 133 ++++++++++++++++
 .../src/main/royale/mx/controls/LinkBar.as         |   2 +-
 4 files changed, 307 insertions(+), 6 deletions(-)

diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ItemResponder.as
b/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ItemResponder.as
new file mode 100644
index 0000000..03a6ce9
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ItemResponder.as
@@ -0,0 +1,168 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.collections
+{
+
+import mx.rpc.IResponder;
+
+
+/**
+ *  The ItemResponder class provides a default implementation of the
+ *  <code>mx.rpc.IResponder</code> interface.
+ *  It represents a responder that lets you specify methods to be 
+ *  called when a request is completed, either successfully or with an error.
+ *  The class object can also lets you provide data (a token) to be used by
+ *  the responder methods.
+ * 
+ * <p>You use an <code>ItemResponder</code> object in the <code>catch</code>
statement
+ * of a try block that might result in getting remote data, as shown in the following
+ * code:</p>
+ * 
+ *  <pre><code>
+ *     import mx.collections.ItemResponder;
+ *     //...
+ *
+ *     try
+ *     {
+ *        //...
+ *        cursor.moveNext();
+ *     }
+ *	   catch(e:ItemPendingError)
+ *     {
+ *        e.addResponder(new ItemResponder(myResultFunction, myFaultFunction, {info:"..."}));
+ *     }
+ *  </code></pre>
+ *
+ *  <p>The result method specified must have the following signature:</p>
+ * 
+ *  <code><pre>
+ *     public function myResultFunction(result:Object, token:Object = null):void;
+ *  </pre></code>
+ *
+ *  <p>The fault method specified must have the following signature:</p>
+ * 
+ *  <code><pre>
+ *     public function myFaultFunction(error:Object, token:Object = null):void;
+ *  </pre></code>
+ * 
+ *  <p>Any other signature will result in a runtime error.</p>
+ * 
+ *  @see mx.collections.errors.ItemPendingError
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class ItemResponder implements IResponder
+{
+    // include "../core/Version.as";
+
+	//--------------------------------------------------------------------------
+	//
+	//  Constructor
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  Constructs an instance of the responder with the specified data and 
+	 *  handlers.
+	 *  
+	 *  @param	result Function that should be called when the request has
+	 *          completed successfully.
+	 *  		Must have the following signature:
+	 *  		<code><pre>
+	 *     		    public function (result:Object, token:Object = null):void;
+	 *  		</pre></code>
+	 *  @param	fault Function that should be called when the request has
+	 *			completed with errors.
+	 *  		Must have the following signature:
+	 *  		<code><pre>
+	 *     		    public function (error:ErrorMessage, token:Object = null):void;
+	 *  		</pre></code>
+	 *  @param	token Object [optional] additional information to associate with
+	 *          this request. This object is passed to the result and fault functions
+	 *          as their second parameter.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function ItemResponder(result:Function, fault:Function, token:Object = null)
+	{
+		super();
+
+		_resultHandler = result;
+		_faultHandler = fault;
+		_token = token;
+	}
+	
+	//--------------------------------------------------------------------------
+	//
+	//  Methods
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  This method is called by a service when the return value has been 
+	 *  received.
+	 *
+	 *  @param	data Object containing the information returned from the request.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function result(data:Object):void
+	{
+		_resultHandler(data, _token);
+	}
+	
+	/**
+	 *  This method is called by a service when an error has been received.
+	 *
+	 *  @param	info Object containing the information about the error that 
+	 *   		occured.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function fault(info:Object):void
+	{
+		_faultHandler(info, _token);
+	}
+	
+	//--------------------------------------------------------------------------
+	//
+	//  Variables
+	//
+	//--------------------------------------------------------------------------
+
+	private var _resultHandler:Function;
+	private var _faultHandler:Function;
+	private var _token:Object;
+}
+
+
+}
\ No newline at end of file
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ListCollectionView.as
b/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ListCollectionView.as
index c14c928..78d89a3 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ListCollectionView.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/collections/ListCollectionView.as
@@ -32,7 +32,7 @@ package mx.collections
 
     //import mx.binding.utils.ChangeWatcher;
     //import mx.collections.errors.CollectionViewError;
-    //import mx.collections.errors.ItemPendingError;
+    import mx.collections.errors.ItemPendingError;
     import mx.collections.errors.SortError;
     //import mx.core.IMXMLObject;
     import mx.core.mx_internal;
@@ -1673,12 +1673,12 @@ public class ListCollectionView extends Proxy implements ICollectionView,
IList
     {
         if (sort || filterFunction != null)
         {
-            /*
+            
             try
             {
-            */
+            
                 populateLocalIndex();
-            /*
+            
             }
             catch(pending:ItemPendingError)
             {
@@ -1693,7 +1693,7 @@ public class ListCollectionView extends Proxy implements ICollectionView,
IList
                     }));
                 return false;
             }
-            */
+            
 
             if (filterFunction != null)
             {
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/collections/errors/ItemPendingError.as
b/frameworks/projects/MXRoyale/src/main/royale/mx/collections/errors/ItemPendingError.as
new file mode 100644
index 0000000..f8bf49a
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/collections/errors/ItemPendingError.as
@@ -0,0 +1,133 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+//  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.collections.errors
+{
+
+import mx.rpc.IResponder;
+
+/**
+ *  This error is thrown when retrieving an item from a collection view
+ *  requires an asynchronous call. This error occurs when the backing data 
+ *  is provided from a remote source and the data is not yet available locally.
+ * 
+ *  <p>If the receiver of this error needs notification when the requested item
+ *  becomes available (that is, when the asynchronous call completes), it must
+ *  use the <code>addResponder()</code> method and specify  
+ *  an object that  supports the <code>mx.rpc.IResponder</code>
+ *  interface to respond when the item is available.
+ *  The <code>mx.collections.ItemResponder</code> class implements the 
+ *  IResponder interface and supports a <code>data</code> property.</p>
+ *
+ *  @see mx.collections.ItemResponder
+ *  @see mx.rpc.IResponder
+ *  
+ *  @langversion 3.0
+ *  @playerversion Flash 9
+ *  @playerversion AIR 1.1
+ *  @productversion Flex 3
+ */
+public class ItemPendingError extends Error
+{
+    // include "../../core/Version.as";
+
+	//--------------------------------------------------------------------------
+	//
+	//  Constructor
+	//
+	//--------------------------------------------------------------------------
+
+    /**
+	 *  Constructor.
+	 *
+	 *  <p>Called by the Flex Framework when a request is made 
+	 *  for an item that isn't local.</p>
+	 *
+	 *  @param message A message providing information about the error cause.
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+    public function ItemPendingError(message:String)
+    {
+        super(message);
+    }
+
+	//--------------------------------------------------------------------------
+	//
+	//  Properties
+	//
+	//--------------------------------------------------------------------------
+
+	//----------------------------------
+	// responder
+	//----------------------------------
+
+    /**
+	 *  @private
+	 */
+	private var _responders:Array;
+
+    /**
+     *  An array of IResponder handlers that will be called when
+     *  the asynchronous request completes.
+	 *  
+	 *  @langversion 3.0
+	 *  @playerversion Flash 9
+	 *  @playerversion AIR 1.1
+	 *  @productversion Flex 3
+	 */
+	public function get responders():Array
+	{
+		return _responders;
+	}
+
+	//--------------------------------------------------------------------------
+	//
+	//  Methods
+	//
+	//--------------------------------------------------------------------------
+
+	/**
+	 *  <code>addResponder</code> adds a responder to an Array of responders. 
+     *  The object assigned to the responder parameter must implement the 
+     *  mx.rpc.IResponder interface.
+	 *
+	 *  @param responder A handler which will be called when the asynchronous request completes.
+	 * 
+	 *  @see	mx.rpc.IResponder
+	 *  @see	mx.collections.ItemResponder
+     *  
+     *  @langversion 3.0
+     *  @playerversion Flash 9
+     *  @playerversion AIR 1.1
+     *  @productversion Flex 3
+     */
+	public function addResponder(responder:IResponder):void
+	{
+		if (!_responders)
+			_responders = [];
+
+		_responders.push(responder);
+	}
+}
+
+}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/LinkBar.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/LinkBar.as
index 93513e3..0fbce90 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/LinkBar.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/LinkBar.as
@@ -27,7 +27,7 @@ import mx.core.ClassFactory;
 import mx.core.EdgeMetrics;
 import mx.core.IFlexDisplayObject;
 import mx.core.mx_internal;
-import mx.events.ChildExistenceChangedEvent;
+// import mx.events.ChildExistenceChangedEvent;
 import mx.events.FlexEvent;
 import mx.events.ItemClickEvent;
 import mx.styles.ISimpleStyleClient;


Mime
View raw message