X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/f5240829880f87e0cf581c6a296e436fdef0ef80..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/docs/source/AbstractManager.html diff --git a/docs/source/AbstractManager.html b/docs/source/AbstractManager.html index 8dcdc7c3..16cda9bb 100644 --- a/docs/source/AbstractManager.html +++ b/docs/source/AbstractManager.html @@ -1,91 +1,80 @@ - - - - The source code - - - - -
/*!
- * Ext JS Library 3.3.0
- * Copyright(c) 2006-2010 Ext JS, Inc.
- * licensing@extjs.com
- * http://www.extjs.com/license
- */
-
/** - * @class Ext.AbstractManager +Sencha Documentation Project
/**
+ * @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 || {});
-        
-        
/** - * Contains all of the items currently managed + + /** + * 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 = {}; }, - -
/** - * 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, undefined if not found, or null if a - * Class was found. + + /** + * 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, <code>undefined</code> if not found. */ - get : function(id){ + get : function(id) { return this.all.get(id); }, - -
/** - * Registers an item to be managed + + /** + * Registers an item to be managed * @param {Mixed} item The item to register */ register: function(item) { this.all.add(item); }, - -
/** - * Unregisters a component by removing it from this manager + + /** + * 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); }, - -
/** - *

Registers a new Component constructor, keyed by a new - * {@link Ext.Component#xtype}.

- *

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}

- * @param {String} xtype The mnemonic string by which the Component class may be looked up. - * @param {Constructor} cls The new Component class. + + /** + * <p>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; }, - -
/** - * Checks if a Component type is registered. - * @param {Ext.Component} xtype The mnemonic string by which the Component class may be looked up + + /** + * 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; }, - -
/** - * Creates and returns an instance of whatever this manager manages, based on the supplied type and config object + + /** + * 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]; - + + //<debug> if (Constructor == undefined) { - throw new Error(String.format("The '{0}' type has not been registered with this manager", type)); + Ext.Error.raise("The '" + type + "' type has not been registered with this manager"); } - + //</debug> + return new Constructor(config); }, - -
/** - * 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 (this reference) in which the callback is executed. Defaults to the Component. + + /** + * 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 (<code>this</code> 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); + } + }); + } + }, + + /** + * 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: + * <div class="mdetail-params"><ul> + * <li><b>key</b> : String<p class="sub-desc">The key of the item</p></li> + * <li><b>value</b> : Number<p class="sub-desc">The value of the item</p></li> + * <li><b>length</b> : Number<p class="sub-desc">The total number of items in the collection</p></li> + * </ul></div> + * @param {Object} fn The function to execute. + * @param {Object} scope The scope to execute in. Defaults to <tt>this</tt>. + */ + each: function(fn, scope){ + this.all.each(fn, scope || this); + }, + + /** + * Gets the number of items in the collection. + * @return {Number} The number of items in the collection. + */ + getCount: function(){ + return this.all.getCount(); } -});
- - \ No newline at end of file +}); +
\ No newline at end of file