Fix #7250 - better handling of adding properties
[roobuilder] / src / Builder4 / ProjectSettings.bjs
index b843fb6..0bcd491 100644 (file)
 {
- "name" : "ProjectSettings",
- "parent" : "",
- "title" : "",
- "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ProjectSettings.bjs",
- "permname" : "",
- "modOrder" : "",
  "build_module" : "builder",
  "items" : [
   {
-   "@ void buttonPressed" : "(string btn)",
-   "id" : "RooProjectSettings",
-   "| void show" : " (Project.Project project) {\n    _this.project = project;\n    _this.path.el.label = project.firstPath();\n    // get the active project.\n     var lm = Gtk.SourceLanguageManager.get_default();\n                \n    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(\n    \n        lm.get_language(\"html\"));\n  \n    //print (project.fn);\n    //project.runhtml = project.runhtml || '';\n    _this.view.el.get_buffer().set_text(project.runhtml);\n    \n       \n    _this.rootURL.el.set_text( _this.project.rootURL );\n    _this.base_template.el.set_text(_this.project.base_template);    \n     var js = _this.project;\n    _this.database_DBTYPE.el.set_text(     js.get_string_member(\"DBTYPE\") );\n    _this.database_DBNAME.el.set_text(    js.get_string_member(\"DBNAME\") );\n    _this.database_DBUSERNAME.el.set_text(    js.get_string_member(\"DBUSERNAME\") );\n    _this.database_DBPASSWORD.el.set_text(    js.get_string_member(\"DBPASSWORD\") );\n    //this.el.show_all();\n}\n",
    "# Project.Project project" : "",
-   "xtype" : "Box",
-   "| void save" : "()\n{\n   var buf =    _this.view.el.get_buffer();\n   Gtk.TextIter s;\n     Gtk.TextIter e;\n    buf.get_start_iter(out s);\n    buf.get_end_iter(out e);\n      _this.project.runhtml = buf.get_text(s,e,true);\n      \n    _this.project.rootURL = _this.rootURL.el.get_text();\n    _this.project.base_template = _this.base_template.el.get_text();    \n    \n    var js = _this.project.json_project_data;\n    js.set_string_member(\"DBTYPE\", _this.database_DBTYPE.el.get_text());\n   js.set_string_member(\"DBNAME\", _this.database_DBNAME.el.get_text());\n    js.set_string_member(\"DBUSERNAME\", _this.database_DBUSERNAME.el.get_text());\n    js.set_string_member(\"DBPASSWORD\", _this.database_DBPASSWORD.el.get_text());\n//    _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text());    \n    \n    // need to re-init the database \n    \n    _this.project.initRooDatabase();\n     \n    \n}",
+   "$ homogeneous" : false,
    "$ xns" : "Gtk",
+   "@ void buttonPressed" : "(string btn)",
    "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
    "border_width" : 5,
-   "$ homogeneous" : false,
+   "id" : "RooProjectSettings",
    "items" : [
     {
-     "* pack" : "pack_start,false,false,0",
-     "xtype" : "Box",
-     "gboolean expand" : false,
+     "$ homogeneous" : true,
      "$ xns" : "Gtk",
+     "* pack" : "pack_start,false,false,0",
      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
-     "$ homogeneous" : true,
+     "gboolean expand" : false,
      "gboolean vexpand" : false,
      "items" : [
       {
+       "$ xns" : "Gtk",
+       "* pack" : "add",
+       "label" : "Apply",
        "listeners" : {
-        "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
+        "button_press_event" : [
+         "() => {",
+         "    _this.save();",
+         "          ",
+         "    _this.buttonPressed(\"apply\");",
+         "        return false;",
+         "}"
+        ]
        },
-       "label" : "Apply",
-       "xtype" : "Button",
-       "* pack" : "add",
-       "$ xns" : "Gtk"
+       "xtype" : "Button"
       },
       {
+       "$ xns" : "Gtk",
+       "* pack" : "add",
+       "label" : "Save",
        "listeners" : {
-        "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
+        "button_press_event" : [
+         "() => {",
+         "       _this.save();",
+         "          ",
+         "    _this.buttonPressed(\"save\");",
+         "        return false;",
+         "}"
+        ]
        },
-       "label" : "Save",
-       "xtype" : "Button",
-       "* pack" : "add",
-       "$ xns" : "Gtk"
+       "xtype" : "Button"
       }
-     ]
+     ],
+     "xtype" : "Box"
     },
     {
-     "* pack" : "pack_end,true,true,0",
-     "xtype" : "Notebook",
      "$ xns" : "Gtk",
+     "* pack" : "pack_end,true,true,0",
      "items" : [
       {
-       "id" : "label_global",
-       "* pack" : false,
-       "xtype" : "Label",
        "$ xns" : "Gtk",
-       "utf8 label" : "Global"
+       "* pack" : false,
+       "id" : "label_global",
+       "utf8 label" : "Global",
+       "xtype" : "Label"
       },
       {
-       "id" : "label_database",
-       "xtype" : "Label",
-       "* pack" : false,
        "$ xns" : "Gtk",
-       "utf8 label" : "Database"
+       "* pack" : false,
+       "id" : "label_database",
+       "utf8 label" : "Database",
+       "xtype" : "Label"
       },
       {
-       "* pack" : "append_page,_this.label_global.el",
-       "xtype" : "Box",
-       "gboolean homogeneous" : false,
        "$ xns" : "Gtk",
+       "* pack" : "append_page,_this.label_global.el",
        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+       "gboolean homogeneous" : false,
        "items" : [
         {
-         "label" : "filename",
-         "id" : "path",
-         "xalign" : 0,
+         "$ xns" : "Gtk",
          "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
          "gint margin" : 3,
-         "$ xns" : "Gtk"
+         "id" : "path",
+         "label" : "filename",
+         "xalign" : 0,
+         "xtype" : "Label"
         },
         {
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Box",
-         "gboolean expand" : false,
+         "$ homogeneous" : false,
          "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
-         "$ homogeneous" : false,
+         "gboolean expand" : false,
          "items" : [
           {
-           "label" : "HTML template file",
+           "$ xns" : "Gtk",
            "* pack" : "pack_start,false,false,0",
-           "xtype" : "Label",
            "gint margin" : 3,
-           "$ xns" : "Gtk"
+           "label" : "HTML template file",
+           "xtype" : "Label"
           },
           {
-           "id" : "base_template",
+           "$ xns" : "Gtk",
            "* pack" : "add",
-           "xtype" : "Entry",
-           "$ xns" : "Gtk"
+           "id" : "base_template",
+           "xtype" : "Entry"
           }
-         ]
+         ],
+         "xtype" : "Box"
         },
         {
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Box",
-         "gboolean expand" : false,
+         "$ homogeneous" : false,
          "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
-         "$ homogeneous" : false,
+         "gboolean expand" : false,
          "items" : [
           {
-           "label" : "root URL",
+           "$ xns" : "Gtk",
            "* pack" : "pack_start,false,false,0",
-           "xtype" : "Label",
            "gint margin" : 3,
-           "$ xns" : "Gtk"
+           "label" : "root URL",
+           "xtype" : "Label"
           },
           {
-           "id" : "rootURL",
+           "$ xns" : "Gtk",
            "* pack" : "add",
-           "xtype" : "Entry",
-           "$ xns" : "Gtk"
+           "id" : "rootURL",
+           "xtype" : "Entry"
           }
-         ]
+         ],
+         "xtype" : "Box"
         },
         {
-         "label" : "HTML To insert at end of <HEAD>",
+         "$ xns" : "Gtk",
          "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
-         "$ xns" : "Gtk"
+         "label" : "HTML To insert at end of <HEAD>",
+         "xtype" : "Label"
         },
         {
-         "* pack" : "pack_start,true,true,0",
-         "xtype" : "ScrolledWindow",
          "$ xns" : "Gtk",
+         "* pack" : "pack_start,true,true,0",
          "items" : [
           {
+           "$ xns" : "GtkSource",
+           "* init" : [
+            " ",
+            "    var description =   Pango.FontDescription.from_string(\"monospace\");",
+            "    description.set_size(9000);",
+            "    this.el.override_font(description);"
+           ],
+           "* pack" : "add",
+           "id" : "view",
            "listeners" : {
-            "key_release_event" : " ( event) =>{\n    if (event.keyval != 115) {\n        return false;\n         \n    }\n    if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {\n        return false;\n    }\n     var buf =    this.el.get_buffer();\n    Gtk.TextIter s;\n    Gtk.TextIter e;\n    buf.get_start_iter(out s);\n    buf.get_end_iter(out e);\n    _this.project.runhtml = buf.get_text(s,e,true);\n    \n          \n    _this.buttonPressed(\"save\");\n     \n    return false;\n         \n}"
+            "key_release_event" : [
+             " ( event) =>{",
+             "    if (event.keyval != 115) {",
+             "        return false;",
+             "         ",
+             "    }",
+             "    if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {",
+             "        return false;",
+             "    }",
+             "     var buf =    this.el.get_buffer();",
+             "    Gtk.TextIter s;",
+             "    Gtk.TextIter e;",
+             "    buf.get_start_iter(out s);",
+             "    buf.get_end_iter(out e);",
+             "    _this.project.runhtml = buf.get_text(s,e,true);",
+             "    ",
+             "          ",
+             "    _this.buttonPressed(\"save\");",
+             "     ",
+             "    return false;",
+             "         ",
+             "}"
+            ]
            },
-           "id" : "view",
-           "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
-           "xtype" : "View",
-           "* pack" : "add",
-           "$ xns" : "GtkSource"
+           "xtype" : "View"
           }
-         ]
+         ],
+         "xtype" : "ScrolledWindow"
         }
-       ]
+       ],
+       "xtype" : "Box"
       },
       {
-       "* pack" : "append_page,_this.label_database.el",
-       "xtype" : "Box",
-       "gboolean homogeneous" : false,
        "$ xns" : "Gtk",
+       "* pack" : "append_page,_this.label_database.el",
        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
+       "gboolean homogeneous" : false,
        "items" : [
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "label" : "Type (eg. MySQL or PostgreSQL)",
          "xalign" : 0,
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
-         "$ xns" : "Gtk"
+         "xtype" : "Label"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
+         "id" : "database_DBTYPE",
          "listeners" : {
-          "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBNAME.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
+          "key_press_event" : [
+           "(ev) => {",
+           "",
+           "    if (ev.keyval == Gdk.Key.Tab) {",
+           "        _this.database_DBNAME.el.grab_focus();",
+           "        return true;",
+           "    }",
+           "",
+           "",
+           "    return false;",
+           "}",
+           ""
+          ]
          },
-         "id" : "database_DBTYPE",
-         "xtype" : "Entry",
-         "* pack" : "pack_start,false,false,0",
-         "$ xns" : "Gtk"
+         "xtype" : "Entry"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "label" : "Name",
          "xalign" : 0,
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
-         "$ xns" : "Gtk"
+         "xtype" : "Label"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
+         "id" : "database_DBNAME",
          "listeners" : {
-          "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBUSERNAME.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
+          "key_press_event" : [
+           "(ev) => {",
+           "",
+           "    if (ev.keyval == Gdk.Key.Tab) {",
+           "        _this.database_DBUSERNAME.el.grab_focus();",
+           "        return true;",
+           "    }",
+           "",
+           "",
+           "    return false;",
+           "}",
+           ""
+          ]
          },
-         "id" : "database_DBNAME",
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Entry",
-         "$ xns" : "Gtk"
+         "xtype" : "Entry"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "label" : "Username",
          "xalign" : 0,
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
-         "$ xns" : "Gtk"
+         "xtype" : "Label"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
+         "id" : "database_DBUSERNAME",
          "listeners" : {
-          "key_press_event" : "(ev) => {\n\n    if (ev.keyval == Gdk.Key.Tab) {\n        _this.database_DBPASSWORD.el.grab_focus();\n        return true;\n    }\n\n\n    return false;\n}\n"
+          "key_press_event" : [
+           "(ev) => {",
+           "",
+           "    if (ev.keyval == Gdk.Key.Tab) {",
+           "        _this.database_DBPASSWORD.el.grab_focus();",
+           "        return true;",
+           "    }",
+           "",
+           "",
+           "    return false;",
+           "}",
+           ""
+          ]
          },
-         "id" : "database_DBUSERNAME",
-         "xtype" : "Entry",
-         "* pack" : "pack_start,false,false,0",
-         "$ xns" : "Gtk"
+         "xtype" : "Entry"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "label" : "Password",
          "xalign" : 0,
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
-         "$ xns" : "Gtk"
+         "xtype" : "Label"
         },
         {
-         "id" : "database_DBPASSWORD",
+         "$ xns" : "Gtk",
          "* pack" : "pack_start,false,false,0",
-         "xtype" : "Entry",
-         "$ xns" : "Gtk"
+         "id" : "database_DBPASSWORD",
+         "xtype" : "Entry"
         },
         {
+         "$ xns" : "Gtk",
+         "* pack" : "pack_start,false,false,0",
          "listeners" : {
-          "clicked" : "() => {\n\n\n  _this.database_ERROR.el.label    = \"\";\n    Gda.Connection cnc;\n    try {\n        // assumes localhost...\n         cnc = Gda.Connection.open_from_string (\n\t\t\t_this.database_DBTYPE.el.get_text(),\n\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), \n\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + \n\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),\n\t\t\tGda.ConnectionOptions.NONE\n\t\t);\n   //} catch (Gda.ConnectionError ce) { \n   //   _this.database_ERROR.el.label = ce.message;        \n   } catch(Gda.ConnectionError ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }  catch(Gda.ConfigError ue) {\n      _this.database_ERROR.el.label = ue.message;\n        return;\n   }\n  _this.database_ERROR.el.label = \"Connection Succeeded\";\n   cnc.close();\n}"
+          "clicked" : [
+           "() => {",
+           "",
+           "",
+           "  _this.database_ERROR.el.label    = \"\";",
+           "    Gda.Connection cnc;",
+           "    try {",
+           "        // assumes localhost...",
+           "         cnc = Gda.Connection.open_from_string (",
+           "\t\t\t_this.database_DBTYPE.el.get_text(),",
+           "\t\t\t\"DB_NAME=\" + _this.database_DBNAME.el.get_text(), ",
+           "\t\t\t\"USERNAME=\" + _this.database_DBUSERNAME.el.get_text() + ",
+           "\t\t\t\";PASSWORD=\" + _this.database_DBPASSWORD.el.get_text(),",
+           "\t\t\tGda.ConnectionOptions.NONE",
+           "\t\t);",
+           "   //} catch (Gda.ConnectionError ce) { ",
+           "   //   _this.database_ERROR.el.label = ce.message;        ",
+           "   } catch(Gda.ConnectionError ue) {",
+           "      _this.database_ERROR.el.label = ue.message;",
+           "        return;",
+           "   }  catch(Gda.ConfigError ue) {",
+           "      _this.database_ERROR.el.label = ue.message;",
+           "        return;",
+           "   }",
+           "  _this.database_ERROR.el.label = \"Connection Succeeded\";",
+           "   cnc.close();",
+           "}"
+          ]
          },
-         "* pack" : "pack_start,false,false,0",
-         "xtype" : "Button",
-         "$ xns" : "Gtk",
-         "utf8 label" : "Check Connection"
+         "utf8 label" : "Check Connection",
+         "xtype" : "Button"
         },
         {
-         "label" : " ",
-         "id" : "database_ERROR",
-         "xalign" : 0,
+         "$ xns" : "Gtk",
          "* pack" : "pack_start,false,false,0",
-         "xtype" : "Label",
          "gint margin" : 3,
-         "$ xns" : "Gtk"
+         "id" : "database_ERROR",
+         "label" : " ",
+         "xalign" : 0,
+         "xtype" : "Label"
         }
-       ]
+       ],
+       "xtype" : "Box"
       }
