// it may not be loaded yet..
return true;
}
- pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(
- this.get('/LeftTree.model').listAllTypes()));
+ pm.load(
+ this.get('/LeftTree').getPaleteProvider().gatherList(
+ this.get('/LeftTree.model').listAllTypes()
+ )
+ );
if (render && render.redraw) {
render.redraw();
}
var _this = this;
function addall(li)
{
- li.forEach(function(el) {
+ var el;
+ for (var i =0 ; i < li.length; i++ ) {
+ el = li[i];
+
// this is specific to roo!!!?
if (!el) { // skip empty?
return;
addall(el.items);
}
- });
+ };
}
} else {
this.el.append(ret);
}
- print(JSON.stringify(ret,null,4));
- print('call nodeToJSON: ' + tr[i]);
+ //print(JSON.stringify(ret,null,4));
+ //print('call nodeToJSON: ' + tr[i]);
var body = this.nodeToJSON(tr[i]);
- print(body);
+ //print(body);
//this.el.set_value(ret.iter, 0, '' _ [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
//this.el.set_value(ret.iter, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
//this.el.set_value(ret.iter, 2, [GObject.TYPE_STRING, body ]);
},
loadFile : function(f) {
//console.dump(f);
+ print("LOADFILE");
this.el.clear();
this.file = f;
return;
}
print("LOAD");
- print(JSON.stringify(f.items, null,4));
+ //print(JSON.stringify(f.items, null,4));
//console.dump(f.items);
this.load(f.items);
this.get('/LeftTree.view').el.expand_all();
this.currentTree = this.toJS(false, false)[0];
- console.dump(this.currentTree);
+ //console.dump(this.currentTree);
this.currentTree = this.currentTree || { items: [] };
this.get('/LeftTree').renderView();
- console.dump(this.map);
+ // console.dump(this.map);
//var RightPalete = imports.Builder.RightPalete.RightPalete;
var pm = this.get('/RightPalete.model');
// set up provider..
},
nodeToJS : function (treepath, with_id)
{
- print("nodeToJS : WITHID: "+ with_id);
+ //print("nodeToJS : WITHID: "+ with_id);
var iter = treepath; // API used to be iter here..
if (typeof(iter) == 'string') {
var ret = {};
},
toJS : function(treepath, with_id)
{
- print("toJS : WITHID: "+ with_id);
+ //print("toJS : WITHID: "+ with_id);
var iter = treepath; // API used to be iter here..
pack : "set_model",
init : function() {
XObject.prototype.init.call(this);
- this.el.set_column_types ( 2, [
+ this.el.set_column_types ( 2, [
GObject.TYPE_STRING, // real key
GObject.TYPE_STRING // real type
var pm = imports.ProjectManager.ProjectManager;
var _this = this;
pm.on('changed', function() {
- print("caught changed hook on project manager - reloading data");
- _this.loadData(pm.projects);
+ print("caught changed hook on project manager - reloading data");
+ _this.loadData(pm.projects);
});
},
data.forEach(function(p) {
el.append(na);
- print(JSON.stringify(XObject.keys(na)));
- print(typeof(na.iter));
+ //print(JSON.stringify(XObject.keys(na)));
+ //print(typeof(na.iter));
//print(JSON.stringify(iter))
el.set_value(na.iter, 0, p.fn);
el.set_value(na.iter, 1, p.name);
items : [
{
xtype: Gtk.TreeView,
+
listeners : {
cursor_changed : function (self) {
- var ret = {};
- if (this.selection.count_selected_rows() < 1) {
- //XN.get('Builder.LeftTree.model').
- this.get('/LeftTree.model').load( false);
-
- return;
- }
- var model = this.get('/LeftProjectTree.model');
- //console.log('changed');
- var s = this.selection;
- s.get_selected(ret);
- var value = ''+ ret.model.get_value(ret.iter, 2).value.get_string();
- //console.log(JSON.stringify(value,null,4));// id..
- console.log("OUT?" + value);// id..
- var file = this.get('/LeftProjectTree').project.getById(value);
-
- file.items = false;
- console.log(file);
+
+ var model = this.get('/LeftProjectTree.model');
+
+
+
+ if (model.loading) {
-
-
- var nb = this.get('/LeftTopPanel.expander');
- nb.el.expanded = false;
- nb.onCollapse();
- //nb.listeners.activate.call(nb);
- //_expander.el.set_expanded(false);
-
- var ltm = this.get('/LeftTree.model');
- ltm.loadFile(file);
+
+ return;
+ }
+ print("LOADING IS FALSE");
+ var ret = {};
+ if (this.selection.count_selected_rows() < 1) {
+ //XN.get('Builder.LeftTree.model').
+ this.get('/LeftTree.model').load( false);
- return true;
+ return;
+ }
+ //console.log('changed');
+ var s = this.selection;
+ s.get_selected(ret);
+ var value = ''+ ret.model.get_value(ret.iter, 2).value.get_string();
+ //console.log(JSON.stringify(value,null,4));// id..
+ console.log("OUT?" + value);// id..
+ var file = this.get('/LeftProjectTree').project.getById(value);
+
+ file.items = false;
+ console.log(file);
+
+
+
+ var nb = this.get('/LeftTopPanel.expander');
+ nb.el.expanded = false;
+ nb.onCollapse();
+ //nb.listeners.activate.call(nb);
+ //_expander.el.set_expanded(false);
+
+ var ltm = this.get('/LeftTree.model');
+ ltm.loadFile(file);
+
+ return true;
}
},
id : "view",
xtype: Gtk.TreeStore,
pack : "set_model",
id : "model",
+ loading : false,
init : function() {
XObject.prototype.init.call(this);
this.el.set_column_types ( 3, [
},
loadProject : function(pr) {
print("LOAD PROJECT");
- this.el.clear();
- if (!pr) {
- return;
- }
-
- this.get('/LeftProjectTree').project = pr;
- this.load(pr.toTree());
- this.get('/LeftProjectTree.view').el.expand_all();
+ var model = this.get('/LeftProjectTree.model');
+ model.loading = true;
+
+ this.el.clear();
+ if (!pr) {
+ return;
+ }
+
+ this.get('/LeftProjectTree').project = pr;
+
+ this.load(pr.toTree());
+
+ this.get('/LeftProjectTree.view').el.expand_all();
+ model.loading = false;
+
},
load : function(tr,iter) {
// console.dump(tr);
- console.log('Project tree load: ' + tr.length);
- var cret = {};
- //this.insert(citer,iter,0);
-
- var _this = this;
- tr.forEach(function (r) {
- if (!iter) {
- _this.el.append(cret);
- } else {
- _this.el.insert(cret,iter,-1);
- }
- _this.el.set_value(cret.iter, 0, '' + r.getTitle() ); // title
- _this.el.set_value(cret.iter, 1, '' + r.getTitleTip()); // tip
- _this.el.set_value(cret.iter, 2, '' + r.id ); //id
- if (r.cn && r.cn.length) {
- _this.load(r.cn, cret.iter);
- }
-
- });
+
+
+ console.log('Project tree load: ' + tr.length);
+ var cret = {};
+ //this.insert(citer,iter,0);
+
+ var _this = this;
+ // recursive...
+ tr.forEach(function (r) {
+ if (!iter) {
+ _this.el.append(cret);
+ } else {
+ _this.el.insert(cret,iter,-1);
+ }
+ _this.el.set_value(cret.iter, 0, '' + r.getTitle() ); // title
+ _this.el.set_value(cret.iter, 1, '' + r.getTitleTip()); // tip
+ _this.el.set_value(cret.iter, 2, '' + r.id ); //id
+ if (r.cn && r.cn.length) {
+ _this.load(r.cn, cret.iter);
+ }
+
+ });
+
},
getValue : function(iter, col) {
var gval = ''+ this.el.get_value(iter, col).value.get_string();
label : "ID",
listeners : {
activate : function (self) {
-
+
this.get('/LeftPanel.model').add( {
key : 'id',
type : 'string',
xtype: Gtk.TreeView,
listeners : {
cursor_changed : function (self) {
+ // this is getting fired when we are loading elements..
+ if (this.get('/MidPropTree.model').loading) {
+ return;
+ }
+
var iret = {};
- //console.log('changed');
+ //console.log('changed');
var m = this.get('model');
- if (!this.selection){
- this.selection = this.el.get_selection();
- }
-
+ if (!this.selection){
+ this.selection = this.el.get_selection();
+ }
+
var s = this.selection;
if (!s.get_selected(iret)) {
- return;
- }
+ return;
+ }
var tp = m.el.get_path(iret.iter).to_string();
if (etype != 'events') {
key = '|' + key;
}
-
+ print("cursor_changed: ADDding to left panel model");
this.get('/LeftPanel.model').add({
key : key,
type : type,
//if (type.indexOf('.') > -1 || type.toLowerCase() == 'boolean') {
// key = '|' + key;
// }
-
+ print("cursor_changed: ADDding to left panel model");
this.get('/LeftPanel.model').add( {
key : key,
type : type,
xtype: Gtk.ListStore,
id : "model",
pack : "set_model",
+ loading : false,
getValue : function(treepath, col)
{
var tp = new Gtk.TreePath.from_string (treepath);
] );
},
showData : function(type) {
- this.el.clear();
+
+
+ this.loading = true;
+ this.el.clear();
if (!this.get('/MidPropTree').activeElement || !type) {
+ this.loading = false;
return; // no active element
}
print ("GOT " + elementList.length + " items for " + fullpath + "|" + type);
// console.dump(elementList);
+ // scope of this is off..??
for(var i =0 ; i < elementList.length; i++) {
this.el.set_value(iret.iter, 5, type);
}
-
+ this.loading = false;
}
},
{
xtype: Gtk.Button,
listeners : {
clicked : function (self) {
- this.get('/RightBrowser.view').redraws = 99;
- this.get('/RightBrowser.view').renderJS(null,true);
- }
+
+ var view = this.get('/RightBrowser.view');
+ //this.get('/RightBrowser.view').redraws = 99;
+ view.refreshRequired = true;
+ view.lastRedraw = false;
+ view.renderedData = false;
+ view.renderJS(null,true);
+
+ }
},
label : "Full Redraw",
pack : "pack_start,false,false,0"
this.ready = true;
- if (this.pendingRedraw) {
- this.pendingRedraw = false;
- this.refreshRequired = true;
- }
+ //if (this.pendingRedraw) {
+ // this.pendingRedraw = false;
+ // this.refreshRequired = true;
+ //}
//var js = this.get('/LeftTree.model').toJS();
//if (js && js[0]) {
// this.renderJS(js[0]);
return true; // do not display anything...
},
console_message : function (self, object, p0, p1) {
- print(object);
- // console.log(object);
+ print(object);
+ // console.log(object);
-
- if (object.match(/variable/) && object.match(/Builder/)) {
- print("got builder missing message");
- this.refreshRequired = true;
- this.lastRedraw = 0;
- this.runRefresh();
- return true;
- }
+
+ if (object.match(/variable/) && object.match(/Builder/)) {
+ print("got builder missing message");
+ this.refreshRequired = true;
+ this.lastRedraw = 0;
+ this.runRefresh();
+ return true;
+ }
if (!object.match(/^\{/)) {
this.get('/LeftTree.view').selectNode(tg[0]);
ret = true;
- }
+ }
+
if (ret && typeof(val['set']) != 'undefined') {
- this.get('/LeftPanel.model').add({
- key : val['set'],
- val : val['value']
- });
+ print("console messages: ADDding to left panel model");
+ //
+ //this.get('/LeftPanel.model').add({
+ // key : val['set'],
+ // val : val['value']
+ // });
//console.log('active node: ' + this.activeNode);
}
if (!this.refreshRequired) {
- // print("no refresh required");
+ // print("no refresh required");
return;
}
this.runhtml = this.runhtml || '';
- if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
+ var file = this.get('/LeftTree.model').file;
+ var items = file.items;
+ file.items = this.get('/LeftTree.model').toJS(false, false);
+ //file.items[0].background = false;
+ //var p = file.parent;
+ //file.parent = false;
+
+ var js_src = file.toSourcePreview();
+ if (this.renderedData && js_src == this.renderedData && project.runhtml == this.runhtml) {
+ // unless it' sforced..
+
+ return;
+ }
+
+ this.renderedData = js_src;
+ // restore stuff..
+ //file.parent = p;
+ //file.items = items;
+ //print("send source as " + js_src);
+
+ js_src += "\n" +
+ "Roo.onReady(function() {\n" +
+ "if (" + file.name +".show) " + file.name +".show({});\n" +
+ "Roo.XComponent.build();\n" +
+ "});\n";
+
+
+
+
+
+ //if ((project.runhtml != this.runhtml) || (this.redraws > 10)) {
// then we need to reload the browser using
// load_html_string..
// then trigger a redraw once it's loaded..
this.pendingRedraw = true;
- var runhtml = '<script type="text/javascript">' + "\n" ;
- runhtml +=imports.File.File.read(__script_path__ + '/../builder.html.js') + "\n";
- runhtml += '</script>'+ "\n" ;
+ var runhtml = '<script type="text/javascript">' + "\n" ;
+ runhtml +=imports.File.File.read(__script_path__ + '/../builder.html.js') + "\n";
+ runhtml += '</script>'+ "\n" ;
this.runhtml = project.runhtml;
// need to modify paths
-
+ this.lastRedraw= new Date();
var html = imports.File.File.read(__script_path__ + '/../builder.html');
- html = html.replace('</head>', runhtml + this.runhtml + '</head>');
- print("LOAD HTML " + html);
+ html = html.replace('</head>',
+ runhtml +
+ this.runhtml +
+ '<script type="text/javascript">' + "\n" +
+ js_src + "\n" +
+ '</script>' +
+
+ '</head>');
+ //print("LOAD HTML " + html);
this.el.load_html_string( html ,
//fixme - should be a config option!
'http://localhost/app.Builder/'
// should trigger load_finished! - which in truns shoudl set refresh Required;
return;
- }
-
- file.items = this.get('/LeftTree.model').toJS(false, false);
- var js_src = file.toSource();
+
// not used.
//this.renderedData = data;
//var str = JSON.stringify(data) ;
console.log('not loaded yet');
}
this.lastRedraw = new Date();
-
- this.el.execute_script("Builder.render(" + JSON.stringify(js_src) + ");");
+
+ this.el.execute_script("Builder.render(" +
+ JSON.stringify(js_src) +
+ "," +
+ JSON.stringify(file.name) +
+ ");");
print( "before render" + this.lastRedraw);
print( "after render" + (new Date()));
return;
}
- console.dump(args);
+ //console.dump(args);
args.unshift(el);
//if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
//Seed.print('args: ' + args.length);