{

	xtype: 'container',

	requires: [
		'Ext.ux.itemreference.Reference'
	],
	layout: "fit",

	isDirty: function() {

		var widget = this;
		var isDirty = widget.productReference.isDirty();

		return isDirty;
	},

	onInitialize: function(widget, owner) {

		if ( owner._isDataTrackerReady ) {
			init();
		}
		else {
			owner.on({
				'datatrackerinit': {
					fn: function () {
						init();
					},
					single: true
				}
			});
		}

		function init () {

			var track = owner.getDataTrack(),
				parent;

			track.each(function(item) {
				if ( item.self.entityEditor ) {
					parent = item.self;
				}
			});

			var i_reference = Ext.create('Ext.ux.itemreference.Reference', {
				trackerParent: parent
			});

			widget.productReference = i_reference;

			widget.add(i_reference);

			widget.relayEvents(widget.productReference, ['savecomplete']);
		}

	},

	doSave: function(f_callback) {

		console.log('/admin/ip2Base/widgets/productreference.widget: this.productReference.doSave has to have a callback or an event so we know when we done saving!');

		this.productReference.doSave();

		f_callback && f_callback();
	},

	doDelete: function(f_callback) {

		console.log('/admin/ip2Base/widgets/productreference.widget: this.productReference.doDelete has to have a callback or an event so we know when we done deleting!');

		this.productReference.doDelete();

		f_callback && f_callback();
	}
}
