3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
18 * Provides a registry of available Plugin classes indexed by a mnemonic code known as the Plugin's ptype.
20 * A plugin may be specified simply as a *config object* as long as the correct `ptype` is specified:
23 * ptype: 'gridviewdragdrop',
24 * dragText: 'Drag and drop to reorganize'
27 * Or just use the ptype on its own:
31 * Alternatively you can instantiate the plugin with Ext.create:
33 * Ext.create('Ext.view.plugin.AutoComplete', {
34 * ptype: 'gridviewdragdrop',
35 * dragText: 'Drag and drop to reorganize'
38 Ext.define('Ext.PluginManager', {
39 extend: 'Ext.AbstractManager',
40 alternateClassName: 'Ext.PluginMgr',
45 * Creates a new Plugin from the specified config object using the config object's ptype to determine the class to
47 * @param {Object} config A configuration object for the Plugin you wish to create.
48 * @param {Function} defaultType (optional) The constructor to provide the default Plugin type if the config object does not
49 * contain a `ptype`. (Optional if the config contains a `ptype`).
50 * @return {Ext.Component} The newly instantiated Plugin.
52 //create: function(plugin, defaultType) {
53 // if (plugin instanceof this) {
56 // var type, config = {};
58 // if (Ext.isString(plugin)) {
62 // type = plugin[this.typeName] || defaultType;
66 // return Ext.createByAlias('plugin.' + type, config);
70 create : function(config, defaultType){
74 return Ext.createByAlias('plugin.' + (config.ptype || defaultType), config);
77 // Prior system supported Singleton plugins.
78 //var PluginCls = this.types[config.ptype || defaultType];
79 //if (PluginCls.init) {
82 // return new PluginCls(config);
87 * Returns all plugins registered with the given type. Here, 'type' refers to the type of plugin, not its ptype.
88 * @param {String} type The type to search for
89 * @param {Boolean} defaultsOnly True to only return plugins of this type where the plugin's isDefault property is
91 * @return {Ext.AbstractPlugin[]} All matching plugins
93 findByType: function(type, defaultsOnly) {
97 for (var name in types) {
98 if (!types.hasOwnProperty(name)) {
101 var item = types[name];
103 if (item.type == type && (!defaultsOnly || (defaultsOnly === true && item.isDefault))) {
112 * Shorthand for {@link Ext.PluginManager#registerType}
113 * @param {String} ptype The ptype mnemonic string by which the Plugin class
115 * @param {Function} cls The new Plugin class.
119 Ext.preg = function() {
120 return Ext.PluginManager.registerType.apply(Ext.PluginManager, arguments);