* Fires when this the componnt is built
* @param {Roo.XComponent} c the component
*/
- 'built' : true,
- /**
- * @event buildcomplete
- * Fires on the top level element when all elements have been built
- * @param {Roo.XComponent} c the top level component.
- */
- 'buildcomplete' : true
+ 'built' : true
});
this.region = this.region || 'center'; // default..
*/
items : false,
+ /**
+ * @property _tree
+ * The method that retuns the tree of parts that make up this compoennt
+ * @type {function}
+ */
+ _tree : false,
/**
* render
if (!this.parent) {
- el = el ? Roo.get(el) : false;
+ el = el ? Roo.get(el) : false;
// it's a top level one..
this.parent = {
}
}
-
+ if (!this.parent.el) {
+ // probably an old style ctor, which has been disabled.
+ return;
+
+ }
+ // The 'tree' method is '_tree now'
- var tree = this.tree();
+ var tree = this._tree ? this._tree() : this.tree();
tree.region = tree.region || this.region;
this.el = this.parent.el.addxtype(tree);
this.fireEvent('built', this);
this.panel = this.el;
- this.layout = this.panel.layout;
+ this.layout = this.panel.layout;
+ this.parentLayout = this.parent.layout || false;
}
});
Roo.apply(Roo.XComponent, {
-
+ /**
+ * @property hideProgress
+ * true to disable the building progress bar.. usefull on single page renders.
+ * @type Boolean
+ */
+ hideProgress : false,
/**
* @property buildCompleted
* True when the builder has completed building the interface.
* * @param {Object} details about module
*/
register : function(obj) {
+
+ Roo.XComponent.event.fireEvent('register', obj);
+ switch(typeof(obj.disabled) ) {
+
+ case 'undefined':
+ break;
+
+ case 'function':
+ if ( obj.disabled() ) {
+ return;
+ }
+ break;
+
+ default:
+ if (obj.disabled) {
+ return;
+ }
+ break;
+ }
+
this.modules.push(obj);
},
var _t = this;
Roo.each(this.modules , function (obj)
{
+ Roo.XComponent.event.fireEvent('beforebuild', obj);
+
var opar = obj.parent;
try {
obj.parent = this.toObject(opar);
} catch(e) {
- Roo.log(e.toString());
+ Roo.log("parent:toObject failed: " + e.toString());
return;
}
if (!obj.parent) {
+ Roo.debug && Roo.log("GOT top level module");
+ Roo.debug && Roo.log(obj);
+ obj.modules = new Roo.util.MixedCollection(false,
+ function(o) { return o.order + '' }
+ );
this.topModule = obj;
return;
}
+ // parent is a string (usually a dom element name..)
if (typeof(obj.parent) == 'string') {
this.elmodules.push(obj);
return;
}
if (obj.parent.constructor != Roo.XComponent) {
- Roo.log("Object Parent is not instance of XComponent:" + obj.name)
+ Roo.log("Warning : Object Parent is not instance of XComponent:" + obj.name)
}
if (!obj.parent.modules) {
obj.parent.modules = new Roo.util.MixedCollection(false,
function(o) { return o.order + '' }
);
}
-
+ if (obj.parent.disabled) {
+ obj.disabled = true;
+ }
obj.parent.modules.add(obj);
}, this);
},
// make a flat list in order of modules to build.
var mods = this.topModule ? [ this.topModule ] : [];
- Roo.each(this.elmodules,function(e) { mods.push(e) });
+
+ // elmodules (is a list of DOM based modules )
+ Roo.each(this.elmodules, function(e) {
+ mods.push(e)
+ });
// add modules to their parents..
var addMod = function(m) {
- // Roo.debug && Roo.log(m.modKey);
+ Roo.debug && Roo.log("build Order: add: " + m.name);
- mods.push(m);
- if (m.modules) {
- m.modules.keySort('ASC', cmp );
- m.modules.each(addMod);
- }
+ mods.push(m);
+ if (m.modules && !m.disabled) {
+ Roo.debug && Roo.log("build Order: " + m.modules.length + " child modules");
+ m.modules.keySort('ASC', cmp );
+ Roo.debug && Roo.log("build Order: " + m.modules.length + " child modules (after sort)");
+
+ m.modules.each(addMod);
+ } else {
+ Roo.debug && Roo.log("build Order: no child modules");
+ }
// not sure if this is used any more..
if (m.finalize) {
m.finalize.name = m.name + " (clean up) ";
}
-
+ var msg = "Building Interface...";
// flash it up as modal - so we store the mask!?
- Roo.MessageBox.show({ title: 'loading' });
- Roo.MessageBox.show({
- title: "Please wait...",
- msg: "Building Interface...",
- width:450,
- progress:true,
- closable:false,
- modal: false
-
- });
+ if (!this.hideProgress) {
+ Roo.MessageBox.show({ title: 'loading' });
+ Roo.MessageBox.show({
+ title: "Please wait...",
+ msg: msg,
+ width:450,
+ progress:true,
+ closable:false,
+ modal: false
+
+ });
+ }
var total = mods.length;
var _this = this;
var progressRun = function() {
if (!mods.length) {
Roo.debug && Roo.log('hide?');
- Roo.MessageBox.hide();
- if (_this.topModule) {
- _this.topModule.fireEvent('buildcomplete', _this.topModule);
+ if (!this.hideProgress) {
+ Roo.MessageBox.hide();
}
+ Roo.XComponent.event.fireEvent('buildcomplete', _this.topModule);
+
// THE END...
return false;
}
}
-
- Roo.MessageBox.updateProgress(
- (total - mods.length)/total, "Building Interface " + (total - mods.length) +
+ msg = "Building Interface " + (total - mods.length) +
" of " + total +
- (m.name ? (' - ' + m.name) : '')
- );
+ (m.name ? (' - ' + m.name) : '');
+ Roo.debug && Roo.log(msg);
+ if (!this.hideProgress) {
+ Roo.MessageBox.updateProgress( (total - mods.length)/total, msg );
+ }
// is the module disabled?
// now build
+
+
m.render();
// it's 10 on top level, and 1 on others??? why...
return progressRun.defer(10, _this);
},
+
/**
* Event Object.
*
*
*/
-
-
-
+ event: false,
+ /**
+ * wrapper for event.on - aliased later..
+ * Typically use to register a event handler for register:
+ *
+ * eg. Roo.XComponent.on('register', function(comp) { comp.disable = true } );
+ *
+ */
+ on : false
});
+
+Roo.XComponent.event = new Roo.util.Observable({
+ events : {
+ /**
+ * @event register
+ * Fires when an Component is registered,
+ * set the disable property on the Component to stop registration.
+ * @param {Roo.XComponent} c the component being registerd.
+ *
+ */
+ 'register' : true,
+ /**
+ * @event beforebuild
+ * Fires before each Component is built
+ * can be used to apply permissions.
+ * @param {Roo.XComponent} c the component being registerd.
+ *
+ */
+ 'beforebuild' : true,
+ /**
+ * @event buildcomplete
+ * Fires on the top level element when all elements have been built
+ * @param {Roo.XComponent} the top level component.
+ */
+ 'buildcomplete' : true
+
+ }
+});
+
+Roo.XComponent.on = Roo.XComponent.event.on.createDelegate(Roo.XComponent.event);
\ No newline at end of file