Builder/Provider/Palete.js
authorAlan Knowles <alan@akbkhome.com>
Thu, 29 Apr 2010 05:04:19 +0000 (13:04 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 29 Apr 2010 05:04:19 +0000 (13:04 +0800)
Builder/Provider/Palete.js [new file with mode: 0755]

diff --git a/Builder/Provider/Palete.js b/Builder/Provider/Palete.js
new file mode 100755 (executable)
index 0000000..fa888a3
--- /dev/null
@@ -0,0 +1,93 @@
+//<Script type="text/javascript">
+console = imports['console.js']; 
+Roo = imports['Roo.js']; 
+Gio = imports.gi.Gio;
+XN = imports.xnew;
+Builder = imports['Builder.js']
+
+
+// Palete Provider..
+
+Builder.Provider.Palete = function(cfg) {
+    
+    Roo.apply(this, cfg);
+    // various loader methods..
+   
+}
+
+Builder.Provider.Palete.prototype = {
+    
+    
+    map : false, // array of mappings   left: [] , right : []
+    
+    items : false, // the tree of nodes.
+    
+    
+    /**
+     * gather a  list of potentional objects that can be added..
+     * 
+     */
+    gatherList: function (existing) {
+        existing = existing || [];
+        existing.push('*top'); // always have top
+        var ret  = []; 
+        
+        function addRight(right) {
+            Roo.each(right, function(r) {
+                if (ret.indexOf(r) > -1) {
+                    return;
+                }
+                ret.push(r);
+            });
+        }
+        
+        Roo.each(this.map, function(m) {
+            Roo.each(m.left, function(left) {
+                var l = left.replace(/:.*$/, '');
+                if (existing.indexOf(l) > -1) {
+                    addRight(m.right);
+                    return true; // no more needed..
+                }
+            });
+            
+        });
+        return ret;
+        
+        
+        
+    },
+    
+    getDropList : function(rval)
+    {
+        
+        var ret = [];
+        Roo.each(this.map, function(m) {
+            if (m.right.indexOf(rval) > -1) {
+                Roo.each(m.left, function(l) {
+                    if (ret.indexOf(l) > -1) {
+                        return;
+                    }
+                    ret.push(l)
+                });
+            }
+            
+        });
+        console.log("DROP LIST:");
+        console.dump(ret);
+        return ret;
+        
+    },
+    
+    
+    confirmCanAdd: function(parent, child) {
+        // confirms that one obj can be added to another.
+        // returns true, for items, or list of properties that can hold it..
+        return true;
+        
+    }
+    
+};
+
+
+