Builder4/DialogNewComponent.bjs
authorAlan Knowles <alan@roojs.com>
Mon, 18 Aug 2014 10:22:31 +0000 (18:22 +0800)
committerAlan Knowles <alan@roojs.com>
Mon, 18 Aug 2014 10:22:31 +0000 (18:22 +0800)
Builder4/DialogNewComponent.js
Builder4/DialogNewComponent.vala

Builder4/DialogNewComponent.bjs
Builder4/DialogNewComponent.js
Builder4/DialogNewComponent.vala

index df7e699..0adf772 100644 (file)
@@ -8,7 +8,7 @@
         {
             "listeners": {
                 "delete_event": "(self, event) => {\n    this.el.hide();\n    return true;   \n}\n ",
-                "response": " (self, response_id) =>  { \n  \n\tif (response_id < 1) { // cancel!\n            this.el.hide();\n            return;\n        }\n\n        if (_this.name.el.get_text().length  < 1) {\n            StandardErrorDialog.show(\n                \"You have to set Component name \"\n            );\n             \n            return;\n        }\n        // what does this do?\n        \n        var isNew = _this.file.name.length  > 0 ? false : true;\n        \n        if (!isNew && this.file.name != _this.name.el.get_text()) {\n            StandardErrorDialog.show(\n                \"Sorry changing names does not work yet. \"\n            );\n             \n            return;\n        }\n        \n         \n        \n      \n        // FIXME - this may be more complicated...\n        //for (var i in this.def) {\n        //    this.file[i] =  this.get(i).el.get_text();\n        //}\n\n        if (!isNew) {\n             this.updateFileFromEntry();\n            _this.file.title = _this.title.el.get_text();\n            _this.file.region = _this.region.el.get_text();            \n            _this.file.parent = _this.parent.el.get_text();                        \n            _this.file.permname = _this.permname.el.get_text();                                    \n            _this.file.modOrder = _this.modOrder.el.get_text();                                                \n        \n            _this.file.save();\n            this.el.hide();\n            return;\n        }\n        var fn = this.name.el.get_text();\n       \n       var f =  JsRender.JsRender.factory(\n                _this.file.project.xtype,  \n                _this.file.project, \n                fn);\n\n        this.updateFileFromEntry();\n        \n\tvar dir = _this.project.firstPath();\n\t//FIXME...\n        //for (var i in this.project.paths) {\n \t//\tdir = i;\n\t//\tbreak;\n\t//}\n\n \n        \n        // what about .js ?\n        if (GLib.FileUtils.test(_this.file.name + \".bjs\", GLib.FileTest.EXISTS)) {\n            StandardErrorDialog.show(\n                \"That file already exists\"\n            ); \n            return;\n        }\n        this.el.hide();\n        \n        \n        //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n         \n        var nf = _this.project.create(dir + \"/\" + _this.file.name + \".bjs\");\n        //for (var i in this.file) {\n        //    nf[i] = this.file[i];\n        //}\n        _this.success(_this.project, nf);\n        /*\n\n        -- fixme -- needs to be a signal..\n        if (DialogNewComponent.success != null) {\n            DialogNewComponent.success(_this.project, nf);\n        }\n        */\n}",
+                "response": " (self, response_id) =>  { \n  \n\tif (response_id < 1) { // cancel!\n            this.el.hide();\n            return;\n        }\n\n        if (_this.name.el.get_text().length  < 1) {\n            StandardErrorDialog.show(\n                \"You have to set Component name \"\n            );\n             \n            return;\n        }\n        // what does this do?\n        \n        var isNew = _this.file.name.length  > 0 ? false : true;\n        \n        if (!isNew && this.file.name != _this.name.el.get_text()) {\n            StandardErrorDialog.show(\n                \"Sorry changing names does not work yet. \"\n            );\n             \n            return;\n        }\n        \n         \n        \n      \n        // FIXME - this may be more complicated...\n        //for (var i in this.def) {\n        //    this.file[i] =  this.get(i).el.get_text();\n        //}\n\n        if (!isNew) {\n             this.updateFileFromEntry();\n                                                        \n        \n            _this.file.save();\n            this.el.hide();\n            return;\n        }\n        var fn = this.name.el.get_text();\n       var dir = _this.project.firstPath();\n       \n        if (GLib.FileUtils.test(dir + \"/\" + fn + \".bjs\", GLib.FileTest.EXISTS)) {\n            StandardErrorDialog.show(\n                \"That file already exists\"\n            ); \n            return;\n        }\n       \n       var f =  JsRender.JsRender.factory(\n                _this.file.project.xtype,  \n                _this.file.project, \n                dir + \"/\" + fn + \".bjs\");\n\n        this.updateFileFromEntry();\n        \n\t \n        // what about .js ?\n       \n        this.el.hide();\n        \n        \n        //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());\n         \n        //var nf = _this.project.create(dir + \"/\" + _this.file.name + \".bjs\");\n        //for (var i in this.file) {\n        //    nf[i] = this.file[i];\n        //}\n        _this.success(_this.project, nf);\n        /*\n\n        -- fixme -- needs to be a signal..\n        if (DialogNewComponent.success != null) {\n            DialogNewComponent.success(_this.project, nf);\n        }\n        */\n}",
                 "show": "(self)  => {\n  this.el.show_all();\n  \n}"
             },
             "|void:updateFileFromEntry": "() {\n\n        _this.file.title = _this.title.el.get_text();\n        _this.file.region = _this.region.el.get_text();            \n        _this.file.parent = _this.parent.el.get_text();                        \n        _this.file.permname = _this.permname.el.get_text();                                    \n        _this.file.modOrder = _this.modOrder.el.get_text();                                                \n}    ",
index d8e5d53..4a3495f 100644 (file)
@@ -52,47 +52,38 @@ DialogNewComponent=new XObject({
         
                 if (!isNew) {
                      this.updateFileFromEntry();
-                    _this.file.title = _this.title.el.get_text();
-                    _this.file.region = _this.region.el.get_text();            
-                    _this.file.parent = _this.parent.el.get_text();                        
-                    _this.file.permname = _this.permname.el.get_text();                                    
-                    _this.file.modOrder = _this.modOrder.el.get_text();                                                
+                                                                
                 
                     _this.file.save();
                     this.el.hide();
                     return;
                 }
                 var fn = this.name.el.get_text();
+               var dir = _this.project.firstPath();
+               
+                if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
+                    StandardErrorDialog.show(
+                        "That file already exists"
+                    ); 
+                    return;
+                }
                
                var f =  JsRender.JsRender.factory(
                         _this.file.project.xtype,  
                         _this.file.project, 
-                        fn);
+                        dir + "/" + fn + ".bjs");
         
                 this.updateFileFromEntry();
                 
-               var dir = _this.project.firstPath();
-               //FIXME...
-                //for (var i in this.project.paths) {
-               //      dir = i;
-               //      break;
-               //}
-        
-         
-                
+                
                 // what about .js ?
-                if (GLib.FileUtils.test(_this.file.name + ".bjs", GLib.FileTest.EXISTS)) {
-                    StandardErrorDialog.show(
-                        "That file already exists"
-                    ); 
-                    return;
-                }
+               
                 this.el.hide();
                 
                 
                 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
                  
-                var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
+                //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
                 //for (var i in this.file) {
                 //    nf[i] = this.file[i];
                 //}
index e1fa66d..ac2a8c9 100644 (file)
@@ -108,47 +108,38 @@ public class Xcls_DialogNewComponent : Object
         
                 if (!isNew) {
                      this.updateFileFromEntry();
-                    _this.file.title = _this.title.el.get_text();
-                    _this.file.region = _this.region.el.get_text();            
-                    _this.file.parent = _this.parent.el.get_text();                        
-                    _this.file.permname = _this.permname.el.get_text();                                    
-                    _this.file.modOrder = _this.modOrder.el.get_text();                                                
+                                                                
                 
                     _this.file.save();
                     this.el.hide();
                     return;
                 }
                 var fn = this.name.el.get_text();
+               var dir = _this.project.firstPath();
+               
+                if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
+                    StandardErrorDialog.show(
+                        "That file already exists"
+                    ); 
+                    return;
+                }
                
                var f =  JsRender.JsRender.factory(
                         _this.file.project.xtype,  
                         _this.file.project, 
-                        fn);
+                        dir + "/" + fn + ".bjs");
         
                 this.updateFileFromEntry();
                 
-               var dir = _this.project.firstPath();
-               //FIXME...
-                //for (var i in this.project.paths) {
-               //      dir = i;
-               //      break;
-               //}
-        
-         
-                
+                
                 // what about .js ?
-                if (GLib.FileUtils.test(_this.file.name + ".bjs", GLib.FileTest.EXISTS)) {
-                    StandardErrorDialog.show(
-                        "That file already exists"
-                    ); 
-                    return;
-                }
+               
                 this.el.hide();
                 
                 
                 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
                  
-                var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
+                //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
                 //for (var i in this.file) {
                 //    nf[i] = this.file[i];
                 //}