src/Builder4/ProjectSettings.bjs
[app.Builder.js] / src / Builder4 / ProjectSettings.bjs
1 {
2  "name" : "ProjectSettings",
3  "parent" : "",
4  "title" : "",
5  "path" : "/home/alan/gitlive/app.Builder.js/src/Builder4/ProjectSettings.bjs",
6  "permname" : "",
7  "modOrder" : "",
8  "build_module" : "builder",
9  "items" : [
10   {
11    "@ void buttonPressed" : "(string btn)",
12    "id" : "ProjectSettings",
13    "| 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",
14    "# Project.Project project" : "",
15    "xtype" : "VBox",
16    "| 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}",
17    "$ xns" : "Gtk",
18    "border_width" : 5,
19    "$ homogeneous" : false,
20    "items" : [
21     {
22      "* pack" : "pack_start,false,false,0",
23      "xtype" : "Box",
24      "gboolean expand" : false,
25      "$ xns" : "Gtk",
26      "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
27      "$ homogeneous" : true,
28      "gboolean vexpand" : false,
29      "items" : [
30       {
31        "listeners" : {
32         "button_press_event" : "() => {\n    _this.save();\n          \n    _this.buttonPressed(\"apply\");\n        return false;\n}"
33        },
34        "label" : "Apply",
35        "* pack" : "add",
36        "xtype" : "Button",
37        "$ xns" : "Gtk"
38       },
39       {
40        "listeners" : {
41         "button_press_event" : "() => {\n       _this.save();\n          \n    _this.buttonPressed(\"save\");\n        return false;\n}"
42        },
43        "label" : "Save",
44        "* pack" : "add",
45        "xtype" : "Button",
46        "$ xns" : "Gtk"
47       }
48      ]
49     },
50     {
51      "* pack" : "pack_end,true,true,0",
52      "xtype" : "Notebook",
53      "$ xns" : "Gtk",
54      "items" : [
55       {
56        "id" : "label_global",
57        "xtype" : "Label",
58        "* pack" : false,
59        "$ xns" : "Gtk",
60        "utf8 label" : "Global"
61       },
62       {
63        "id" : "label_database",
64        "* pack" : false,
65        "xtype" : "Label",
66        "$ xns" : "Gtk",
67        "utf8 label" : "Database"
68       },
69       {
70        "* pack" : "append_page,_this.label_global.el",
71        "xtype" : "Box",
72        "gboolean homogeneous" : false,
73        "$ xns" : "Gtk",
74        "items" : [
75         {
76          "label" : "filename",
77          "id" : "path",
78          "xalign" : 0,
79          "* pack" : "pack_start,false,false,0",
80          "xtype" : "Label",
81          "gint margin" : 3,
82          "$ xns" : "Gtk"
83         },
84         {
85          "* pack" : "pack_start,false,false,0",
86          "xtype" : "HBox",
87          "gboolean expand" : false,
88          "$ xns" : "Gtk",
89          "$ homogeneous" : false,
90          "items" : [
91           {
92            "label" : "HTML template file",
93            "xtype" : "Label",
94            "* pack" : "pack_start,false,false,0",
95            "gint margin" : 3,
96            "$ xns" : "Gtk"
97           },
98           {
99            "id" : "base_template",
100            "xtype" : "Entry",
101            "* pack" : "add",
102            "$ xns" : "Gtk"
103           }
104          ]
105         },
106         {
107          "* pack" : "pack_start,false,false,0",
108          "xtype" : "HBox",
109          "gboolean expand" : false,
110          "$ xns" : "Gtk",
111          "$ homogeneous" : false,
112          "items" : [
113           {
114            "label" : "root URL",
115            "xtype" : "Label",
116            "* pack" : "pack_start,false,false,0",
117            "gint margin" : 3,
118            "$ xns" : "Gtk"
119           },
120           {
121            "id" : "rootURL",
122            "xtype" : "Entry",
123            "* pack" : "add",
124            "$ xns" : "Gtk"
125           }
126          ]
127         },
128         {
129          "label" : "HTML To insert at end of <HEAD>",
130          "xtype" : "Label",
131          "* pack" : "pack_start,false,false,0",
132          "$ xns" : "Gtk"
133         },
134         {
135          "* pack" : "pack_start,true,true,0",
136          "xtype" : "ScrolledWindow",
137          "$ xns" : "Gtk",
138          "items" : [
139           {
140            "listeners" : {
141             "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}"
142            },
143            "id" : "view",
144            "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
145            "xtype" : "View",
146            "* pack" : "add",
147            "$ xns" : "GtkSource"
148           }
149          ]
150         }
151        ]
152       },
153       {
154        "* pack" : "append_page,_this.label_database.el",
155        "xtype" : "VBox",
156        "gboolean homogeneous" : false,
157        "$ xns" : "Gtk",
158        "items" : [
159         {
160          "label" : "Type (eg. MySQL or PostgreSQL)",
161          "xalign" : 0,
162          "* pack" : "pack_start,false,false,0",
163          "xtype" : "Label",
164          "$ xns" : "Gtk"
165         },
166         {
167          "listeners" : {
168           "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"
169          },
170          "id" : "database_DBTYPE",
171          "* pack" : "pack_start,false,false,0",
172          "xtype" : "Entry",
173          "$ xns" : "Gtk"
174         },
175         {
176          "label" : "Name",
177          "xalign" : 0,
178          "* pack" : "pack_start,false,false,0",
179          "xtype" : "Label",
180          "$ xns" : "Gtk"
181         },
182         {
183          "listeners" : {
184           "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"
185          },
186          "id" : "database_DBNAME",
187          "xtype" : "Entry",
188          "* pack" : "pack_start,false,false,0",
189          "$ xns" : "Gtk"
190         },
191         {
192          "label" : "Username",
193          "xalign" : 0,
194          "* pack" : "pack_start,false,false,0",
195          "xtype" : "Label",
196          "$ xns" : "Gtk"
197         },
198         {
199          "listeners" : {
200           "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"
201          },
202          "id" : "database_DBUSERNAME",
203          "* pack" : "pack_start,false,false,0",
204          "xtype" : "Entry",
205          "$ xns" : "Gtk"
206         },
207         {
208          "label" : "Password",
209          "xalign" : 0,
210          "* pack" : "pack_start,false,false,0",
211          "xtype" : "Label",
212          "$ xns" : "Gtk"
213         },
214         {
215          "id" : "database_DBPASSWORD",
216          "xtype" : "Entry",
217          "* pack" : "pack_start,false,false,0",
218          "$ xns" : "Gtk"
219         },
220         {
221          "listeners" : {
222           "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}"
223          },
224          "* pack" : "pack_start,false,false,0",
225          "xtype" : "Button",
226          "$ xns" : "Gtk",
227          "utf8 label" : "Check Connection"
228         },
229         {
230          "label" : " ",
231          "id" : "database_ERROR",
232          "xalign" : 0,
233          "* pack" : "pack_start,false,false,0",
234          "xtype" : "Label",
235          "gint margin" : 3,
236          "$ xns" : "Gtk"
237         }
238        ]
239       }
240      ]
241     }
242    ]
243   }
244  ]
245 }