X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=Builder%2FProvider%2FFile%2FRoo.js;h=db0d28da91201423e04412daaad5a45b8f2f6569;hb=ae36594d7a193ff1b695cf2fc09a66e4e34f8a6b;hp=d6523c3ebd5af924d1a3790d70f9e8b3cec549a2;hpb=a49899b7c7a70f7666faf222acbed91734f944e0;p=app.Builder.js diff --git a/Builder/Provider/File/Roo.js b/Builder/Provider/File/Roo.js old mode 100755 new mode 100644 index d6523c3eb..db0d28da9 --- a/Builder/Provider/File/Roo.js +++ b/Builder/Provider/File/Roo.js @@ -9,12 +9,12 @@ XObject = imports.XObject.XObject; //----------------------- our roo verison Base = imports.Builder.Provider.File.Base.Base; Gio = imports.gi.Gio; - +File = imports.File.File; -JSDOC = imports['JSDOC.js']; +//JSDOC = imports['JSDOC.js']; //----------------------- our roo verison -id = 0; +var rid = 0; Roo = XObject.define( function(cfg) { @@ -28,12 +28,13 @@ Roo = XObject.define( //console.dump(cfg); if (!cfg.name || !cfg.fullname ) { - cfg.name = cfg.path.split('/').pop().replace(/\.js$/, ''); - cfg.fullname = (cfg.parent && cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name; + cfg.name = cfg.path.split('/').pop().replace(/\.bjs$/, ''); + //cfg.fullname = (cfg.parent && cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name; + cfg.fullname = cfg.name; } - this.items = []; + this.items = false; if (cfg.json) { var jstr = JSON.parse(cfg.json); this.items = [ jstr ]; @@ -59,12 +60,27 @@ Roo = XObject.define( // super?!?! - this.id = 'roo-file-' + (id++); + this.id = 'roo-file-' + (rid++); // various loader methods.. }, Base, { - + doubleStringProps : [ + 'title', + 'legend', + 'loadingText', + 'emptyText', + 'qtip', + 'value', + 'text' + ], + modOrder : '001', /// sequence id that this uses. + region : 'center', + parent : '', + title : '', // the title on displayed when loading. + disable : '', // use a function to that returns false to disable this.. + permname: '', /// permission name + setNSID : function(id) { @@ -74,12 +90,15 @@ Roo = XObject.define( }, + getType: function() { + return 'Roo'; + }, - + loadItems : function(cb) { console.log("load Items!"); - if (this.items.length) { + if (this.items !== false) { return false; } var file = Gio.file_new_for_path(this.path); @@ -92,7 +111,19 @@ Roo = XObject.define( var src = dstream.read_until("") var cfg = JSON.parse(src); - _this.items = cfg.items; + print("loaded data"); + console.dump(cfg); + _this.modOrder = cfg.modOrder || '001'; + _this.name = cfg.name.replace(/\.bjs/, ''); // BC! + _this.parent = cfg.parent; + _this.permname = cfg.permname || ''; + _this.title = cfg.title; + _this.items = cfg.items || []; + + _this.fixItems(_this, false); + + + cb(); /* var tstream = new JSDOC.TextStream(src); @@ -125,29 +156,130 @@ Roo = XObject.define( }, - - - - toSource: function() + /** + * old code had broken xtypes and used arrays differently, + * this code should try and clean it up.. + * + * + */ + fixItems : function(node, fixthis) { - // dump the file tree back out to a string. - - if (typeof(this.items[0]['|module']) != 'undefined') { - return this.toSourceStdClass(); + if (fixthis) { + // fix xtype. + var fn = this.guessName(node); + //print("guessname got " + fn); + if (fn) { + var bits = fn.split('.'); + node.xtype = bits.pop(); + node['|xns'] = bits.join('.'); + + } + // fix array??? + + } - - if (this.items[0].region) { - return this.toSourceLayout(); + if (!node.items || !node.items.length) { + return; } - return this.toSourceDialog(); + var _this = this; + var aitems = []; + var nitems = []; + node.items.forEach(function(i) { + + + + _this.fixItems(i, true); + if (i.xtype == 'Array') { + aitems.push(i); + return; + } + nitems.push(i); + }); + node.items = nitems; + if (!aitems.length) { + return; + } + aitems.forEach(function(i) { + if (!i.items || !i.items.length) { + return; + } + var prop = i['*prop'] + '[]'; + // colModel to cm? + i.items.forEach(function(c) { + c['*prop'] = prop; + node.items.push(c); + }); - - + + }); + + + // array handling.. + + + + + }, + + save : function() + { + Base.prototype.save.call(this); + // now write the js file.. + var js = this.path.replace(/\.bjs$/, '.js'); + var d = new Date(); + var js_src = this.toSource(); + print("TO SOURCE in " + ((new Date()) - d) + "ms"); + File.write(js, js_src); + + + + }, + /** + * convert xtype for munged output.. + * + */ + mungeXtype : function(xtype, els) + { + var bits = xtype.split('.'); + // assume it has lenght! + + els.push("xtype: '"+ bits.pop()+"'"); + els.push('xns: '+ bits.join('.')); + }, + + /** + * This needs to use some options on the project + * to determine how the file is output.. + * + * At present we are hard coding it.. + * + * + */ + toSource: function() + { + // dump the file tree back out to a string. + + // we have 2 types = dialogs and components + // + var top = this.guessName(this.items[0]); + if (!top) { + return false; + } + if (top.match(/Dialog/)) { + return this.toSourceDialog(); + } + return this.toSourceLayout(); + + /* + eventually support 'classes??' + return this.toSourceStdClass(); + */ + }, outputHeader : function() @@ -155,20 +287,21 @@ Roo = XObject.define( return [ "//