//<Script type="text/javascript">
-console = imports['console.js'];
-Roo = imports['Roo.js'];
-Gio = imports.gi.Gio;
-XN = imports.xnew;
+
-Builder = imports['Builder.js'];
-JSDOC = imports['JSDOC.js'];
+Gio = imports.gi.Gio;
+console = imports.console;
+XObject = imports.XObject.XObject;
+
+
//----------------------- our roo verison
+Base = imports.Builder.Provider.File.Base.Base;
+Gio = imports.gi.Gio;
+File = imports.File.File;
+//JSDOC = imports['JSDOC.js'];
+//----------------------- our roo verison
+var rid = 0;
-Builder.Provider.File.Roo = function(cfg) {
-
- // id ,
- //"name":"Edit Module Details",
- // items :
- //"btype":"FORM", // was to be components...
- //"app":"Builder",
- //"module":"Pman.Tab.BuilderTop2"
- //console.dump(cfg);
-
- if (!cfg.name || !cfg.fullname ) {
- cfg.name = cfg.path.split('/').pop().replace(/\.js$/, '');
- cfg.fullname = (cfg.parent && cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name;
- }
-
-
- this.items = [];
- if (cfg.json) {
- var jstr = JSON.parse(cfg.json);
- this.items = [ jstr ];
- //console.log(cfg.items.length);
- delete cfg.json; // not needed!
- }
- this.cn = [];
- /*
- var p = cfg.items && cfg.items.length && cfg.items[0].parent ? cfg.items[0].parent : false;
-
- // ensure real data is set...
- Roo.apply(this, {
- name : cfg.module,
- parent : p,
- title : cfg.name,
- project : cfg.app
+Roo = XObject.define(
+ function(cfg) {
- });
-
- this.cn = [];
- */
- Builder.Provider.File.Roo.superclass.constructor.call(this, cfg);
-
-
- // super?!?!
- this.id = Roo.id();
- // various loader methods..
-
-}
-
-Roo.extend(Builder.Provider.File.Roo, Builder.Provider.File, {
- setNSID : function(id)
- {
+ // id ,
+ //"name":"Edit Module Details",
+ // items :
+ //"btype":"FORM", // was to be components...
+ //"app":"Builder",
+ //"module":"Pman.Tab.BuilderTop2"
+ //console.dump(cfg);
- this.items[0]['|module'] = id;
-
+ if (!cfg.name || !cfg.fullname ) {
+ cfg.name = cfg.path.split('/').pop().replace(/\.bjs$/, '');
+ //cfg.fullname = (cfg.parent && cfg.parent.length ? (cfg.parent + '.') : '' ) + cfg.name;
+ cfg.fullname = cfg.name;
+ }
- },
-
- loadItems : function(cb)
- {
- console.log("load Items!");
- if (this.items.length) {
- return false;
+
+ this.items = false;
+ if (cfg.json) {
+ var jstr = JSON.parse(cfg.json);
+ this.items = [ jstr ];
+ //console.log(cfg.items.length);
+ delete cfg.json; // not needed!
}
- var file = Gio.file_new_for_path(this.path);
+ this.cn = [];
+ /*
+ var p = cfg.items && cfg.items.length && cfg.items[0].parent ? cfg.items[0].parent : false;
- var _this = this;
- file.read_async(0, null, function(source,result) {
- var stream = source.read_finish(result)
- var dstream = new Gio.DataInputStream.c_new(stream);
-
- var src = dstream.read_until("")
- var tstream = new JSDOC.TextStream(src);
- var tr = new JSDOC.TokenReader( {
- keepWhite : true,
- keepComments : true
- });
- var toks = tr.tokenize(tstream);
- var ts = new JSDOC.Collapse(toks);
- //console.dump(ts.tokens);
- var rd = new JSDOC.RooFile(ts.tokens);
- try {
- rd.parse();
- } catch (e) {
- console.log(e);
- _this.items = [ src ];
- cb();
- return;
- }
-
- console.dump(rd.cfg);
- //!!??? have we got engouth!
- // try parsing self..
- _this.items = [ rd.cfg ];
- cb();
-
+ // ensure real data is set...
+ Roo.apply(this, {
+ name : cfg.module,
+ parent : p,
+ title : cfg.name,
+ project : cfg.app
});
+ this.cn = [];
+ */
+ Roo.superclass.constructor.call(this, cfg);
+
-
+ // super?!?!
+ this.id = 'roo-file-' + (rid++);
+ // various loader methods..
},
-
-
-
- toSource: function()
+ Base,
{
- // dump the file tree back out to a string.
+ doubleStringProps : [
+ 'title',
+ 'legend',
+ 'loadingText',
+ 'emptyText',
+ 'qtip',
+ 'value',
+ 'text'
+ ],
+ modOrder : '001', /// sequence id that this uses.
+ region : 'center',
+ parent : '',
+ title : '', // the title on displayed when loading.
+ disable : '', // use a function to that returns false to disable this..
+ permname: '', /// permission name
- if (typeof(this.items[0]['|module']) != 'undefined') {
- return this.toSourceStdClass();
- }
+ setNSID : function(id)
+ {
+
+ this.items[0]['|module'] = id;
+
+
+ },
- if (this.items[0].region) {
- return this.toSourceLayout();
- }
- return this.toSourceDialog();
+ getType: function() {
+ return 'Roo';
+ },
+
+ loadItems : function(cb)
+ {
+ console.log("load Items!");
+ if (this.items !== false) {
+ return false;
+ }
+ var file = Gio.file_new_for_path(this.path);
+ var _this = this;
+ file.read_async(0, null, function(source,result) {
+ var stream = source.read_finish(result)
+ var dstream = new Gio.DataInputStream.c_new(stream);
+ var src = dstream.read_until("")
+
+ var cfg = JSON.parse(src);
+ print("loaded data");
+ console.dump(cfg);
+ _this.modOrder = cfg.modOrder || '001';
+ _this.name = cfg.name.replace(/\.bjs/, ''); // BC!
+ _this.parent = cfg.parent;
+ _this.permname = cfg.permname || '';
+ _this.title = cfg.title;
+ _this.items = cfg.items || [];
+
+ _this.fixItems(_this, false);
+
+
+
+ cb();
+ /*
+ var tstream = new JSDOC.TextStream(src);
+ var tr = new JSDOC.TokenReader( {
+ keepWhite : true,
+ keepComments : true
+ });
+ var toks = tr.tokenize(tstream);
+ var ts = new JSDOC.Collapse(toks);
+ //console.dump(ts.tokens);
+ var rd = new JSDOC.RooFile(ts.tokens);
+ try {
+ rd.parse();
+ } catch (e) {
+ console.log(e);
+ _this.items = [ src ];
+ cb();
+ return;
+ }
+
+ console.dump(rd.cfg);
+ //!!??? have we got engouth!
+ // try parsing self..
+ _this.items = [ rd.cfg ];
+ cb();
+ */
+
+ });
+
+
+ },
+ /**
+ * old code had broken xtypes and used arrays differently,
+ * this code should try and clean it up..
+ *
+ *
+ */
+ fixItems : function(node, fixthis)
+ {
+ if (fixthis) {
+ // fix xtype.
+ var fn = this.guessName(node);
+ //print("guessname got " + fn);
+ if (fn) {
+ var bits = fn.split('.');
+ node.xtype = bits.pop();
+ node['|xns'] = bits.join('.');
+
+ }
+ // fix array???
+
-
-
- },
-
- outputHeader : function()
- {
- return [
- "//<script type=\"text/javascript\">",
- "",
- "// Auto generated file - created by Builder Module - do not edit directly",
- ""
- ].join("\n");
-
-
- },
- // a standard dialog module.
- toSourceDialog : function()
- {
- var b = this.items[0];
- var o = this.mungePropObj(this.items[0]);
- return [
- this.outputHeader(),
- b['|module'] + " = {",
- "",
- " dialog : false,",
- " callback: false,",
- "",
- " show : function(data, cb)",
- " {",
- " if (!this.dialog) {",
- " this.create();",
- " }",
- "",
- " this.callback = cb;",
- " this.data = data;",
- " this.dialog.show();",
- " if (this.form) {",
- " this.form.reset();",
- " this.form.setValues(data);",
- " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
- " }",
- "",
- " },",
- "",
- " create : function()",
- " {",
- " var _this = this;",
- " this.dialog = Roo.factory(" + this.objectToJsString(o,3) + ");",
- " }",
- "};",
- ""
-
- ].join("\n");
-
-
-
- },
- // a layout compoent
- toSourceLayout : function()
- {
- var b = this.items[0];
- var o = this.mungePropObj(this.items[0]);
+ }
+ if (!node.items || !node.items.length) {
+ return;
+ }
+ var _this = this;
+ var aitems = [];
+ var nitems = [];
+ node.items.forEach(function(i) {
+
+
+
+ _this.fixItems(i, true);
+ if (i.xtype == 'Array') {
+ aitems.push(i);
+ return;
+ }
+ nitems.push(i);
+ });
+ node.items = nitems;
+
+ if (!aitems.length) {
+ return;
+ }
+
+ aitems.forEach(function(i) {
+
+ if (!i.items || !i.items.length) {
+ return;
+ }
+ var prop = i['*prop'] + '[]';
+ // colModel to cm?
+ i.items.forEach(function(c) {
+ c['*prop'] = prop;
+ node.items.push(c);
+
+ });
+
+
+ });
+
+
+ // array handling..
+
+
+
+
+
+ },
- var disabled = typeof(b['|disabled']) == 'undefined' ? (b.disabled || false) : b['disabled'];
+ save : function()
+ {
+ Base.prototype.save.call(this);
+ // now write the js file..
+ var js = this.path.replace(/\.bjs$/, '.js');
+ var d = new Date();
+ var js_src = this.toSource();
+ print("TO SOURCE in " + ((new Date()) - d) + "ms");
+ File.write(js, js_src);
+
+
+
+ },
+ /**
+ * convert xtype for munged output..
+ *
+ */
+ mungeXtype : function(xtype, els)
+ {
+ var bits = xtype.split('.');
+ // assume it has lenght!
+
+ els.push("xtype: '"+ bits.pop()+"'");
+ els.push('xns: '+ bits.join('.'));
+ },
- return [
- this.outputHeader(),
- "",
- "",
- "// register the module first",
- "Pman.on('beforeload', function()",
- "{",
- " Pman.register({",
- " modKey : '" + (b.modkey || "000-unnumbered module") +"',",
- " module : " + b['|module'] + ",",
- " region : '" + (b.region || '') +"',",
- " parent : " + (b.parent || false) + ",",
- " name : \"" + (b.name || "unnamed module") + "\"",
- " disabled : " + disabled +" ",
- " });",
- "});",
- "",
-
- b['|module'] + " = new Roo.util.Observable({",
- "",
- " panel : false,",
- " disabled : false,",
- " parentLayout: false,",
- "",
- " add : function(parentLayout, region)",
- " {",
- "",
- " var _this = this;", // standard avaialbe..
- " this.parentLayout = parentLayout;",
- "",
- " this.panel = parentLayout.addxtype(" + this.objectToJsString(o,3) + ");",
- " this.layout = this.panel.layout;",
- "",
- " }",
- "});",
- ""
+ /**
+ * This needs to use some options on the project
+ * to determine how the file is output..
+ *
+ * At present we are hard coding it..
+ *
+ *
+ */
+ toSource: function()
+ {
+ // dump the file tree back out to a string.
+
+ // we have 2 types = dialogs and components
+ //
+ var top = this.guessName(this.items[0]);
+ if (!top) {
+ return false;
+ }
+ if (top.match(/Dialog/)) {
+ return this.toSourceDialog();
+ }
+ return this.toSourceLayout();
+
+ /*
+ eventually support 'classes??'
+ return this.toSourceStdClass();
+ */
+
+ },
+
+ outputHeader : function()
+ {
+ return [
+ "//<script type=\"text/javascript\">",
+ "",
+ "// Auto generated file - created by app.Builder.js- do not edit directly (at present!)",
+ ""
+ ].join("\n");
+
+
+ },
+ // a standard dialog module.
+ // fixme - this could be alot neater..
+ toSourceDialog : function()
+ {
+ var items = JSON.parse(JSON.stringify(this.items[0]));
+ var o = this.mungeToString(items, false, ' ');
+ return [
+ this.outputHeader(),
+ this.name + " = {",
+ "",
+ " dialog : false,",
+ " callback: false,",
+ "",
+ " show : function(data, cb)",
+ " {",
+ " if (!this.dialog) {",
+ " this.create();",
+ " }",
+ "",
+ " this.callback = cb;",
+ " this.data = data;",
+ " this.dialog.show(this.data._el);",
+ " if (this.form) {",
+ " this.form.reset();",
+ " this.form.setValues(data);",
+ " this.form.fireEvent('actioncomplete', this.form, { type: 'setdata', data: data });",
+ " }",
+ "",
+ " },",
+ "",
+ " create : function()",
+ " {",
+ " var _this = this;",
+ " this.dialog = Roo.factory(" + o + ");",
+ " }",
+ "};",
+ ""
+
+ ].join("\n");
+
+
+ },
+ // a layout compoent
+ toSourceLayout : function()
+ {
+ var items = JSON.parse(JSON.stringify(this.items[0]));
+ var o = this.mungeToString(items, false, ' ');
+
+ var modkey = this.modOrder + '-' + this.name.replace('/[^A-Z]+/ig', '-');
+
+
+ if (this.name.match(/^Pman/)) {
+
+
+ // old BC way we did things..
+ return [
+ this.outputHeader(),
+ "",
+ "",
+ "// register the module first",
+ "Pman.on('beforeload', function()",
+ "{",
+ " Pman.register({",
+ " modKey : '" +modkey+"',",
+ " module : " + this.name + ",",
+ " moduleName : '" + this.name + "',",
+ " region : '" + this.region +"',",
+ " parent : " + (this.parent || 'false') + ",",
+ " name : " + JSON.stringify(this.title || "unnamed module") + ",",
+ " disabled : " + (this.disabled || 'false') +", ",
+ " permname: '" + (this.permname|| '') +"' ",
+ " });",
+ "});",
+ "",
+
+ this.name + " = new Roo.util.Observable({",
+ "",
+ " panel : false,",
+ " disabled : false,",
+ " parentLayout: false,",
+ "",
+ " add : function(parentLayout, region)",
+ " {",
+ "",
+ " var _this = this;", // standard avaialbe..
+ " this.parentLayout = parentLayout;",
+ "",
+ " this.panel = parentLayout.addxtype(" + o + ");",
+ " this.layout = this.panel.layout;",
+ "",
+ " }",
+ "});",
+ ""
+
+
+ ].join("\n");
+ }
- ].join("\n");
- }
-
-
- /*
- getTree : function( o ) {
-
+ return [
+ this.outputHeader(),
+
+ this.name + " = new Roo.XComponent({",
+ " order : '" +modkey+"',",
+ " region : '" + this.region +"',",
+ " parent : "+ (this.parent ? "'" + this.parent + "'" : 'false') + ",",
+ " name : " + JSON.stringify(this.title || "unnamed module") + ",",
+ " disabled : " + (this.disabled || 'false') +", ",
+ " tree : function()",
+ " {",
+ " var _this = this;", // bc
+ " var MODULE = this;", /// this looks like a better name.
+ " return " + o + ';',
+ " }",
+ "});",
+ ""
+
+ ].join("\n");
+
+ },
+
+ guessName : function(ar) // turns the object into full name.
+ {
+ // eg. xns: Roo, xtype: XXX -> Roo.xxx
+ if (!ar) {
+ return false;
+ }
+ var ret = [];
+ ret.push(typeof( ar['|xns'] ) == 'undefined' ? 'Roo' : ar['|xns'] );
+
+
+
+ if (typeof( ar['xtype'] ) == 'undefined' || !ar['xtype'].length) {
+ return false;
+ }
+ var xtype = ar['xtype'] + '';
+ if (xtype[0] == '*') { // prefixes????
+ xtype = xtype.substring(1);
+ }
+ if (xtype.match(/^Roo/)) {
+ // already starts with roo...
+ ret = [];
+ }
+ ret.push(xtype);
+ var str = ret.join('.');
+
+
+
+ var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
+ return pm.getPalete('Roo').guessName(ret.join('.'));
+
+
+
+ },
+ /*
+ getTree : function( o ) {
+
+
+
+ }
+ */
+ getHelpUrl : function(cls)
+ {
+ return 'http://www.akbkhome.com/roojs1/docs/symbols/' + cls + '.html';
+ }
- }
- */
-
});
\ No newline at end of file