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

		var i_self = this;

		var i_store = Ext.create("Ext.data.Store", {
			fields: ["key", "value"],
			renderer: function (s_key) {

				var i_self = this;
				var i_store = i_self.getStore();

				var i_record = i_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>";

		var o_listConfig = {
			tpl: tpl,
			itemSelector: ".x-boundlist-item",
			width: 400
		};

		Ext.apply(i_self, {
			store: i_store,
			listConfig: o_listConfig
		});

		i_self.callParent();

		i_self.renderer = i_store.renderer;

		var i_designer = i_self.getDesigner();
		var o_types = i_designer.normal.types || {};
		var a_data = [];

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

		i_store.loadRawData(a_data);
	}
});
