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..
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.title = cfg.title;
120 _this.items = cfg.items || [];
122 _this.fixItems(_this, false);
128 var tstream = new JSDOC.TextStream(src);
129 var tr = new JSDOC.TokenReader( {
133 var toks = tr.tokenize(tstream);
134 var ts = new JSDOC.Collapse(toks);
135 //console.dump(ts.tokens);
136 var rd = new JSDOC.RooFile(ts.tokens);
141 _this.items = [ src ];
146 console.dump(rd.cfg);
147 //!!??? have we got engouth!
148 // try parsing self..
149 _this.items = [ rd.cfg ];
159 * old code had broken xtypes and used arrays differently,
160 * this code should try and clean it up..
164 fixItems : function(node, fixthis)
168 var fn = this.guessName(node);
169 //print("guessname got " + fn);
171 var bits = fn.split('.');
172 node.xtype = bits.pop();
173 node['|xns'] = bits.join('.');
180 if (!node.items || !node.items.length) {
186 node.items.forEach(function(i) {
190 _this.fixItems(i, true);
191 if (i.xtype == 'Array') {
199 if (!aitems.length) {
203 aitems.forEach(function(i) {
205 if (!i.items || !i.items.length) {
208 var prop = i['*prop'] + '[]';
210 i.items.forEach(function(c) {
230 Base.prototype.save.call(this);
231 // now write the js file..
232 var js = this.path.replace(/\.bjs$/, '.js');
233 File.write(js, this.toSource());
239 * convert xtype for munged output..
242 mungeXtype : function(xtype, els)
244 var bits = xtype.split('.');
245 // assume it has lenght!
247 els.push("xtype: '"+ bits.pop()+"'");
248 els.push('xns: '+ bits.join('.'));
252 * This needs to use some options on the project
253 * to determine how the file is output..
255 * At present we are hard coding it..
261 // dump the file tree back out to a string.
263 // we have 2 types = dialogs and components
265 var top = this.guessName(this.items[0]);
269 if (top.match(/Dialog/)) {
270 return this.toSourceDialog();
272 return this.toSourceLayout();
275 eventually support 'classes??'
276 return this.toSourceStdClass();
281 outputHeader : function()
284 "//<script type=\"text/javascript\">",
286 "// Auto generated file - created by app.Builder.js- do not edit directly (at present!)",
292 // a standard dialog module.
293 // fixme - this could be alot neater..
294 toSourceDialog : function()
296 var items = JSON.parse(JSON.stringify(this.items[0]));
297 var o = this.mungeToString(items, false, ' ');
305 " show : function(data, cb)",
307 " if (!this.dialog) {",
311 " this.callback = cb;",
312 " this.data = data;",
313 " this.dialog.show(this.data._el);",
315 " this.form.reset();",
316 " this.form.setValues(data);",
317 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
322 " create : function()",
324 " var _this = this;",
325 " this.dialog = Roo.factory(" + o + ");",
336 toSourceLayout : function()
338 var items = JSON.parse(JSON.stringify(this.items[0]));
339 var o = this.mungeToString(items, false, ' ');
341 var modkey = this.modOrder + '-' + this.name.replace('/[^A-Z]+/ig', '-');
344 if (this.name.match(/^Pman/)) {
347 // old BC way we did things..
352 "// register the module first",
353 "Pman.on('beforeload', function()",
356 " modKey : '" +modkey+"',",
357 " module : " + this.name + ",",
358 " region : '" + this.region +"',",
359 " parent : " + (this.parent || 'false') + ",",
360 " name : " + JSON.stringify(this.title || "unnamed module") + ",",
361 " disabled : " + (this.disabled || 'false') +", ",
362 " permname: '" + (this.permname|| '') +"' ",
367 this.name + " = new Roo.util.Observable({",
370 " disabled : false,",
371 " parentLayout: false,",
373 " add : function(parentLayout, region)",
376 " var _this = this;", // standard avaialbe..
377 " this.parentLayout = parentLayout;",
379 " this.panel = parentLayout.addxtype(" + o + ");",
380 " this.layout = this.panel.layout;",
394 this.name + " = new Roo.XComponent({",
395 " order : '" +modkey+"',",
396 " region : '" + this.region +"',",
397 " parent : "+ (this.parent ? "'" + this.parent + "'" : 'false') + ",",
398 " name : " + JSON.stringify(this.title || "unnamed module") + ",",
399 " disabled : " + (this.disabled || 'false') +", ",
400 " tree : function()",
402 " var _this = this;", // bc
403 " var MODULE = this;", /// this looks like a better name.
404 " return " + o + ';',
413 guessName : function(ar) // turns the object into full name.
415 // eg. xns: Roo, xtype: XXX -> Roo.xxx
420 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
424 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
427 var xtype = ar['xtype'] + '';
428 if (xtype[0] == '*') { // prefixes????
429 xtype = xtype.substring(1);
431 if (xtype.match(/^Roo/)) {
432 // already starts with roo...
436 var str = ret.join('.');
440 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
441 return pm.getPalete('Roo').guessName(ret.join('.'));
447 getTree : function( o ) {
453 getHelpUrl : function(cls)
455 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';