-     ]
+     ],
+     "xtype" : "Notebook"
     }
+   ],
+   "xtype" : "Box",
+   "| void save" : [
+    "()",
+    "{",
+    "   var buf =    _this.view.el.get_buffer();",
+    "   Gtk.TextIter s;",
+    "     Gtk.TextIter e;",
+    "    buf.get_start_iter(out s);",
+    "    buf.get_end_iter(out e);",
+    "      _this.project.runhtml = buf.get_text(s,e,true);",
+    "      ",
+    "    _this.project.rootURL = _this.rootURL.el.get_text();",
+    "    _this.project.base_template = _this.base_template.el.get_text();    ",
+    "    ",
+    "    var js = _this.project.json_project_data;",
+    "    js.set_string_member(\"DBTYPE\", _this.database_DBTYPE.el.get_text());",
+    "   js.set_string_member(\"DBNAME\", _this.database_DBNAME.el.get_text());",
+    "    js.set_string_member(\"DBUSERNAME\", _this.database_DBUSERNAME.el.get_text());",
+    "    js.set_string_member(\"DBPASSWORD\", _this.database_DBPASSWORD.el.get_text());",
+    "//    _this.project.set_string_member(\"DBHOST\", _this.DBTYPE.el.get_text());    ",
+    "    ",
+    "    // need to re-init the database ",
+    "    ",
+    "    _this.project.initRooDatabase();",
+    "      ",
+    "}"
+   ],
+   "| void show" : [
+    " (Project.Project project) {",
+    "    _this.project = project;",
+    "    _this.path.el.label = project.firstPath();",
+    "    // get the active project.",
+    "     var lm = Gtk.SourceLanguageManager.get_default();",
+    "                ",
+    "    ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(",
+    "    ",
+    "        lm.get_language(\"html\"));",
+    "  ",
+    "    //print (project.fn);",
+    "    //project.runhtml = project.runhtml || '';",
+    "    _this.view.el.get_buffer().set_text(project.runhtml);",
+    "    ",
+    "       ",
+    "    _this.rootURL.el.set_text( _this.project.rootURL );",
+    "    _this.base_template.el.set_text(_this.project.base_template);    ",
+    "     var js = _this.project;",
+    "    _this.database_DBTYPE.el.set_text(     js.get_string_member(\"DBTYPE\") );",
+    "    _this.database_DBNAME.el.set_text(    js.get_string_member(\"DBNAME\") );",
+    "    _this.database_DBUSERNAME.el.set_text(    js.get_string_member(\"DBUSERNAME\") );",
+    "    _this.database_DBPASSWORD.el.set_text(    js.get_string_member(\"DBPASSWORD\") );",
+    "    //this.el.show_all();",
+    "}",
+    ""
    ]
   }
- ]
+ ],
+ "modOrder" : "",
+ "name" : "ProjectSettings",
+ "parent" : "",
+ "path" : "/home/alan/gitlive/roobuilder/src/Builder4/ProjectSettings.bjs",
+ "permname" : "",
+ "title" : ""
 }
\ No newline at end of file