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;
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(/\.js$/, '');
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.
73 setNSID : function(id)
76 this.items[0]['|module'] = id;
87 loadItems : function(cb)
89 console.log("load Items!");
90 if (this.items !== false) {
93 var file = Gio.file_new_for_path(this.path);
96 file.read_async(0, null, function(source,result) {
97 var stream = source.read_finish(result)
98 var dstream = new Gio.DataInputStream.c_new(stream);
100 var src = dstream.read_until("")
102 var cfg = JSON.parse(src);
103 print("loaded data");
106 _this.name = cfg.name;
107 _this.parent = cfg.parent;
108 _this.title = cfg.title;
109 _this.items = cfg.items || [];
111 _this.fixItems(_this, false);
117 var tstream = new JSDOC.TextStream(src);
118 var tr = new JSDOC.TokenReader( {
122 var toks = tr.tokenize(tstream);
123 var ts = new JSDOC.Collapse(toks);
124 //console.dump(ts.tokens);
125 var rd = new JSDOC.RooFile(ts.tokens);
130 _this.items = [ src ];
135 console.dump(rd.cfg);
136 //!!??? have we got engouth!
137 // try parsing self..
138 _this.items = [ rd.cfg ];
148 * old code had broken xtypes and used arrays differently,
149 * this code should try and clean it up..
153 fixItems : function(node, fixthis)
157 var fn = this.guessName(node);
158 //print("guessname got " + fn);
160 var bits = fn.split('.');
161 node.xtype = bits.pop();
162 node['|xns'] = bits.join('.');
169 if (!node.items || !node.items.length) {
175 node.items.forEach(function(i) {
179 _this.fixItems(i, true);
180 if (i.xtype == 'Array') {
188 if (!aitems.length) {
192 aitems.forEach(function(i) {
194 if (!i.items || !i.items.length) {
197 var prop = i['*prop'] + '[]';
199 i.items.forEach(function(c) {
219 Base.prototype.save.call(this);
220 // now write the js file..
226 * convert xtype for munged output..
229 mungeXtype : function(xtype, els)
231 var bits = xtype.split('.');
232 // assume it has lenght!
234 els.push("xtype: '"+ bits.pop()+"'");
235 els.push('xns: '+ bits.join('.'));
239 * This needs to use some options on the project
240 * to determine how the file is output..
242 * At present we are hard coding it..
248 // dump the file tree back out to a string.
250 // we have 2 types = dialogs and components
252 var top = this.guessType(this.items[0]);
253 if (top.match(/Dialog/) {
254 return this.toSourceDialog();
256 return this.toSourceLayout();
259 eventually support 'classes??'
260 return this.toSourceStdClass();
265 outputHeader : function()
268 "//<script type=\"text/javascript\">",
270 "// Auto generated file - created by Builder Module - do not edit directly",
276 // a standard dialog module.
277 toSourceDialog : function()
279 var b = this.items[0];
280 var o = this.mungePropObj(this.items[0]);
283 b['|module'] + " = {",
288 " show : function(data, cb)",
290 " if (!this.dialog) {",
294 " this.callback = cb;",
295 " this.data = data;",
296 " this.dialog.show();",
298 " this.form.reset();",
299 " this.form.setValues(data);",
300 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
305 " create : function()",
307 " var _this = this;",
308 " this.dialog = Roo.factory(" + this.objectToJsString(o,3) + ");",
319 toSourceLayout : function()
321 var b = this.items[0];
322 var o = this.mungeToString(this.items[0], false, ' ');
324 var modkey = this.modOrder + '-' + this.name.replace('/[^A-Z]+/ig', '-');
331 "// register the module first",
332 "Pman.on('beforeload', function()",
335 " modKey : '" +modkey+"',",
336 " module : " + this.name + ",",
337 " region : '" + this.region +"',",
338 " parent : " + (this.parent || 'false') + ",",
339 " name : \"" + (b.title || "unnamed module") + "\"",
340 " disabled : " + disabled +" ",
345 b['|module'] + " = new Roo.util.Observable({",
348 " disabled : false,",
349 " parentLayout: false,",
351 " add : function(parentLayout, region)",
354 " var _this = this;", // standard avaialbe..
355 " this.parentLayout = parentLayout;",
357 " this.panel = parentLayout.addxtype(" + this.objectToJsString(o,3) + ");",
358 " this.layout = this.panel.layout;",
368 guessName : function(ar) // turns the object into full name.
370 // eg. xns: Roo, xtype: XXX -> Roo.xxx
372 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
376 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
379 var xtype = ar['xtype'] + '';
380 if (xtype[0] == '*') { // prefixes????
381 xtype = xtype.substring(1);
383 if (xtype.match(/^Roo/)) {
384 // already starts with roo...
388 var str = ret.join('.');
392 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
393 return pm.getPalete('Roo').guessName(ret.join('.'));
399 getTree : function( o ) {
405 getHelpUrl : function(cls)
407 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';