Ext.define('Portfolio.designer.ui.uiTypeComboBox', {
	extend: 'Ext.form.ComboBox',
	alias: ['widget.ip2uiTypeComboBox'],
	displayField: 'key',
	valueField: 'key',
	emptyText: '',
	matchFieldWidth: false,
	config: {
		types: null
	},
	queryMode: "local",
	initComponent: function() {

		var me = this;

		me.store = Ext.create('Ext.data.Store', {
			fields: ['key', 'value'],
			renderer: function(s_key) {
				var i_record = this.store.findRecord('key', s_key);
				return (i_record ? i_record.get("value") : s_key);
			}
		});

		var tpl =
		'<table border="0">' +
			'<tpl for=".">' +
				'<tr class="x-boundlist-item">' +
					'<td class="ip2-boundlist-cell" width="100">{key}</td>' +
					'<td class="ip2-boundlist-cell" width="300">{value}</td>' +
				'</tr>' +
			'</tpl>' +
		'</table>';

		me.listConfig = {
			tpl: tpl,
			itemSelector: '.x-boundlist-item',
			width: 400
		};

		me.callParent();

		me.renderer = me.store.renderer;

		var o_types = ip2.loadUItypes();

		a_data = [];

		Ext.Object.each(o_types, function(s_key, o_value) {
			a_data.push({
				key: s_key,
				value: ip2.i18n(o_value.title || "")
			});
		});

		me.store.loadRawData(a_data);
	}
});
