Sample/EditProject.js
authorAlan Knowles <alan@akbkhome.com>
Mon, 24 May 2010 09:01:28 +0000 (17:01 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 24 May 2010 09:01:28 +0000 (17:01 +0800)
Sample/EditProject.js

index d42c60e..a99cd98 100644 (file)
@@ -13,6 +13,54 @@ EditProject=new XObject({
     xtype: Gtk.Dialog,
     default_height : 300,
     default_width : 600,
+    deletable : true,
+    modal : true,
+    border_width : 0,
+    title : "Project Properties",
+    show : function(c) {
+           c = c || { name : '' , xtype : '' };
+        this.project  = c;
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        [ 'xtype' , 'name' ].forEach(function(k) {
+            _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
+        });
+        
+        this.el.show_all();
+        this.success = c.success;
+    },
+    listeners : {
+        "destroy_event":function (self, event) {
+             this.el.hide();
+                        return true;
+        },
+        "response":function (self, response_id) {
+         if (id < 1) {
+                    this.el.hide();
+                    return;
+                }
+                if (!this.get('xtype').getValue().length) {
+                    this.get('/StandardErrorDialog').show("You have to set Project type");
+                     
+                    return;
+                }
+                this.el.hide();
+                
+                
+                
+                
+                this.project.name  = this.get('name').getValue();
+                this.project.xtype  = this.get('xtype').getValue();
+                
+                
+                var pr = imports.Builder.Provider.ProjectManager.ProjectManager.update(this.project);
+                
+                this.success(pr);
+                Seed.print(id);
+        }
+    },
     items : [
         {
             xtype: Gtk.VBox,
@@ -32,7 +80,14 @@ EditProject=new XObject({
                         {
                             xtype: Gtk.Entry,
                             pack : "pack_end,true,true,0",
-                            id : "name"
+                            id : "name",
+                            getValue : function() {
+                                return this.el.get_text();
+                            },
+                            setValue : function(v) 
+                                                            {
+                                                                this.el.set_text(v);
+                                                            }
                         }
                     ]
                 },
@@ -46,10 +101,82 @@ EditProject=new XObject({
                             label : "Project type :"
                         },
                         {
-                            xtype: Gtk.Entry,
-                            pack : "pack_end,true,true,0"
+                            xtype: Gtk.ComboBox,
+                            pack : "pack_end,true,true,0",
+                            id : "xtype",
+                            setValue : function(v)
+                                            {
+                                                var el = this.el;
+                                                el.set_active(-1);
+                                                this.get('model').data.forEach(function(n, ix) {
+                                                    if (v == n.xtype) {
+                                                        el.set_active(ix);
+                                                        return false;
+                                                    }
+                                                });
+                                            },
+                            getValue : function() {
+                                 var ix = this.el.get_active();
+                                        if (ix < 0 ) {
+                                            return '';
+                                        }
+                                        return this.get('model').data[ix].xtype;
+                            },
+                            items : [
+                                {
+                                    xtype: Gtk.CellRendererText,
+                                    pack : false
+                                },
+                                {
+                                    xtype: Gtk.ListStore,
+                                    pack : "set_model",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                    
+                                                                this.el.set_column_types ( 2, [
+                                                                    GObject.TYPE_STRING,  // real key
+                                                                    GObject.TYPE_STRING // real type
+                                                                    
+                                                                    
+                                                                ] );
+                                                                
+                                                                this.data = [
+                                                                    { xtype: 'Roo', desc : "Roo Project" },
+                                                                    { xtype: 'Gtk', desc : "Gtk Project" },    
+                                                                    //{ xtype: 'JS', desc : "Javascript Class" }
+                                                                ]
+                                                                
+                                                                this.loadData(this.data);
+                                                                    
+                                    },
+                                    loadData : function (data) {
+                                                                                
+                                                var iter = new Gtk.TreeIter();
+                                                var el = this.el;
+                                                data.forEach(function(p) {
+                                                    
+                                                    el.append(iter);
+                                                    
+                                                     
+                                                    el.set_value(iter, 0, p.xtype);
+                                                    el.set_value(iter, 1, p.desc);
+                                                    
+                                                });
+                                                 
+                                                
+                                                
+                                                                         
+                                    },
+                                    id : "model"
+                                }
+                            ]
                         }
                     ]
+                },
+                {
+                    xtype: Gtk.FileChooserWidget,
+                    pack : "add",
+                    action : Gtk.FileChooserAction.SELECT_FOLDER
                 }
             ]
         },