Builder3/Window.js
[app.Builder.js] / Builder3 / Window.js
index b6b8875..c08c03a 100644 (file)
@@ -1110,7 +1110,10 @@ Window=new XObject({
                                                                                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;
@@ -1125,7 +1128,7 @@ Window=new XObject({
                                                                                             addall(el.items);
                                                                                         }
                                                                                         
-                                                                                    });
+                                                                                    };
                                                                                     
                                                                                     
                                                                                 }
@@ -1170,6 +1173,7 @@ Window=new XObject({
                                                                                     },
                                                                             loadFile : function(f) {
                                                                                 //console.dump(f);
+                                                                                  print("LOADFILE");
                                                                                         this.el.clear();
                                                                                         this.file = f;
                                                                                         
@@ -1196,7 +1200,7 @@ Window=new XObject({
                                                                                             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();
@@ -1223,10 +1227,10 @@ Window=new XObject({
                                                                                         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..
@@ -1335,7 +1339,7 @@ Window=new XObject({
                                                                             },
                                                                             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 = {};
@@ -1396,7 +1400,7 @@ Window=new XObject({
                                                                                     },
                                                                             toJS : function(treepath, with_id)
                                                                             {
-                                                                                print("toJS : WITHID: "+ with_id);
+                                                                                //print("toJS : WITHID: "+ with_id);
                                                                                 
                                                                                 var iter = treepath;  // API used to be iter here..
                                                                                 
@@ -1569,7 +1573,7 @@ Window=new XObject({
                                                                                     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
                                                                                             
@@ -1579,8 +1583,8 @@ Window=new XObject({
                                                                                        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);
                                                                                     
                                                                                        });
                                                                                     },
@@ -1592,8 +1596,8 @@ Window=new XObject({
                                                                                         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);
@@ -1618,39 +1622,50 @@ Window=new XObject({
                                                                     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",
@@ -1671,6 +1686,7 @@ Window=new XObject({
                                                                                     xtype: Gtk.TreeStore,
                                                                                     pack : "set_model",
                                                                                     id : "model",
+                                                                                     loading : false,
                                                                                     init : function() {
                                                                                         XObject.prototype.init.call(this);
                                                                                       this.el.set_column_types ( 3, [
@@ -1682,36 +1698,47 @@ Window=new XObject({
                                                                                     },
                                                                                     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();
@@ -2656,18 +2683,23 @@ Window=new XObject({
                                             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();
                                                         
                                                         
@@ -2733,6 +2765,7 @@ Window=new XObject({
                                                     xtype: Gtk.ListStore,
                                                     id : "model",
                                                     pack : "set_model",
+                                                    loading : false,
                                                     getValue : function(treepath, col)
                                                     {
                                                         var tp = new Gtk.TreePath.from_string (treepath);
@@ -2755,8 +2788,12 @@ Window=new XObject({
                                                         ] );
                                                     },
                                                     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
                                                                 }
                                                     
@@ -2802,7 +2839,7 @@ Window=new XObject({
                                                                     this.el.set_value(iret.iter, 5, type);
                                                                     
                                                                 }
-                                                                                 
+                                                                this.loading = false;              
                                                     }
                                                 },
                                                 {
@@ -3545,7 +3582,7 @@ Window=new XObject({
                                                                             return;
                                                                         }
                                                                         
-                                                                        console.dump(args);
+                                                                        //console.dump(args);
                                                                         args.unshift(el);
                                                                         //if (XObject.debug) print(pack_m + '[' + args.join(',') +']');
                                                                         //Seed.print('args: ' + args.length);