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);
154 var bits = fn.split('.');
155 node.xtype = bits.pop();
156 node['|xns'] = bits.join('.');
162 if (!node.items || !node.items.length) {
168 node.items.forEach(function(i) {
172 _this.fixItems(i, true);
173 if (i.xtype == 'Array') {
181 if (!aitems.length) {
185 aitems.forEach(function(i) {
187 if (!i.items || !i.items.length) {
190 var prop = i['*prop'] + '[]';
192 i.items.forEach(function(c) {
212 // dump the file tree back out to a string.
214 if (typeof(this.items[0]['|module']) != 'undefined') {
215 return this.toSourceStdClass();
218 if (this.items[0].region) {
219 return this.toSourceLayout();
221 return this.toSourceDialog();
232 outputHeader : function()
235 "//<script type=\"text/javascript\">",
237 "// Auto generated file - created by Builder Module - do not edit directly",
243 // a standard dialog module.
244 toSourceDialog : function()
246 var b = this.items[0];
247 var o = this.mungePropObj(this.items[0]);
250 b['|module'] + " = {",
255 " show : function(data, cb)",
257 " if (!this.dialog) {",
261 " this.callback = cb;",
262 " this.data = data;",
263 " this.dialog.show();",
265 " this.form.reset();",
266 " this.form.setValues(data);",
267 " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
272 " create : function()",
274 " var _this = this;",
275 " this.dialog = Roo.factory(" + this.objectToJsString(o,3) + ");",
286 toSourceLayout : function()
288 var b = this.items[0];
289 var o = this.mungePropObj(this.items[0]);
291 var disabled = typeof(b['|disabled']) == 'undefined' ? (b.disabled || false) : b['disabled'];
297 "// register the module first",
298 "Pman.on('beforeload', function()",
301 " modKey : '" + (b.modkey || "000-unnumbered module") +"',",
302 " module : " + b['|module'] + ",",
303 " region : '" + (b.region || '') +"',",
304 " parent : " + (b.parent || false) + ",",
305 " name : \"" + (b.name || "unnamed module") + "\"",
306 " disabled : " + disabled +" ",
311 b['|module'] + " = new Roo.util.Observable({",
314 " disabled : false,",
315 " parentLayout: false,",
317 " add : function(parentLayout, region)",
320 " var _this = this;", // standard avaialbe..
321 " this.parentLayout = parentLayout;",
323 " this.panel = parentLayout.addxtype(" + this.objectToJsString(o,3) + ");",
324 " this.layout = this.panel.layout;",
334 guessName : function(ar) // turns the object into full name.
336 // eg. xns: Roo, xtype: XXX -> Roo.xxx
338 ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
342 if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
345 var xtype = ar['xtype'] + '';
346 if (xtype == '*') { // prefixes????
347 xtype = xtype.substring(1);
349 if (xtype.match(/^Roo/)) {
350 // already starts with roo...
354 var str = ret.join('.');
356 var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
357 return pm.getPalete('Roo').guessName(ret.join('.'));
363 getTree : function( o ) {
369 getHelpUrl : function(cls)
371 return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';