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;
33 cfg.fullname = cfg.name;
39 var jstr = JSON.parse(cfg.json);
40 this.items = [ jstr ];
41 //console.log(cfg.items.length);
42 delete cfg.json; // not needed!
46 var p = cfg.items && cfg.items.length && cfg.items[0].parent ? cfg.items[0].parent : false;
48 // ensure real data is set...
59 Roo.superclass.constructor.call(this, cfg);
63 this.id = 'roo-file-' + (rid++);
64 // various loader methods..
77 modOrder : '001', /// sequence id that this uses.
80 title : '', // the title on displayed when loading.
81 disable : '', // use a function to that returns false to disable this..
82 permname: '', /// permission name
84 setNSID : function(id)
87 this.items[0]['|module'] = id;
98 loadItems : function(cb)
100 console.log("load Items!");
101 if (this.items !== false) {
104 var file = Gio.file_new_for_path(this.path);
107 file.read_async(0, null, function(source,result) {
108 var stream = source.read_finish(result)
109 var dstream = new Gio.DataInputStream.c_new(stream);
111 var src = dstream.read_until("")
113 var cfg = JSON.parse(src);
114 print("loaded data");
117 _this.name = cfg.name.replace(/\.bjs/, ''); // BC!
118 _this.parent = cfg.parent;
119 _this.permname = cfg.permname;
120 _this.title = cfg.title;
121 _this.items = cfg.items || [];
123 _this.fixItems(_this, false);
129 var tstream = new JSDOC.TextStream(src);
130 var tr = new JSDOC.TokenReader( {
134 var toks = tr.tokenize(tstream);
135 var ts = new JSDOC.Collapse(toks);
136 //console.dump(ts.tokens);
137 var rd = new JSDOC.RooFile(ts.tokens);
142 _this.items = [ src ];
147 console.dump(rd.cfg);
148 //!!??? have we got engouth!
149 // try parsing self..
150 _this.items = [ rd.cfg ];
160 * old code had broken xtypes and used arrays differently,
161 * this code should try and clean it up..
165 fixItems : function(node, fixthis)
169 var fn = this.guessName(node);
170 //print("guessname got " + fn);
172 var bits = fn.split('.');
173 node.xtype = bits.pop();
174 node['|xns'] = bits.join('.');
181 if (!node.items || !node.items.length) {
187 node.items.forEach(function(i) {
191 _this.fixItems(i, true);
192 if (i.xtype == 'Array') {
200 if (!aitems.length) {
204 aitems.forEach(function(i) {
206 if (!i.items || !i.items.length) {
209 var prop = i['*prop'] + '[]';
211 i.items.forEach(function(c) {
231 Base.prototype.save.call(this);
232 // now write the js file..
233 var js = this.path.replace(/\.bjs$/, '.js');
234 File.write(js, this.toSource());
240 * convert xtype for munged output..
243 mungeXtype : function(xtype, els)
245 var bits = xtype.split('.');
246 // assume it has lenght!
248 els.push("xtype: '"+ bits.pop()+"'");
249 els.push('xns: '+ bits.join('.'));
253 * This needs to use some options on the project
254 * to determine how the file is output..
256 * At present we are hard coding it..
262 // dump the file tree back out to a string.
264 // we have 2 types = dialogs and components
266 var top = this.guessName(this.items[0]);
270 if (top.match(/Dialog/)) {
271 return this.toSourceDialog();
273 return this.toSourceLayout();
276 eventually support 'classes??'
277 return this.toSourceStdClass();
282 outputHeader : function()
285 "//<script type=\"text/javascript\">",
287 "// Auto generated file - created by app.Builder.js- do not edit directly (at present!)",
293 // a standard dialog module.
294 // fixme - this could be alot neater..
295 toSourceDialog : function()
297 var items = JSON.parse(JSON.stringify(this.items[0]));
298 var o = this.mungeToString(items, false, ' ');
306 " show : function(data, cb)",
308 " if (!this.dialog) {",
312 " this.callback = cb;",
313 " this.data = data;",
314 " this.dialog.show(this.data._el);",
316 " this.form.reset();",
317 " this.form.setValues(data);",
318 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
323 " create : function()",
325 " var _this = this;",
326 " this.dialog = Roo.factory(" + o + ");",
337 toSourceLayout : function()
339 var items = JSON.parse(JSON.stringify(this.items[0]));
340 var o = this.mungeToString(items, false, ' ');
342 var modkey = this.modOrder + '-' + this.name.replace('/[^A-Z]+/ig', '-');
345 if (this.name.match(/^Pman/)) {
348 // old BC way we did things..
353 "// register the module first",
354 "Pman.on('beforeload', function()",
357 " modKey : '" +modkey+"',",
358 " module : " + this.name + ",",
359 " region : '" + this.region +"',",
360 " parent : " + (this.parent || 'false') + ",",
361 " name : " + JSON.stringify(this.title || "unnamed module") + ",",
362 " disabled : " + (this.disabled || 'false') +", ",
363 " permname: '" + (this.permname|| '') +"' ",
368 this.name + " = new Roo.util.Observable({",
371 " disabled : false,",
372 " parentLayout: false,",
374 " add : function(parentLayout, region)",
377 " var _this = this;", // standard avaialbe..
378 " this.parentLayout = parentLayout;",
380 " this.panel = parentLayout.addxtype(" + o + ");",
381 " this.layout = this.panel.layout;",
395 this.name + " = new Roo.XComponent({",
396 " order : '" +modkey+"',",
397 " region : '" + this.region +"',",
398 " parent : "+ (this.parent ? "'" + this.parent + "'" : 'false') + ",",
399 " name : " + JSON.stringify(this.title || "unnamed module") + ",",
400 " disabled : " + (this.disabled || 'false') +", ",
401 " tree : function()",
403 " var _this = this;", // bc
404 " var MODULE = this;", /// this looks like a better name.
405 " return " + o + ';',
414 guessName : function(ar) // turns the object into full name.
416 // eg. xns: Roo, xtype: XXX -> Roo.xxx
421 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
425 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
428 var xtype = ar['xtype'] + '';
429 if (xtype[0] == '*') { // prefixes????
430 xtype = xtype.substring(1);
432 if (xtype.match(/^Roo/)) {
433 // already starts with roo...
437 var str = ret.join('.');
441 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
442 return pm.getPalete('Roo').guessName(ret.join('.'));
448 getTree : function( o ) {
454 getHelpUrl : function(cls)
456 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';