{
xtype: Gtk.Menu,
pack : "set_submenu",
- listeners : {
-
- },
items : [
{
xtype: Gtk.MenuItem,
{
xtype: Gtk.Menu,
pack : "set_submenu",
- listeners : {
-
- },
items : [
{
xtype: Gtk.MenuItem,
html = html.replace('</head>', project.runhtml + '</head>');
- var jsstr = JSON.stringify(js[0]);
+ var jsstr = JSON.stringify(js[0], null, 4);
var runbuilder = '<script type="text/javascript">' + "\n" +
" Builder.render(" + jsstr + ");\n" +
xtype: Gtk.MenuItem,
label : "_Help",
use_underline : true,
- listeners : {
-
- },
pack : "add",
items : [
{
xtype: Gtk.Menu,
pack : "set_submenu",
- listeners : {
-
- },
items : [
{
xtype: Gtk.MenuItem,
items : [
{
xtype: Gtk.Expander,
- label : "Select Project",
- id : "expander",
- pack : "pack_start,false,true",
- init : function() {
- XObject.prototype.init.call(this);
- this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
- },
listeners : {
activate : function (self) {
var nb = this.get('/LeftTopPanel.notebook');
return true;
}
+ },
+ id : "expander",
+ label : "Select Project or File",
+ pack : "pack_start,false,true",
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.add_events (Gdk.EventMask.BUTTON_MOTION_MASK );
}
},
{
items : [
{
xtype: Gtk.ScrolledWindow,
+ id : "LeftTree",
pack : "add",
- shadow_type : Gtk.ShadowType.IN,
- init : function() {
- XObject.prototype.init.call(this);
- this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ getActiveElement : function() { // return path to actie node.
+
+ var path = this.getActivePath();
+ if (!path) {
+ return false;
+ }
+ var iter = new Gtk.TreeIter();
+ this.get('model').el.get_iter_from_string(iter, path);
+
+ var value = new GObject.Value('');
+ this.get('model').el.get_value(iter, 2, value);
+
+ return JSON.parse(value.value);
+ },
+ getActiveFile : function() {
+ return this.get('model').file;
+ },
+ getActivePath : function() {
+ var model = this.get('model');
+ var view = this.get('view');
+ if (view.selection.count_selected_rows() < 1) {
+ return false;
+ }
+ var iter = new Gtk.TreeIter();
+
+ view.selection.get_selected(model.el, iter);
+ return model.el.get_path(iter).to_string();
},
- id : "LeftTree",
getPaleteProvider : function() {
var model = this.get('model');
var pm = imports.Builder.Provider.ProjectManager.ProjectManager;
return pm.getPalete(model.file.getType());
},
- renderView : function() {
- var render = this.getRenderer();
- var model = this.get('model');
- if (render) {
- render.renderJS(model.toJS(false,true)[0]);
- } else {
- print("NO RENDER JS METHOD?");
- }
- },
getRenderer : function() {
switch( this.getActiveFile().getType()) {
}
},
- getActivePath : function() {
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+ },
+ renderView : function() {
+ var render = this.getRenderer();
var model = this.get('model');
- var view = this.get('view');
- if (view.selection.count_selected_rows() < 1) {
- return false;
+ if (render) {
+ render.renderJS(model.toJS(false,true)[0]);
+ } else {
+ print("NO RENDER JS METHOD?");
}
- var iter = new Gtk.TreeIter();
-
- view.selection.get_selected(model.el, iter);
- return model.el.get_path(iter).to_string();
- },
- getActiveFile : function() {
- return this.get('model').file;
- },
- getActiveElement : function() {
-
- var path = this.getActivePath();
- if (!path) {
- return false;
- }
- var iter = new Gtk.TreeIter();
- this.get('model').el.get_iter_from_string(iter, path);
-
- var value = new GObject.Value('');
- this.get('model').el.get_value(iter, 2, value);
-
- return JSON.parse(value.value);
},
+ shadow_type : Gtk.ShadowType.IN,
items : [
{
xtype: Gtk.TreeView,
items : [
{
xtype: Gtk.TreeStore,
- pack : "set_model",
- id : "model",
- init : function() {
- XObject.prototype.init.call(this);
- this.el.set_column_types ( 3, [
- GObject.TYPE_STRING, // title
- GObject.TYPE_STRING, // tip
- GObject.TYPE_STRING // source..
- ] );
- },
activePath : false,
+ currentTree : false,
+ id : "model",
+ pack : "set_model",
changed : function(n, refresh) {
print("MODEL CHANGED CALLED" + this.activePath);
if (this.activePath) {
}
},
- loadFile : function(f) {
- //console.dump(f);
- this.el.clear();
- this.file = f;
-
- if (!f) {
- console.log('missing file');
- return;
- }
-
- // load the file if not loaded..
- if (f.items === false) {
- var _this = this;
- f.loadItems(function() {
- _this.loadFile(f);
- });
- return;
-
- }
- this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);
-
- if (f.items.length && typeof(f.items[0]) == 'string') {
-
- this.get('/RightEditor').el.show();
- this.get('/RightEditor.view').load( f.items[0]);
- return;
- }
- print("LOAD");
- //console.dump(f.items);
- this.load(f.items);
- this.get('/LeftTree.view').el.expand_all();
+ deleteSelected : function() {
+ this.get('/LeftTree.view').blockChanges = true;
+ var old_iter = new Gtk.TreeIter();
+ var s = this.get('/LeftTree.view').selection;
+ s.get_selected(this.el, old_iter);
+ var path = this.el.get_path(old_iter).to_string();
- if (!f.items.length) {
- // single item..
-
- this.get('/Window.leftvpaned').el.set_position(80);
- // select first...
- this.get('/LeftTree.view').el.set_cursor(
- new Gtk.TreePath.from_string('0'), null, false);
-
-
- } else {
- this.get('/Window.leftvpaned').el.set_position(200);
- }
-
-
- //print("hide right editior");
- this.get('/RightEditor').el.hide();
- //print("set current tree");
- this.currentTree = this.toJS(false, false)[0];
- //console.dump(this.currentTree);
- this.currentTree = this.currentTree || { items: [] };
- this.get('/LeftTree').renderView();
- //console.dump(this.map);
- //var RightPalete = imports.Builder.RightPalete.RightPalete;
- var pm = this.get('/RightPalete.model');
- // set up provider..
+ this.activePath= false;
+ s.unselect_all();
+
+ this.activePath= false;
+ var iter = new Gtk.TreeIter();
+ this.el.get_iter_from_string(iter, path);
+ this.el.remove(iter);
+
+ // rebuild treemap. -- depreciated.!!
+ this.map = {};
+ this.treemap = { };
+ //this.toJS(null, true) // does not do anything?
+ this.activePath= false;
+ this.changed(false,true);
+ this.get('/LeftTree.view').blockChanges = false;
+ },
+ dropNode : function(target_data, node) {
+ print("drop Node");
+ // console.dump(node);
+ // console.dump(target_data);
+ var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
+
+ print("add " + tp + "@" + target_data[1] );
+ var parent = tp;
+ var after = false;
+ if (tp && target_data[1] < 2) { // before or after..
+ var ar = target_data[0].split(':');
+ ar.pop();
+ parent = new Gtk.TreePath.from_string( ar.join(':') );
+ after = tp;
+ }
+ var n_iter = new Gtk.TreeIter();
+ var iter_par = new Gtk.TreeIter();
+ var iter_after = after ? new Gtk.TreeIter() : false;
+
+
+
+ if (parent !== false) {
+ this.el.get_iter(iter_par, parent);
+ } else {
+ iter_par = null;
+ }
+
+
+ if (tp && after) {
+ print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
+ this.el.get_iter(iter_after, after);
+ this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
+ n_iter, iter_par, iter_after);
- this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
+ } else {
+ this.el.append(n_iter, iter_par);
- if (!this.get('/RightPalete').provider) {
- print ("********* PALETE PROVIDER MISSING?!!");
+ }
+
+ if (typeof(node) == 'string') {
+ var ar = node.split('.');
+ var xtype = ar.pop();
+
+ node = {
+ '|xns' : ar.join('.'),
+ 'xtype' : xtype
+ };
+ if (target_data.length == 3 && target_data[2].length) {
+ node['*prop'] = target_data[2];
}
- this.get('/LeftTree').renderView();
+ node = this.get('/DialogTemplateSelect').show(node);
- pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
+ }
+ // work out what kind of packing to use..
+ if (typeof(node.pack) == 'undefined' && parent !== false) {
+ var pal = this.get('/LeftTree').getPaleteProvider();
+ if (pal.name == 'Gtk') {
+ var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
+ var cname = pal.guessName(node);
+ node.pack = pal.getDefaultPack(pname, cname);
+ }
+ }
+
+
+ var xitems = [];
+ if (node.items) {
+ xitems = node.items;
+ delete node.items;
+ }
+ // load children - if it has any..
+
+ if (xitems) {
+ this.load(xitems, n_iter);
+ this.get('/LeftTree.view').el.expand_row(this.el.get_path(n_iter), true);
+ }
+ if (tp && (xitems || after)) {
+ this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
+ }
+ // wee need to get the empty proptypes from somewhere..
+
+ //var olditer = this.activeIter;
+ this.activePath = this.el.get_path(n_iter).to_string();
+
+ // changed actually set's the node data..
+ this.changed(node, true);
+
+
+
+ this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
+
+ //Builder.MidPropTree._model.load(node);
+ //Builder.MidPropTree._win.hideWin();
+ //Builder.LeftPanel._model.load( node);
+
-
- this.get('/Window.view-notebook').el.set_current_page(
- this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
-
},
findDropNode : function(treepath_str, targets) {
return [];
},
- dropNode : function(target_data, node) {
- print("drop Node");
- console.dump(node);
- console.dump(target_data);
- var tp = target_data[0].length ? new Gtk.TreePath.from_string( target_data[0] ) : false;
-
- print("add " + tp + "@" + target_data[1] );
- var parent = tp;
- var after = false;
- if (tp && target_data[1] < 2) { // before or after..
- var ar = target_data[0].split(':');
- ar.pop();
- parent = new Gtk.TreePath.from_string( ar.join(':') );
- after = tp;
+ getIterValue : function (iter, col) {
+ var gval = new GObject.Value('');
+ this.el.get_value(iter, col ,gval);
+ return gval.value;
+
+
+ },
+ init : function() {
+ XObject.prototype.init.call(this);
+ this.el.set_column_types ( 3, [
+ GObject.TYPE_STRING, // title
+ GObject.TYPE_STRING, // tip
+ GObject.TYPE_STRING // source..
+ ] );
+ },
+ listAllTypes : function() {
+ var s = this.get('/LeftTree.view').selection;
+ print ("LIST ALL TYPES: " + s.count_selected_rows() );
+
+ if (s.count_selected_rows() > 0) {
+ var iter = new Gtk.TreeIter();
+ s.get_selected(this.el, iter);
+
+ // set some properties of the tree for use by the dropped element.
+ var value = new GObject.Value('');
+ this.el.get_value(iter, 2, value);
+ var data = JSON.parse(value.value);
+
+
+ var xname = this.get('/LeftTree.model').file.guessName(data);
+ console.log('selected:' + xname);
+ if (xname.length) {
+ return [ xname ];
+ }
+ return []; // could not find it..
+ }
+
+ var ret = [ ];
+
+ var _this = this;
+ function addall(li)
+ {
+ li.forEach(function(el) {
+ // this is specific to roo!!!?
+ if (!el) { // skip empty?
+ return;
}
- var n_iter = new Gtk.TreeIter();
- var iter_par = new Gtk.TreeIter();
- var iter_after = after ? new Gtk.TreeIter() : false;
-
-
-
- if (parent !== false) {
- this.el.get_iter(iter_par, parent);
- } else {
- iter_par = null;
+ var fullpath = _this.file.guessName(el);
+ if (fullpath.length && ret.indexOf(fullpath) < 0) {
+ ret.push(fullpath);
}
- if (tp && after) {
- print(target_data[1] > 0 ? 'insert_after' : 'insert_before');
- this.el.get_iter(iter_after, after);
- this.el[ target_data[1] > 0 ? 'insert_after' : 'insert_before'](
- n_iter, iter_par, iter_after);
-
- } else {
- this.el.append(n_iter, iter_par);
-
+ if (el.items && el.items.length) {
+ addall(el.items);
}
- if (typeof(node) == 'string') {
- var ar = node.split('.');
- var xtype = ar.pop();
-
- node = {
- '|xns' : ar.join('.'),
- 'xtype' : xtype
- };
- if (target_data.length == 3 && target_data[2].length) {
- node['*prop'] = target_data[2];
+ });
+
+
+ }
+
+ addall([this.currentTree]);
+
+ // only if we have nothing, should we add '*top'
+ if (!ret.length) {
+ ret = [ '*top' ];
+ }
+ //console.log('all types in tree');
+ //console.dump(ret);
+
+ return ret;
+
+ },
+ load : function(tr,iter)
+ {
+ var citer = new Gtk.TreeIter();
+ //this.insert(citer,iter,0);
+ for(var i =0 ; i < tr.length; i++) {
+ if (iter) {
+ this.el.insert(citer,iter,-1);
+ } else {
+ this.el.append(citer);
}
+ this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
+ this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
+ this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
+ if (tr[i].items && tr[i].items.length) {
+ this.load(tr[i].items, citer);
+ }
+ }
+ },
+ loadFile : function(f) {
+ //console.dump(f);
+ this.el.clear();
+ this.file = f;
+
+ if (!f) {
+ console.log('missing file');
+ return;
}
- // work out what kind of packing to use..
- if (typeof(node.pack) == 'undefined' && parent !== false) {
- var pal = this.get('/LeftTree').getPaleteProvider();
-
- var pname = pal.guessName(this.singleNodeToJS(parent.to_string()));
- print ("PNAME : " + pname);
- var cname = pal.guessName(node);
- print ("CNAME : " + cname);
- node.pack = pal.getDefaultPack(pname, cname);
-
+
+ // load the file if not loaded..
+ if (f.items === false) {
+ var _this = this;
+ f.loadItems(function() {
+ _this.loadFile(f);
+ });
+ return;
}
+ this.get('/Window').setTitle(f.project.getName() + ' - ' + f.name);
+ if (f.items.length && typeof(f.items[0]) == 'string') {
- var xitems = [];
- if (node.items) {
- xitems = node.items;
- delete node.items;
+ this.get('/RightEditor').el.show();
+ this.get('/RightEditor.view').load( f.items[0]);
+ return;
}
- // load children - if it has any..
+ print("LOAD");
+ print(JSON.stringify(f.items, null,4));
+ //console.dump(f.items);
+ this.load(f.items);
+ this.get('/LeftTree.view').el.expand_all();
- if (xitems) {
- this.load(xitems, n_iter);
- }
- if (tp && (xitems || after)) {
- this.get('/LeftTree.view').el.expand_row(this.el.get_path(iter_par), true);
+ if (!f.items.length) {
+ // single item..
+
+ this.get('/Window.leftvpaned').el.set_position(80);
+ // select first...
+ this.get('/LeftTree.view').el.set_cursor(
+ new Gtk.TreePath.from_string('0'), null, false);
+
+
+ } else {
+ this.get('/Window.leftvpaned').el.set_position(200);
}
- // wee need to get the empty proptypes from somewhere..
- //var olditer = this.activeIter;
- this.activePath = this.el.get_path(n_iter).to_string();
-
- // changed actually set's the node data..
- this.changed(node, true);
+ //print("hide right editior");
+ this.get('/RightEditor').el.hide();
+ //print("set current tree");
+ this.currentTree = this.toJS(false, false)[0];
+ //console.dump(this.currentTree);
+ this.currentTree = this.currentTree || { items: [] };
+ this.get('/LeftTree').renderView();
+ //console.dump(this.map);
+ //var RightPalete = imports.Builder.RightPalete.RightPalete;
+ var pm = this.get('/RightPalete.model');
+ // set up provider..
+ this.get('/RightPalete').provider = this.get('/LeftTree').getPaleteProvider();
- this.get('/LeftTree.view').el.set_cursor(this.el.get_path(n_iter), null, false);
+ if (!this.get('/RightPalete').provider) {
+ print ("********* PALETE PROVIDER MISSING?!!");
+ }
+ this.get('/LeftTree').renderView();
- //Builder.MidPropTree._model.load(node);
- //Builder.MidPropTree._win.hideWin();
- //Builder.LeftPanel._model.load( node);
+ pm.load( this.get('/LeftTree').getPaleteProvider().gatherList(this.listAllTypes()));
+
+ this.get('/Window.view-notebook').el.set_current_page(
+ this.get('/LeftTree.model').file.getType()== 'Roo' ? 0 : -1);
+
},
moveNode : function(target_data, action) {
//print("MOVE NODE");
this.activePath= false;
this.changed(false,true);
},
- deleteSelected : function() {
- this.get('/LeftTree.view').blockChanges = true;
- var old_iter = new Gtk.TreeIter();
- var s = this.get('/LeftTree.view').selection;
- s.get_selected(this.el, old_iter);
- var path = this.el.get_path(old_iter).to_string();
-
- this.activePath= false;
- s.unselect_all();
+ nodeTip : function(c) {
+ var ret = this.nodeTitle(c,true);
+ var funcs = '';
- this.activePath= false;
- var iter = new Gtk.TreeIter();
- this.el.get_iter_from_string(iter, path);
- this.el.remove(iter);
-
- // rebuild treemap. -- depreciated.!!
- this.map = {};
- this.treemap = { };
- //this.toJS(null, true) // does not do anything?
- this.activePath= false;
- this.changed(false,true);
- this.get('/LeftTree.view').blockChanges = false;
- },
- currentTree : false,
- listAllTypes : function() {
- var s = this.get('/LeftTree.view').selection;
- print ("LIST ALL TYPES: " + s.count_selected_rows() );
- if (s.count_selected_rows() > 0) {
- var iter = new Gtk.TreeIter();
- s.get_selected(this.el, iter);
+ for( var i in c) {
- // set some properties of the tree for use by the dropped element.
- var value = new GObject.Value('');
- this.el.get_value(iter, 2, value);
- var data = JSON.parse(value.value);
-
-
- var xname = this.get('/LeftTree.model').file.guessName(data);
- console.log('selected:' + xname);
- if (xname.length) {
- return [ xname ];
+ if (!i.length || i[0] != '|') {
+ continue;
}
- return []; // could not find it..
+ if (i == '|init') {
+ continue;
+ }
+ if (typeof(c[i]) != 'string') {
+ continue;
+ }
+ //print("prop : " + i + ':' + c[i]);
+ if (!c[i].match(new RegExp('function'))) {
+ continue;
+ }
+ funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
+
}
+ if (funcs.length) {
+ ret+="\n\nMethods:" + funcs;
+ }
+ return ret;
- var ret = [ ];
+ },
+ nodeTitle : function(c, renderfull) {
+ var txt = [];
+ c = c || {};
+ var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
+ if (sr) txt.push('<s>');
+ if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
- var _this = this;
- function addall(li)
- {
- li.forEach(function(el) {
- // this is specific to roo!!!?
-
- var fullpath = _this.file.guessName(el);
- if (fullpath.length && ret.indexOf(fullpath) < 0) {
- ret.push(fullpath);
- }
-
-
- if (el.items && el.items.length) {
- addall(el.items);
- }
-
- });
-
-
+ if (renderfull && c['|xns']) {
+ txt.push(c['|xns']);
}
- addall([this.currentTree]);
+ if (c.xtype) { txt.push(c.xtype); }
+ if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
+ if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
+ if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
- // only if we have nothing, should we add '*top'
- if (!ret.length) {
- ret = [ '*top' ];
- }
- //console.log('all types in tree');
- //console.dump(ret);
- return ret;
-
+ if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
+ if (c.title) { txt.push('<b>' + c.title + '</b>'); }
+ if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
+ if (c.header) { txt.push('<b>' + c.header + '</b>'); }
+ if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
+ if (c.text) { txt.push('<b>' + c.text + '</b>'); }
+ if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
+ if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
+ if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
+
+ // for flat classes...
+ if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
+ if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
+
+
+ if (sr) txt.push('</s>');
+ return (txt.length == 0 ? "Element" : txt.join(" "));
},
- singleNodeToJS : function (treepath)
- {
- var iter = new Gtk.TreeIter();
- if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
- return false;
- }
-
- var iv = this.getIterValue(iter, 2);
-
- return JSON.parse(iv);
-
- },
- nodeToJS : function (iter, with_id)
+ nodeToJS : function (treepath, with_id)
{
+
+ var iter = treepath; // API used to be iter here..
+ if (typeof(iter) == 'string') {
+ iter = new Gtk.TreeIter();
+ if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
+ return false;
+ }
+ }
var par = new Gtk.TreeIter();
var iv = this.getIterValue(iter, 2);
// print("IV" + iv);
}
return k;
},
- toJS : function(iter, with_id)
+ nodeToJSON : function(c) {
+ var o = {}
+ for (var i in c) {
+ if (i == 'items') {
+ continue;
+ }
+ o[i] = c[i];
+ }
+ return JSON.stringify(o);
+ },
+ singleNodeToJS : function (treepath)
+ {
+ var iter = new Gtk.TreeIter();
+ if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
+ return false;
+ }
+
+ var iv = this.getIterValue(iter, 2);
+
+ return JSON.parse(iv);
+
+ },
+ toJS : function(treepath, with_id)
{
//Seed.print("WITHID: "+ with_id);
-
+ var iter = treepath; // API used to be iter here..
+ if (typeof(iter) == 'string') {
+ iter = new Gtk.TreeIter();
+ if (!this.el.get_iter(iter, new Gtk.TreePath.from_string(treepath))) {
+ return false;
+ }
+ }
var first = false;
if (!iter) {
}
}
- return ar;
- // convert the list into a json string..
-
-
- },
- getIterValue : function (iter, col) {
- var gval = new GObject.Value('');
- this.el.get_value(iter, col ,gval);
- return gval.value;
-
-
- },
- nodeTitle : function(c, renderfull) {
- var txt = [];
- c = c || {};
- var sr = (typeof(c['+buildershow']) != 'undefined') && !c['+buildershow'] ? true : false;
- if (sr) txt.push('<s>');
- if (typeof(c['*prop']) != 'undefined') { txt.push(c['*prop']+ ':'); }
-
- if (renderfull && c['|xns']) {
- txt.push(c['|xns']);
- }
-
- if (c.xtype) { txt.push(c.xtype); }
- if (c.id) { txt.push('<b>[id=' + c.id + ']</b>'); }
- if (c.fieldLabel) { txt.push('[' + c.fieldLabel + ']'); }
- if (c.boxLabel) { txt.push('[' + c.boxLabel + ']'); }
-
-
- if (c.layout) { txt.push('<i>' + c.layout + '</i>'); }
- if (c.title) { txt.push('<b>' + c.title + '</b>'); }
- if (c.label) { txt.push('<b>' + c.label+ '</b>'); }
- if (c.header) { txt.push('<b>' + c.header + '</b>'); }
- if (c.legend) { txt.push('<b>' + c.legend + '</b>'); }
- if (c.text) { txt.push('<b>' + c.text + '</b>'); }
- if (c.name) { txt.push('<b>' + c.name+ '</b>'); }
- if (c.region) { txt.push('<i>(' + c.region + ')</i>'); }
- if (c.dataIndex) { txt.push('[' + c.dataIndex+ ']'); }
-
- // for flat classes...
- if (typeof(c['*class']) != 'undefined') { txt.push('<b>' + c['*class']+ '</b>'); }
- if (typeof(c['*extends']) != 'undefined') { txt.push(': <i>' + c['*extends']+ '</i>'); }
-
-
- if (sr) txt.push('</s>');
- return (txt.length == 0 ? "Element" : txt.join(" "));
- },
- nodeToJSON : function(c) {
- var o = {}
- for (var i in c) {
- if (i == 'items') {
- continue;
- }
- o[i] = c[i];
+ if (treepath === false) {
+ //dupe!!!
+ return JSON.parse(JSON.stringify(ar));
}
- return JSON.stringify(o);
- },
- load : function(tr,iter)
- {
- var citer = new Gtk.TreeIter();
- //this.insert(citer,iter,0);
- for(var i =0 ; i < tr.length; i++) {
- if (iter) {
- this.el.insert(citer,iter,-1);
- } else {
- this.el.append(citer);
- }
-
- this.el.set_value(citer, 0, [GObject.TYPE_STRING, this.nodeTitle(tr[i]) ]);
- this.el.set_value(citer, 1, [GObject.TYPE_STRING, this.nodeTip(tr[i]) ]);
- this.el.set_value(citer, 2, [GObject.TYPE_STRING, this.nodeToJSON(tr[i])]);
- if (tr[i].items && tr[i].items.length) {
- this.load(tr[i].items, citer);
- }
- }
- },
- nodeTip : function(c) {
- var ret = this.nodeTitle(c,true);
- var funcs = '';
-
- for( var i in c) {
+ return ar;
+ // convert the list into a json string..
- if (!i.length || i[0] != '|') {
- continue;
- }
- if (i == '|init') {
- continue;
- }
- if (typeof(c[i]) != 'string') {
- continue;
- }
- //print("prop : " + i + ':' + c[i]);
- if (!c[i].match(new RegExp('function'))) {
- continue;
- }
- funcs += "\n<b>" + i.substring(1) + '</b> : ' + c[i].split(/\n/).shift();
-
- }
- if (funcs.length) {
- ret+="\n\nMethods:" + funcs;
- }
- return ret;
}
},
this.get('/LeftTree.model').deleteSelected();
}
}
+ },
+ {
+ xtype: Gtk.MenuItem,
+ listeners : {
+ activate : function (self) {
+
+ var tree = this.get('/LeftTree');
+ var model = this.get('/LeftTree.model');
+ var el = tree.getActivePath();
+ print(el);
+ var js = model.toJS(el, false);
+ // print(JSON.stringify(js[0], null,4));
+ this.get('/DialogSaveTemplate').show(JSON.stringify(js[0], null,4));
+
+
+ }
+ },
+ label : "Save as Template",
+ pack : "add"
}
]
}
items : [
{
xtype: Gtk.TreeView,
- headers_visible : false,
- enable_tree_lines : true,
- tooltip_column : 1,
- init : function() {
- XObject.prototype.init.call(this);
- var description = new Pango.FontDescription.c_new();
- description.set_size(8000);
- this.el.modify_font(description);
-
- this.selection = this.el.get_selection();
- this.selection.set_mode( Gtk.SelectionMode.SINGLE);
- },
- id : "view",
listeners : {
cursor_changed : function (self) {
var iter = new Gtk.TreeIter();
var file = this.get('/LeftProjectTree').project.getById(value.value);
-
+ file.items = false;
console.log(file);
return true;
}
},
+ id : "view",
+ tooltip_column : 1,
+ enable_tree_lines : true,
+ headers_visible : false,
+ init : function() {
+ XObject.prototype.init.call(this);
+ var description = new Pango.FontDescription.c_new();
+ description.set_size(8000);
+ this.el.modify_font(description);
+
+ this.selection = this.el.get_selection();
+ this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+ },
items : [
{
xtype: Gtk.TreeStore,
},
{
xtype: Gtk.VBox,
- listeners : {
-
- },
items : [
{
xtype: Gtk.HBox,
activePath : false,
id : "model",
pack : "set_model",
- getIterValue : function(iter, col) {
- var gval = new GObject.Value('');
- this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
- return '' + gval.value;
- },
add : function(info) {
// info includes key, val, skel, etype..
console.dump(info);
if (typeof(info.val) == 'undefined') {
info.val = '';
- if (info.type == 'boolean') {
+ if (info.type.toLowerCase() == 'boolean') {
info.val = true;
}
if (type == 'number') {
// Gdk.threads_enter();
_this.get('/BottomPane').el.show();
_this.get('/RightEditor').el.show();
- _this.get('/RightEditor.view').load( rval );
+ _this.get('/RightEditor.view').load( rval );
e.editing_done();
e.remove_widget();
//var type = this.getValue(this.el.get_path(iter).to_string(),4);
+ },
+ getIterValue : function(iter, col) {
+ var gval = new GObject.Value('');
+ this.get('/LeftPanel.model').el.get_value(iter, col ,gval);
+ return '' + gval.value;
},
getType : function(treepath) {
return this.getValue(treepath, 4);
return ret;
},
startEditing : function(path,col) {
- /**
- * start editing path (or selected if not set..)
- * @param {String|false} path (optional) treepath to edit - selected tree gets
- * edited by default.
- * @param {Number} 0 or 1 (optional)- column to edit.
- */
+ /**
+ * start editing path (or selected if not set..)
+ * @param {String|false} path (optional) treepath to edit - selected tree gets
+ * edited by default.
+ * @param {Number} 0 or 1 (optional)- column to edit.
+ */
var tp;
- if (typeof(path) == 'string') {
- tp = new Gtk.TreePath.from_string(path);
- } else {
- var iter = new Gtk.TreeIter();
- var s = this.get('/LeftPanel.view').selection;
- s.get_selected(this.el, iter);
- tp = this.el.get_path(iter);
- path = tp.to_string();
- }
-
-
- // which colum is to be edited..
- var colObj = false;
- if (typeof(col) == 'undefined') {
- var k = this.getValue(path, 0);
- colObj = (!k.length || k == '|') ?
- this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
- } else {
- colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
- }
-
- // make sure the pulldown is set correctly..
- // not really needed for second col...
+ if (typeof(path) == 'string') {
+ tp = new Gtk.TreePath.from_string(path);
+ } else {
+ var iter = new Gtk.TreeIter();
+ var s = this.get('/LeftPanel.view').selection;
+ s.get_selected(this.el, iter);
+ tp = this.el.get_path(iter);
+ path = tp.to_string();
+ }
+
+
+ // which colum is to be edited..
+ var colObj = false;
+ if (typeof(col) == 'undefined') {
+ var k = this.getValue(path, 0);
+ colObj = (!k.length || k == '|') ?
+ this.get('/LeftPanel').propertyColumn : this.get('/LeftPanel').editableColumn;
+ } else {
+ colObj = col ? this.get('/LeftPanel').editableColumn : this.get('/LeftPanel').propertyColumn;
+ }
+
+ // make sure the pulldown is set correctly..
+ // not really needed for second col...
- var provider = this.get('/LeftTree').getPaleteProvider();
-
- var type = this.get('/LeftPanel.model').getType(path);
- var opts = provider.findOptions(type);
- var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
-
- if (opts === false) {
- this.get('/LeftPanel').editableColumn.setOptions([]);
- renderer.has_entry = true; /// probably does not have any effect.
- } else {
- this.get('/LeftPanel').editableColumn.setOptions(opts);
- renderer.has_entry = false;
- }
-
- var _this=this;
- // iter now has row...
- GLib.timeout_add(0, 100, function() {
-
- colObj.items[0].el.editable = true; // esp. need for col 0..
- _this.get('/LeftPanel.view').el.set_cursor_on_cell(
- tp,
- colObj.el,
- colObj.items[0].el,
- true
- );
- });
-
+ var provider = this.get('/LeftTree').getPaleteProvider();
+
+ var type = this.get('/LeftPanel.model').getType(path);
+ var opts = provider.findOptions(type);
+ var renderer = this.get('/LeftPanel').editableColumn.items[0].el;
+
+ if (opts === false) {
+ this.get('/LeftPanel').editableColumn.setOptions([]);
+ renderer.has_entry = true; /// probably does not have any effect.
+ } else {
+ this.get('/LeftPanel').editableColumn.setOptions(opts);
+ renderer.has_entry = false;
+ }
+
+ var _this=this;
+ // iter now has row...
+ GLib.timeout_add(0, 100, function() {
+
+ colObj.items[0].el.editable = true; // esp. need for col 0..
+ _this.get('/LeftPanel.view').el.set_cursor_on_cell(
+ tp,
+ colObj.el,
+ colObj.items[0].el,
+ true
+ );
+ });
+
},
toJS : function() {
var iter = new Gtk.TreeIter();
}
this.get('/Window.left').el.position = this.get('/Window.left').el.position - 150;
- this.el.hide();
- this.shown = false;
- },
- items : [
- {
- xtype: Gtk.TreeView,
- enable_tree_lines : true,
- headers_visible : false,
- tooltip_column : 2,
- init : function() {
- XObject.prototype.init.call(this);
-
- var description = new Pango.FontDescription.c_new();
- description.set_size(8000);
- this.el.modify_font(description);
-
- //this.selection = this.el.get_selection();
- // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
-
-
-
-
-
- },
- pack : "add",
+ this.el.hide();
+ this.shown = false;
+ },
+ items : [
+ {
+ xtype: Gtk.TreeView,
listeners : {
cursor_changed : function (self) {
var iter = new Gtk.TreeIter();
this.get('/MidPropTree').hideWin();
- if (type == 'function') {
+ if (type.toLowerCase() == 'function') {
if (etype != 'events') {
key = '|' + key;
})
return;
}
-
- if (type.indexOf('.') > -1 ||
- type == 'boolean') {
- key = '|' + key;
- }
+ // has dot in name, and is boolean???? this does not make sense..
+ //if (type.indexOf('.') > -1 || type.toLowerCase() == 'boolean') {
+ // key = '|' + key;
+ // }
this.get('/LeftPanel.model').add( {
key : key,
etype : etype
}) //,
}
+ },
+ pack : "add",
+ tooltip_column : 2,
+ enable_tree_lines : true,
+ headers_visible : false,
+ init : function() {
+ XObject.prototype.init.call(this);
+
+ var description = new Pango.FontDescription.c_new();
+ description.set_size(8000);
+ this.el.modify_font(description);
+
+ //this.selection = this.el.get_selection();
+ // this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+
+
+
+
+
},
items : [
{
items : [
{
xtype: Gtk.Notebook,
- pack : "add",
id : "view-notebook",
+ pack : "add",
tab_border : 0,
init : function() {
XObject.prototype.init.call(this);
this.el.set_current_page(0);
- print("SET LABEL?")
+ //print("SET LABEL?")
this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Roo View" }));
this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Gtk View" }));
},
items : [
{
xtype: Gtk.VBox,
- pack : "add",
id : "RightBrowser",
- listeners : {
-
- },
+ pack : "add",
items : [
- {
- xtype: Gtk.HBox,
- pack : "pack_start,false,true,0",
- items : [
- {
- xtype: Gtk.Button,
- pack : "pack_start,false,false,0",
- label : "Redraw",
- listeners : {
- button_press_event : function (self, event) {
- var js = this.get('/LeftTree.model').toJS();
- if (js && js[0]) {
- this.get('/RightBrowser.view').renderJS(js[0]);
- }
- return false;
- }
- }
- },
- {
- xtype: Gtk.Button,
- listeners : {
- button_press_event : function (self, event) {
- this.get('/RooProjectProperties').show();
- return false;
- }
- },
- label : "Set extra HTML in renderer",
- pack : "pack_start,false,false,0"
- },
- {
- xtype: Gtk.Button,
- listeners : {
- button_press_event : function (self, event)
- {
- /* Firefox testing for debugging..
- - we can create a /tmp directory, and put.
- builder.html, builder.html.js, link roojs1
- add at the end of builder.html Roo.onload(function() {
- */
- if (!this.get('/Window.LeftTree').getActiveFile()) {
- return;
- }
-
- var js = this.get('/LeftTree.model').toJS();
- if (!js || !js[0]) {
- return;
- }
- var project = this.get('/Window.LeftTree').getActiveFile().project;
- //print (project.fn);
-
- project.runhtml = project.runhtml || '';
-
-
- var File = imports.File.File;
-
- var target = "/tmp/firetest"; // fixme..
- if (!File.isDirectory(target)) {
- File.mkdir(target);
- }
- File.copy(__script_path__ + '/../builder.html.js', target+ '/builder.html.js', Gio.FileCopyFlags.OVERWRITE);
- if (!File.exists( target+ '/roojs1')) {
- File.link( target+ '/roojs1', __script_path__ + '/../roojs1');
- }
-
-
-
- var html = imports.File.File.read(__script_path__ + '/../builder.html');
- html = html.replace('</head>', project.runhtml + '</head>');
-
-
- var jsstr = JSON.stringify(js[0]);
-
- var runbuilder = '<script type="text/javascript">' + "\n" +
- " Builder.render(" + jsstr + ");\n" +
- '</script>';
-
- html = html.replace('</body>', runbuilder + '</body>');
-
- File.write( target+ '/builder.html', html);
-
- this.get('/Terminal').feed("RUN DIR:" + target);
-
- this.get('/Terminal').el.fork_command( null , [], [], target
- , false,false,false);
- var cmd = "firefox file://" + target + "/builder.html \n";
- this.get('/Terminal').el.feed_child(cmd, cmd.length);
- return false;
- }
- },
- label : "Test in Firefox",
- pack : "pack_start,false,false,0"
- }
- ]
- },
{
xtype: Gtk.ScrolledWindow,
pack : "add",
items : [
{
xtype: WebKit.WebView,
- pack : "add",
- id : "view",
- init : function() {
- XObject.prototype.init.call(this);
- // this may not work!?
- this.el.open('file:///' + __script_path__ + '/../builder.html');
-
- Gtk.drag_dest_set
- (
- this.el, /* widget that will accept a drop */
- Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
- null, /* lists of target to support */
- 0, /* size of list */
- Gdk.DragAction.COPY /* what to do with data after dropped */
- );
-
- // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
- Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
- },
- renderJS : function(data) {
- print("HTML RENDERING");
- /// prevent looping..
- //if (this.pendingRedraw) {
- // print("pending redraw active?!");
- // return;
- //}
-
-
- if (!this.get('/Window.LeftTree').getActiveFile()) {
- return;
- }
-
- var project = this.get('/Window.LeftTree').getActiveFile().project;
- //print (project.fn);
-
- project.runhtml = project.runhtml || '';
-
-
- this.runhtml = this.runhtml || '';
-
- if (project.runhtml != this.runhtml) {
- // then we need to reload the browser using
- // load_html_string..
-
- // then trigger a redraw once it's loaded..
- this.pendingRedraw = true;
-
- this.runhtml = project.runhtml;
-
- var html = imports.File.File.read(__script_path__ + '/../builder.html');
- html = html.replace('</head>', this.runhtml + '</head>');
- print("LOAD HTML " + html);
- this.el.load_html_string( html , 'file:///' + __script_path__ + '/../builder.html');
- // should trigger load_finished!
- return;
-
- }
-
- this.pendingRedraw = false;
-
-
- this.renderedData = data;
- var str = JSON.stringify(data) ;
-
- if (!this.ready) {
- console.log('not loaded yet');
- }
- //Seed.print("RENDER:" + str);
- //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
-
- this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
- },
listeners : {
load_finished : function (self, object) {
// if (this.ready) { // dont do it twice!
// return;
//}
+
+ this.el.get_inspector().show();
this.ready = true;
this.pendingRedraw = false;
var js = this.get('/LeftTree.model').toJS();
if (js && js[0]) {
- this.renderJS(js[0]);
+ this.renderJS(js[0]);
}
},
script_alert : function (self, object, p0) {
- print(p0);
+ // print(p0);
return false;
return true; // do not display anything...
},
// console.log(object);
if (!object.match(/^\{/)) {
- this.get('/Terminal').feed(object);
+ //this.get('/Terminal').feed(object);
return true; // do not handle!!! -> later maybe in console..
}
// console.log(object);
if (typeof(val['id']) != 'undefined') {
// this.activeNode = val['id'];
var tg = this.get('/LeftTree.model').findDropNode(val['id'], true);
- if (!tg) {
+ if (!tg || typeof(tg[0]) == 'undefined') {
return false;
}
+ print("SELECT node " + tg[0]);
+
this.get('/LeftTree.view').selectNode(tg[0]);
ret = true;
Gtk.drag_finish (ctx, dnd_success, delete_selection_data, time);
return true;
- }
+ },
+ resource_request_starting : function (self, object, p0, p1, p2) {
+ // this.get('/Terminal').feed( p1.get_uri() );
+ }
+ },
+ id : "view",
+ pack : "add",
+ init : function() {
+ XObject.prototype.init.call(this);
+ // this may not work!?
+ var settings = this.el.get_settings();
+ settings.enable_developer_extras = true;
+ // settings.enable_file_access_from_file_uris = true;
+ // settings.enable_offline_web_application_cache - true;
+ // settings.enable_universal_access_from_file_uris = true;
+ var _this = this;
+
+ this.el.get_inspector().signal.inspect_web_view.connect(function(wi, pg) {
+ _this.get('/BottomPane.inspector').el.show();
+ return _this.get('/BottomPane.inspector').el;
+ //create_inspector_cb
+ });
+
+
+ this.el.open('file:///' + __script_path__ + '/../builder.html');
+
+ Gtk.drag_dest_set
+ (
+ this.el, /* widget that will accept a drop */
+ Gtk.DestDefaults.MOTION | Gtk.DestDefaults.HIGHLIGHT,
+ null, /* lists of target to support */
+ 0, /* size of list */
+ Gdk.DragAction.COPY /* what to do with data after dropped */
+ );
+
+ // print("RB: TARGETS : " + LeftTree.atoms["STRING"]);
+ Gtk.drag_dest_set_target_list(this.el, this.get('/Window').targetList);
+ },
+ renderJS : function(data) {
+ print("HTML RENDERING");
+ this.get('/BottomPane').el.show();
+ this.get('/BottomPane').el.set_current_page(2);// webkit view!
+ /// prevent looping..
+ //if (this.pendingRedraw) {
+ // print("pending redraw active?!");
+ // return;
+ //}
+
+
+ if (!this.get('/Window.LeftTree').getActiveFile()) {
+ return;
+ }
+
+ var project = this.get('/Window.LeftTree').getActiveFile().project;
+ //print (project.fn);
+
+ project.runhtml = project.runhtml || '';
+
+
+ this.runhtml = this.runhtml || '';
+
+ if (project.runhtml != this.runhtml) {
+ // 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" ;
+ // this.runhtml = '<link rel="stylesheet" type="text/css" href="file://' + __script_path__ + '/../roojs1/cssX/roojs-all.css" />'+ "\n" ;
+ // this.runhtml += '<script type="text/javascript" src="file://' + __script_path__ + '/../roojs1/roojs-debug.js"></script>'+ "\n" ;
+ // this.runhtml += '<script type="text/javascript">' + "\n" ;
+ // this.runhtml += 'Ext=Roo; // bc' + "\n" ;
+ // this.runhtml += 'Roo.BLANK_IMAGE_URL = "file://' + __script_path__ + '/../roojs1/images/gray/s.gif";'+ "\n" ;
+ // this.runhtml += 'Roo.rootURL = "file://' + __script_path__ + '/../roojs1/";'+ "\n" ;
+ // this.runhtml += '</script>'+ "\n" ;
+
+ this.runhtml = project.runhtml;
+ // need to modify paths
+
+
+
+ var html = imports.File.File.read(__script_path__ + '/../builder.html');
+ html = html.replace('</head>', runhtml + this.runhtml + '</head>');
+ print("LOAD HTML " + html);
+ this.el.load_html_string( html ,
+ //fixme - should be a config option!
+ 'http://www.akbkhome.com/e/'
+ );
+ // should trigger load_finished!
+ return;
+
+ }
+
+ this.pendingRedraw = false;
+
+
+ this.renderedData = data;
+ var str = JSON.stringify(data) ;
+
+ if (!this.ready) {
+ console.log('not loaded yet');
+ }
+ //Seed.print("RENDER:" + str);
+ //imports.File.File.write('/tmp/builder.debug.js', "Builder.render(" + JSON.stringify(data) + ");");
+
+ this.el.execute_script("Builder.render(" + JSON.stringify(data) + ");");
+
}
}
]
renderJS : function(data, withDebug)
{
this.highlightWidget = false;
- if (!data) {
- return;
- }
+
this.withDebug = false;
if (this.renderedEl) {
this.renderedEl.destroy();
this.renderedEl = false;
}
-
+ if (!data) {
+ return;
+ }
var tree = this.get('/LeftTree.model').toJS(false,true)[0];
// in theory tree is actually window..
try {
},
{
xtype: Gtk.ScrolledWindow,
- pack : "add",
id : "Help",
+ pack : "add",
show : function() {
var file = this.get('/LeftTree').getActiveFile();
if (!xtype || !xtype.length) {
return;
}
- this.get('/Window.view-help-nb').el.set_current_page(1);
+ //this.get('/Window.view-help-nb').el.set_current_page(1);
// get the active element being edited.
var helpurl = file.getHelpUrl(xtype);
},
{
xtype: Gtk.Notebook,
+ id : "BottomPane",
pack : "add",
init : function() {
XObject.prototype.init.call(this);
this.el.set_tab_label(this.items[0].el, new Gtk.Label({ label : "Code Editor" }));
this.el.set_tab_label(this.items[1].el, new Gtk.Label({ label : "Console" }));
+ this.el.set_tab_label(this.items[2].el, new Gtk.Label({ label : "Inspector" }));
},
- id : "BottomPane",
items : [
{
xtype: Gtk.ScrolledWindow,
scrollback_lines : 1000
}
]
+ },
+ {
+ xtype: Gtk.ScrolledWindow,
+ pack : "add",
+ items : [
+ {
+ xtype: WebKit.WebView,
+ id : "inspector",
+ pack : "add"
+ }
+ ]
}
]
}