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..
83 setNSID : function(id)
86 this.items[0]['|module'] = id;
97 loadItems : function(cb)
99 console.log("load Items!");
100 if (this.items !== false) {
103 var file = Gio.file_new_for_path(this.path);
106 file.read_async(0, null, function(source,result) {
107 var stream = source.read_finish(result)
108 var dstream = new Gio.DataInputStream.c_new(stream);
110 var src = dstream.read_until("")
112 var cfg = JSON.parse(src);
113 print("loaded data");
116 _this.name = cfg.name.replace(/\.bjs/, ''); // BC!
117 _this.parent = cfg.parent;
118 _this.title = cfg.title;
119 _this.items = cfg.items || [];
121 _this.fixItems(_this, false);
127 var tstream = new JSDOC.TextStream(src);
128 var tr = new JSDOC.TokenReader( {
132 var toks = tr.tokenize(tstream);
133 var ts = new JSDOC.Collapse(toks);
134 //console.dump(ts.tokens);
135 var rd = new JSDOC.RooFile(ts.tokens);
140 _this.items = [ src ];
145 console.dump(rd.cfg);
146 //!!??? have we got engouth!
147 // try parsing self..
148 _this.items = [ rd.cfg ];
158 * old code had broken xtypes and used arrays differently,
159 * this code should try and clean it up..
163 fixItems : function(node, fixthis)
167 var fn = this.guessName(node);
168 //print("guessname got " + fn);
170 var bits = fn.split('.');
171 node.xtype = bits.pop();
172 node['|xns'] = bits.join('.');
179 if (!node.items || !node.items.length) {
185 node.items.forEach(function(i) {
189 _this.fixItems(i, true);
190 if (i.xtype == 'Array') {
198 if (!aitems.length) {
202 aitems.forEach(function(i) {
204 if (!i.items || !i.items.length) {
207 var prop = i['*prop'] + '[]';
209 i.items.forEach(function(c) {
229 Base.prototype.save.call(this);
230 // now write the js file..
231 var js = this.path.replace(/\.bjs$/, '.js');
232 File.write(js, this.toSource());
238 * convert xtype for munged output..
241 mungeXtype : function(xtype, els)
243 var bits = xtype.split('.');
244 // assume it has lenght!
246 els.push("xtype: '"+ bits.pop()+"'");
247 els.push('xns: '+ bits.join('.'));
251 * This needs to use some options on the project
252 * to determine how the file is output..
254 * At present we are hard coding it..
260 // dump the file tree back out to a string.
262 // we have 2 types = dialogs and components
264 var top = this.guessName(this.items[0]);
268 if (top.match(/Dialog/)) {
269 return this.toSourceDialog();
271 return this.toSourceLayout();
274 eventually support 'classes??'
275 return this.toSourceStdClass();
280 outputHeader : function()
283 "//<script type=\"text/javascript\">",
285 "// Auto generated file - created by app.Builder.js- do not edit directly (at present!)",
291 // a standard dialog module.
292 // fixme - this could be alot neater..
293 toSourceDialog : function()
295 var items = JSON.parse(JSON.stringify(this.items[0]));
296 var o = this.mungeToString(items, false, ' ');
304 " show : function(data, cb)",
306 " if (!this.dialog) {",
310 " this.callback = cb;",
311 " this.data = data;",
312 " this.dialog.show(this.data._el);",
314 " this.form.reset();",
315 " this.form.setValues(data);",
316 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
321 " create : function()",
323 " var _this = this;",
324 " this.dialog = Roo.factory(" + o + ");",
335 toSourceLayout : function()
337 var items = JSON.parse(JSON.stringify(this.items[0]));
338 var o = this.mungeToString(items, false, ' ');
340 var modkey = this.modOrder + '-' + this.name.replace('/[^A-Z]+/ig', '-');
343 if (this.name.match(/^Pman/)) {
346 // old BC way we did things..
351 "// register the module first",
352 "Pman.on('beforeload', function()",
355 " modKey : '" +modkey+"',",
356 " module : " + this.name + ",",
357 " region : '" + this.region +"',",
358 " parent : " + (this.parent || 'false') + ",",
359 " name : " + JSON.stringify(this.title || "unnamed module") + ",",
360 " disabled : " + (this.disabled || 'false') +" ",
361 " permname: '" + (this.permname|| '') +"' ",
366 this.name + " = new Roo.util.Observable({",
369 " disabled : false,",
370 " parentLayout: false,",
372 " add : function(parentLayout, region)",
375 " var _this = this;", // standard avaialbe..
376 " this.parentLayout = parentLayout;",
378 " this.panel = parentLayout.addxtype(" + o + ");",
379 " this.layout = this.panel.layout;",
393 this.name + " = new Roo.XComponent({",
394 " order : '" +modkey+"',",
395 " region : '" + this.region +"',",
396 " parent : "+ (this.parent ? "'" + this.parent + "'" : 'false') + ",",
397 " name : " + JSON.stringify(this.title || "unnamed module") + ",",
398 " disabled : " + (this.disabled || 'false') +", ",
399 " tree : function()",
401 " var _this = this;", // bc
402 " var MODULE = this;", /// this looks like a better name.
403 " return " + o + ';',
412 guessName : function(ar) // turns the object into full name.
414 // eg. xns: Roo, xtype: XXX -> Roo.xxx
419 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
423 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
426 var xtype = ar['xtype'] + '';
427 if (xtype[0] == '*') { // prefixes????
428 xtype = xtype.substring(1);
430 if (xtype.match(/^Roo/)) {
431 // already starts with roo...
435 var str = ret.join('.');
439 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
440 return pm.getPalete('Roo').guessName(ret.join('.'));
446 getTree : function( o ) {
452 getHelpUrl : function(cls)
454 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';