Ext.define("IceCap.ux.form.panel.TabPanel", {

	extend: "Ext.tab.Panel",

	alias: [
		"widget.tabPanel"
	],

	listeners: {
		afterrender: {
			fn: function(i_panel) {

				var i_self = this;

				i_self.initKeyMap();
			}
		}
	},

	config: {
		keyMap: null
	},

	initComponent: function() {

		var i_self = this;

		i_self.callParent(arguments);
	},

	initKeyMap: function() {

		var i_self = this;

		var a_bindings = [{
			key: "1234567890",
			ctrl: true,
			alt: false,
			handler: function(n_keyCode, i_event) {

				i_event.stopEvent();

				var n_tab = n_keyCode - 49;

				var a_items = i_self.items;

				if (n_tab > a_items.length) {
					n_tab = 0;
				}

				i_self.setActiveTab(n_tab);
			}
		}];

		var i_keyMap = Ext.create("Ext.util.KeyMap", {
			target: i_self.getEl(),
			binding: a_bindings
		});

		i_self.setKeyMap(i_keyMap);
	}
});
