X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/0494b8d9b9bb03ab6c22b34dae81261e3cd7e3e6..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/util/AbstractManager.js diff --git a/src/util/AbstractManager.js b/src/util/AbstractManager.js deleted file mode 100644 index 477756bd..00000000 --- a/src/util/AbstractManager.js +++ /dev/null @@ -1,112 +0,0 @@ -/*! - * Ext JS Library 3.3.1 - * Copyright(c) 2006-2010 Sencha Inc. - * licensing@sencha.com - * http://www.sencha.com/license - */ -/** - * @class Ext.AbstractManager - * @extends Object - * Base Manager class - extended by ComponentMgr and PluginMgr - */ -Ext.AbstractManager = Ext.extend(Object, { - typeName: 'type', - - constructor: function(config) { - Ext.apply(this, config || {}); - - /** - * Contains all of the items currently managed - * @property all - * @type Ext.util.MixedCollection - */ - this.all = new Ext.util.MixedCollection(); - - 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. - */ - get : function(id){ - return this.all.get(id); - }, - - /** - * 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 - * @param {Mixed} item The item to unregister - */ - unregister: function(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. - */ - 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 - * @return {Boolean} Whether the type is registered. - */ - isRegistered : function(type){ - return this.types[type] !== undefined; - }, - - /** - * 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 - */ - create: function(config, defaultType) { - var type = config[this.typeName] || config.type || defaultType, - Constructor = this.types[type]; - - if (Constructor == undefined) { - throw new Error(String.format("The '{0}' type has not been registered with this manager", type)); - } - - 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. - */ - onAvailable : function(id, fn, scope){ - var all = this.all; - - all.on("add", function(index, o){ - if (o.id == id) { - fn.call(scope || o, o); - all.un("add", fn, scope); - } - }); - } -}); \ No newline at end of file