1 //<Script type="text/javascript">
5 console = imports.console;
6 XObject = imports.XObject.XObject;
9 //----------------------- our roo verison
10 Base = imports.Builder.Provider.File.Base.Base;
12 File = imports.File.File;
14 //JSDOC = imports['JSDOC.js'];
15 //----------------------- our roo verison
23 //"name":"Edit Module Details",
25 //"btype":"FORM", // was to be components...
27 //"module":"Pman.Tab.BuilderTop2"
30 if (!cfg.name || !cfg.fullname ) {
31 cfg.name = cfg.path.split('/').pop().replace(/\.bjs$/, '');
32 //cfg.fullname = (cfg.parent && cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name;
38 var jstr = JSON.parse(cfg.json);
39 this.items = [ jstr ];
40 //console.log(cfg.items.length);
41 delete cfg.json; // not needed!
45 var p = cfg.items && cfg.items.length && cfg.items[0].parent ? cfg.items[0].parent : false;
47 // ensure real data is set...
58 Roo.superclass.constructor.call(this, cfg);
62 this.id = 'roo-file-' + (rid++);
63 // various loader methods..
68 modOrder : '001', /// sequence id that this uses.
71 title : '', // the title on displayed when loading.
72 disable : '', // use a function to that returns false to disable this..
74 setNSID : function(id)
77 this.items[0]['|module'] = id;
88 loadItems : function(cb)
90 console.log("load Items!");
91 if (this.items !== false) {
94 var file = Gio.file_new_for_path(this.path);
97 file.read_async(0, null, function(source,result) {
98 var stream = source.read_finish(result)
99 var dstream = new Gio.DataInputStream.c_new(stream);
101 var src = dstream.read_until("")
103 var cfg = JSON.parse(src);
104 print("loaded data");
107 _this.name = cfg.name;
108 _this.parent = cfg.parent;
109 _this.title = cfg.title;
110 _this.items = cfg.items || [];
112 _this.fixItems(_this, false);
118 var tstream = new JSDOC.TextStream(src);
119 var tr = new JSDOC.TokenReader( {
123 var toks = tr.tokenize(tstream);
124 var ts = new JSDOC.Collapse(toks);
125 //console.dump(ts.tokens);
126 var rd = new JSDOC.RooFile(ts.tokens);
131 _this.items = [ src ];
136 console.dump(rd.cfg);
137 //!!??? have we got engouth!
138 // try parsing self..
139 _this.items = [ rd.cfg ];
149 * old code had broken xtypes and used arrays differently,
150 * this code should try and clean it up..
154 fixItems : function(node, fixthis)
158 var fn = this.guessName(node);
159 //print("guessname got " + fn);
161 var bits = fn.split('.');
162 node.xtype = bits.pop();
163 node['|xns'] = bits.join('.');
170 if (!node.items || !node.items.length) {
176 node.items.forEach(function(i) {
180 _this.fixItems(i, true);
181 if (i.xtype == 'Array') {
189 if (!aitems.length) {
193 aitems.forEach(function(i) {
195 if (!i.items || !i.items.length) {
198 var prop = i['*prop'] + '[]';
200 i.items.forEach(function(c) {
220 Base.prototype.save.call(this);
221 // now write the js file..
222 var js = this.path.replace(/\.bjs$/, '.js');
223 File.write(js, this.toSource());
229 * convert xtype for munged output..
232 mungeXtype : function(xtype, els)
234 var bits = xtype.split('.');
235 // assume it has lenght!
237 els.push("xtype: '"+ bits.pop()+"'");
238 els.push('xns: '+ bits.join('.'));
242 * This needs to use some options on the project
243 * to determine how the file is output..
245 * At present we are hard coding it..
251 // dump the file tree back out to a string.
253 // we have 2 types = dialogs and components
255 var top = this.guessName(this.items[0]);
259 if (top.match(/Dialog/)) {
260 return this.toSourceDialog();
262 return this.toSourceLayout();
265 eventually support 'classes??'
266 return this.toSourceStdClass();
271 outputHeader : function()
274 "//<script type=\"text/javascript\">",
276 "// Auto generated file - created by app.Builder.js- do not edit directly (at present!)",
282 // a standard dialog module.
283 toSourceDialog : function()
286 var o = this.mungeToString(this.items[0], false, ' ');
294 " show : function(data, cb)",
296 " if (!this.dialog) {",
300 " this.callback = cb;",
301 " this.data = data;",
302 " this.dialog.show();",
304 " this.form.reset();",
305 " this.form.setValues(data);",
306 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
311 " create : function()",
313 " var _this = this;",
314 " this.dialog = Roo.factory(" + o + ");",
325 toSourceLayout : function()
328 var o = this.mungeToString(this.items[0], false, ' ');
330 var modkey = this.modOrder + '-' + this.name.replace('/[^A-Z]+/ig', '-');
337 "// register the module first",
338 "Pman.on('beforeload', function()",
341 " modKey : '" +modkey+"',",
342 " module : " + this.name + ",",
343 " region : '" + this.region +"',",
344 " parent : " + (this.parent || 'false') + ",",
345 " name : \"" + (this.title || "unnamed module") + "\"",
346 " disabled : " + (this.disabled || 'false') +" ",
351 this.name + " = new Roo.util.Observable({",
354 " disabled : false,",
355 " parentLayout: false,",
357 " add : function(parentLayout, region)",
360 " var _this = this;", // standard avaialbe..
361 " this.parentLayout = parentLayout;",
363 " this.panel = parentLayout.addxtype(" + o + ");",
364 " this.layout = this.panel.layout;",
374 guessName : function(ar) // turns the object into full name.
376 // eg. xns: Roo, xtype: XXX -> Roo.xxx
381 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
385 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
388 var xtype = ar['xtype'] + '';
389 if (xtype[0] == '*') { // prefixes????
390 xtype = xtype.substring(1);
392 if (xtype.match(/^Roo/)) {
393 // already starts with roo...
397 var str = ret.join('.');
401 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
402 return pm.getPalete('Roo').guessName(ret.join('.'));
408 getTree : function( o ) {
414 getHelpUrl : function(cls)
416 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';