var Widget = require ('./widget');

module.exports = new Class
({
	Extends: Widget

	,builder: null
	
	,builderInit: function (path)
	{
		var builder = new Vn.Builder ();
		builder.signalData = this;
		builder.loadXml (path, this.doc);
		this.builderResultInit (builder);
	}
	
	,builderInitString: function (xmlString)
	{
		var builder = new Vn.Builder ();
		builder.signalData = this;
		builder.loadFromString (xmlString, this.doc);
		this.builderResultInit (builder);
	}
	
	,builderResultInit: function (builder)
	{
		var res = this.builder = builder.load ();
		this._node = res.$('main');
		res.link ();
	}

	,$: function (id)
	{
		if (this.builder)
			return this.builder.getById (id);
			
		return null;
	}

	,_destroy: function ()
	{
		if (this.builder)
			this.builder.unref ();

		this.parent ();
	}
});