X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6746dc89c47ed01b165cc1152533605f97eb8e8d..f562e4c6e5fac7bcb445985b99acbea4d706e6f0:/src/AbstractManager.js diff --git a/src/AbstractManager.js b/src/AbstractManager.js index 9e9f3a38..abfb75cf 100644 --- a/src/AbstractManager.js +++ b/src/AbstractManager.js @@ -13,8 +13,6 @@ If you are unsure which license is appropriate for your use, please contact the */ /** - * @class Ext.AbstractManager - * @extends Object * Base Manager class */ Ext.define('Ext.AbstractManager', { @@ -31,9 +29,8 @@ Ext.define('Ext.AbstractManager', { Ext.apply(this, config || {}); /** + * @property {Ext.util.HashMap} all * Contains all of the items currently managed - * @property all - * @type Ext.util.MixedCollection */ this.all = Ext.create('Ext.util.HashMap'); @@ -44,7 +41,7 @@ Ext.define('Ext.AbstractManager', { * 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, undefined if not found. + * @return {Object} The item, undefined if not found. */ get : function(id) { return this.all.get(id); @@ -52,24 +49,32 @@ Ext.define('Ext.AbstractManager', { /** * Registers an item to be managed - * @param {Mixed} item The item to register + * @param {Object} item The item to register */ register: function(item) { + // + var all = this.all, + key = all.getKey(item); + + if (all.containsKey(key)) { + Ext.Error.raise('Registering duplicate id "' + key + '" with this manager'); + } + // this.all.add(item); }, /** * Unregisters an item by removing it from this manager - * @param {Mixed} item The item to unregister + * @param {Object} item The item to unregister */ unregister: function(item) { this.all.remove(item); }, /** - *

Registers a new item constructor, keyed by a type key. + * 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. + * @param {Function} cls The new instance class. */ registerType : function(type, cls) { this.types[type] = cls; @@ -86,17 +91,18 @@ Ext.define('Ext.AbstractManager', { }, /** - * 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 + * @return {Object} The instance of whatever this manager is managing */ create: function(config, defaultType) { var type = config[this.typeName] || config.type || defaultType, Constructor = this.types[type]; // - if (Constructor == undefined) { + if (Constructor === undefined) { Ext.Error.raise("The '" + type + "' type has not been registered with this manager"); } // @@ -105,10 +111,12 @@ Ext.define('Ext.AbstractManager', { }, /** - * Registers a function that will be called when an item with the specified id is added to the manager. This will happen on instantiation. + * 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 (this reference) in which the callback is executed. Defaults to the item. + * @param {Object} scope The scope (this reference) in which the callback is executed. + * Defaults to the item. */ onAvailable : function(id, fn, scope){ var all = this.all, @@ -129,16 +137,12 @@ Ext.define('Ext.AbstractManager', { /** * 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: - *

- * @param {Object} fn The function to execute. - * @param {Object} scope The scope to execute in. Defaults to this. + * @param {Function} fn The function to execute. + * @param {String} fn.key The key of the item + * @param {Number} fn.value The value of the item + * @param {Number} fn.length The total number of items in the collection + * @param {Boolean} fn.return False to cease iteration. + * @param {Object} scope The scope to execute in. Defaults to `this`. */ each: function(fn, scope){ this.all.each(fn, scope || this);