Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / AbstractManager.html
index 3de5d6d..16cda9b 100644 (file)
@@ -1,91 +1,80 @@
-<html>
-<head>
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
-  <title>The source code</title>
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
-</head>
-<body  onload="prettyPrint();">
-    <pre class="prettyprint lang-js">/*!
- * Ext JS Library 3.3.1
- * Copyright(c) 2006-2010 Sencha Inc.
- * licensing@sencha.com
- * http://www.sencha.com/license
- */
-<div id="cls-Ext.AbstractManager"></div>/**
- * @class Ext.AbstractManager
+<!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-AbstractManager'>/**
+</span> * @class Ext.AbstractManager
  * @extends Object
- * Base Manager class - extended by ComponentMgr and PluginMgr
+ * @ignore
+ * Base Manager class
  */
-Ext.AbstractManager = Ext.extend(Object, {
+
+Ext.define('Ext.AbstractManager', {
+
+    /* Begin Definitions */
+
+    requires: ['Ext.util.HashMap'],
+
+    /* End Definitions */
+
     typeName: 'type',
-    
+
     constructor: function(config) {
         Ext.apply(this, config || {});
-        
-        <div id="prop-Ext.AbstractManager-all"></div>/**
-         * Contains all of the items currently managed
+
+<span id='Ext-AbstractManager-property-all'>        /**
+</span>         * Contains all of the items currently managed
          * @property all
          * @type Ext.util.MixedCollection
          */
-        this.all = new Ext.util.MixedCollection();
-        
+        this.all = Ext.create('Ext.util.HashMap');
+
         this.types = {};
     },
-    
-    <div id="method-Ext.AbstractManager-get"></div>/**
-     * Returns a component by {@link Ext.Component#id id}.
-     * For additional details see {@link Ext.util.MixedCollection#get}.
-     * @param {String} id The component {@link Ext.Component#id id}
-     * @return Ext.Component The Component, <code>undefined</code> if not found, or <code>null</code> if a
-     * Class was found.
+
+<span id='Ext-AbstractManager-method-get'>    /**
+</span>     * Returns an item by id.
+     * For additional details see {@link Ext.util.HashMap#get}.
+     * @param {String} id The id of the item
+     * @return {Mixed} The item, &lt;code&gt;undefined&lt;/code&gt; if not found.
      */
-    get : function(id){
+    get : function(id) {
         return this.all.get(id);
     },
-    
-    <div id="method-Ext.AbstractManager-register"></div>/**
-     * Registers an item to be managed
+
+<span id='Ext-AbstractManager-method-register'>    /**
+</span>     * Registers an item to be managed
      * @param {Mixed} item The item to register
      */
     register: function(item) {
         this.all.add(item);
     },
-    
-    <div id="method-Ext.AbstractManager-unregister"></div>/**
-     * Unregisters a component by removing it from this manager
+
+<span id='Ext-AbstractManager-method-unregister'>    /**
+</span>     * Unregisters an item by removing it from this manager
      * @param {Mixed} item The item to unregister
      */
     unregister: function(item) {
-        this.all.remove(item);        
+        this.all.remove(item);
     },
-    
-    <div id="method-Ext.AbstractManager-registerType"></div>/**
-     * <p>Registers a new Component constructor, keyed by a new
-     * {@link Ext.Component#xtype}.</p>
-     * <p>Use this method (or its alias {@link Ext#reg Ext.reg}) to register new
-     * subclasses of {@link Ext.Component} so that lazy instantiation may be used when specifying
-     * child Components.
-     * see {@link Ext.Container#items}</p>
-     * @param {String} xtype The mnemonic string by which the Component class may be looked up.
-     * @param {Constructor} cls The new Component class.
+
+<span id='Ext-AbstractManager-method-registerType'>    /**
+</span>     * &lt;p&gt;Registers a new item constructor, keyed by a type key.
+     * @param {String} type The mnemonic string by which the class may be looked up.
+     * @param {Constructor} cls The new instance class.
      */
-    registerType : function(type, cls){
+    registerType : function(type, cls) {
         this.types[type] = cls;
         cls[this.typeName] = type;
     },
-    
-    <div id="method-Ext.AbstractManager-isRegistered"></div>/**
-     * Checks if a Component type is registered.
-     * @param {Ext.Component} xtype The mnemonic string by which the Component class may be looked up
+
+<span id='Ext-AbstractManager-method-isRegistered'>    /**
+</span>     * Checks if an item type is registered.
+     * @param {String} type The mnemonic string by which the class may be looked up
      * @return {Boolean} Whether the type is registered.
      */
     isRegistered : function(type){
-        return this.types[type] !== undefined;    
+        return this.types[type] !== undefined;
     },
-    
-    <div id="method-Ext.AbstractManager-create"></div>/**
-     * Creates and returns an instance of whatever this manager manages, based on the supplied type and config object
+
+<span id='Ext-AbstractManager-method-create'>    /**
+</span>     * Creates and returns an instance of whatever this manager manages, based on the supplied type and config object
      * @param {Object} config The config object
      * @param {String} defaultType If no type is discovered in the config object, we fall back to this type
      * @return {Mixed} The instance of whatever this manager is managing
@@ -93,30 +82,62 @@ Ext.AbstractManager = Ext.extend(Object, {
     create: function(config, defaultType) {
         var type        = config[this.typeName] || config.type || defaultType,
             Constructor = this.types[type];
-        
+
+        //&lt;debug&gt;
         if (Constructor == undefined) {
-            throw new Error(String.format("The '{0}' type has not been registered with this manager", type));
+            Ext.Error.raise(&quot;The '&quot; + type + &quot;' type has not been registered with this manager&quot;);
         }
-        
+        //&lt;/debug&gt;
+
         return new Constructor(config);
     },
-    
-    <div id="method-Ext.AbstractManager-onAvailable"></div>/**
-     * Registers a function that will be called when a Component with the specified id is added to the manager. This will happen on instantiation.
-     * @param {String} id The component {@link Ext.Component#id id}
-     * @param {Function} fn The callback function
-     * @param {Object} scope The scope (<code>this</code> reference) in which the callback is executed. Defaults to the Component.
+
+<span id='Ext-AbstractManager-method-onAvailable'>    /**
+</span>     * Registers a function that will be called when an item with the specified id is added to the manager. This will happen on instantiation.
+     * @param {String} id The item id
+     * @param {Function} fn The callback function. Called with a single parameter, the item.
+     * @param {Object} scope The scope (&lt;code&gt;this&lt;/code&gt; reference) in which the callback is executed. Defaults to the item.
      */
     onAvailable : function(id, fn, scope){
-        var all = this.all;
+        var all = this.all,
+            item;
         
-        all.on("add", function(index, o){
-            if (o.id == id) {
-                fn.call(scope || o, o);
-                all.un("add", fn, scope);
-            }
-        });
+        if (all.containsKey(id)) {
+            item = all.get(id);
+            fn.call(scope || item, item);
+        } else {
+            all.on('add', function(map, key, item){
+                if (key == id) {
+                    fn.call(scope || item, item);
+                    all.un('add', fn, scope);
+                }
+            });
+        }
+    },
+    
+<span id='Ext-AbstractManager-method-each'>    /**
+</span>     * Executes the specified function once for each item in the collection.
+     * Returning false from the function will cease iteration.
+     * 
+     * The paramaters passed to the function are:
+     * &lt;div class=&quot;mdetail-params&quot;&gt;&lt;ul&gt;
+     * &lt;li&gt;&lt;b&gt;key&lt;/b&gt; : String&lt;p class=&quot;sub-desc&quot;&gt;The key of the item&lt;/p&gt;&lt;/li&gt;
+     * &lt;li&gt;&lt;b&gt;value&lt;/b&gt; : Number&lt;p class=&quot;sub-desc&quot;&gt;The value of the item&lt;/p&gt;&lt;/li&gt;
+     * &lt;li&gt;&lt;b&gt;length&lt;/b&gt; : Number&lt;p class=&quot;sub-desc&quot;&gt;The total number of items in the collection&lt;/p&gt;&lt;/li&gt;
+     * &lt;/ul&gt;&lt;/div&gt;
+     * @param {Object} fn The function to execute.
+     * @param {Object} scope The scope to execute in. Defaults to &lt;tt&gt;this&lt;/tt&gt;.
+     */
+    each: function(fn, scope){
+        this.all.each(fn, scope || this);    
+    },
+    
+<span id='Ext-AbstractManager-method-getCount'>    /**
+</span>     * Gets the number of items in the collection.
+     * @return {Number} The number of items in the collection.
+     */
+    getCount: function(){
+        return this.all.getCount();
     }
-});</pre>    
-</body>
-</html>
\ No newline at end of file
+});
+</pre></pre></body></html>
\ No newline at end of file