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 setNSID : function(id)
71 this.items[0]['|module'] = id;
82 loadItems : function(cb)
84 console.log("load Items!");
85 if (this.items !== false) {
88 var file = Gio.file_new_for_path(this.path);
91 file.read_async(0, null, function(source,result) {
92 var stream = source.read_finish(result)
93 var dstream = new Gio.DataInputStream.c_new(stream);
95 var src = dstream.read_until("")
97 var cfg = JSON.parse(src);
101 _this.name = cfg.name;
102 _this.parent = cfg.parent;
103 _this.title = cfg.title;
104 _this.items = cfg.items || [];
106 _this.fixItems(_this, false);
112 var tstream = new JSDOC.TextStream(src);
113 var tr = new JSDOC.TokenReader( {
117 var toks = tr.tokenize(tstream);
118 var ts = new JSDOC.Collapse(toks);
119 //console.dump(ts.tokens);
120 var rd = new JSDOC.RooFile(ts.tokens);
125 _this.items = [ src ];
130 console.dump(rd.cfg);
131 //!!??? have we got engouth!
132 // try parsing self..
133 _this.items = [ rd.cfg ];
143 * old code had broken xtypes and used arrays differently,
144 * this code should try and clean it up..
148 fixItems : function(node, fixthis)
152 var fn = this.guessName(node);
153 //print("guessname got " + fn);
155 var bits = fn.split('.');
156 node.xtype = bits.pop();
157 node['|xns'] = bits.join('.');
164 if (!node.items || !node.items.length) {
170 node.items.forEach(function(i) {
174 _this.fixItems(i, true);
175 if (i.xtype == 'Array') {
183 if (!aitems.length) {
187 aitems.forEach(function(i) {
189 if (!i.items || !i.items.length) {
192 var prop = i['*prop'] + '[]';
194 i.items.forEach(function(c) {
214 Base.prototype.save.call(this);
215 // now write the js file..
221 * convert xtype for munged output..
224 mungeXtype : function(xtype, els)
226 var bits = xtype.split('.');
227 // assume it has lenght!
229 els.push("xtype: '"+ bits.pop()+"'");
230 els.push('xns: '+ bits.join('.'));
234 * This needs to use some options on the project
235 * to determine how the file is output..
237 * At present we are hard coding it..
243 // dump the file tree back out to a string.
245 // we have 2 types = dialogs and components
247 var top = this.guessType(this.items[0]);
248 if (top.match(/Dialog/) {
249 return this.toSourceDialog();
251 return this.toSourceLayout();
254 eventually support 'classes??'
255 return this.toSourceStdClass();
260 outputHeader : function()
263 "//<script type=\"text/javascript\">",
265 "// Auto generated file - created by Builder Module - do not edit directly",
271 // a standard dialog module.
272 toSourceDialog : function()
274 var b = this.items[0];
275 var o = this.mungePropObj(this.items[0]);
278 b['|module'] + " = {",
283 " show : function(data, cb)",
285 " if (!this.dialog) {",
289 " this.callback = cb;",
290 " this.data = data;",
291 " this.dialog.show();",
293 " this.form.reset();",
294 " this.form.setValues(data);",
295 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
300 " create : function()",
302 " var _this = this;",
303 " this.dialog = Roo.factory(" + this.objectToJsString(o,3) + ");",
314 toSourceLayout : function()
316 var b = this.items[0];
317 var o = this.mungePropObj(this.items[0]);
319 var disabled = typeof(b['|disabled']) == 'undefined' ? (b.disabled || false) : b['disabled'];
325 "// register the module first",
326 "Pman.on('beforeload', function()",
329 " modKey : '" + (b.modkey || "000-unnumbered module") +"',",
330 " module : " + b['|module'] + ",",
331 " region : '" + (b.region || '') +"',",
332 " parent : " + (b.parent || false) + ",",
333 " name : \"" + (b.name || "unnamed module") + "\"",
334 " disabled : " + disabled +" ",
339 b['|module'] + " = new Roo.util.Observable({",
342 " disabled : false,",
343 " parentLayout: false,",
345 " add : function(parentLayout, region)",
348 " var _this = this;", // standard avaialbe..
349 " this.parentLayout = parentLayout;",
351 " this.panel = parentLayout.addxtype(" + this.objectToJsString(o,3) + ");",
352 " this.layout = this.panel.layout;",
362 guessName : function(ar) // turns the object into full name.
364 // eg. xns: Roo, xtype: XXX -> Roo.xxx
366 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
370 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
373 var xtype = ar['xtype'] + '';
374 if (xtype[0] == '*') { // prefixes????
375 xtype = xtype.substring(1);
377 if (xtype.match(/^Roo/)) {
378 // already starts with roo...
382 var str = ret.join('.');
386 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
387 return pm.getPalete('Roo').guessName(ret.join('.'));
393 getTree : function( o ) {
399 getHelpUrl : function(cls)
401 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';