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        "Gtk.Orientation orientation" : "Gtk.Orientation.VERTICAL",
75        "items" : [
76         {
77          "label" : "filename",
78          "id" : "path",
79          "xalign" : 0,
80          "* pack" : "pack_start,false,false,0",
81          "xtype" : "Label",
82          "gint margin" : 3,
83          "$ xns" : "Gtk"
84         },
85         {
86          "* pack" : "pack_start,false,false,0",
87          "xtype" : "Box",
88          "gboolean expand" : false,
89          "$ xns" : "Gtk",
90          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
91          "$ homogeneous" : false,
92          "items" : [
93           {
94            "label" : "HTML template file",
95            "xtype" : "Label",
96            "* pack" : "pack_start,false,false,0",
97            "gint margin" : 3,
98            "$ xns" : "Gtk"
99           },
100           {
101            "id" : "base_template",
102            "xtype" : "Entry",
103            "* pack" : "add",
104            "$ xns" : "Gtk"
105           }
106          ]
107         },
108         {
109          "* pack" : "pack_start,false,false,0",
110          "xtype" : "Box",
111          "gboolean expand" : false,
112          "$ xns" : "Gtk",
113          "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL",
114          "$ homogeneous" : false,
115          "items" : [
116           {
117            "label" : "root URL",
118            "xtype" : "Label",
119            "* pack" : "pack_start,false,false,0",
120            "gint margin" : 3,
121            "$ xns" : "Gtk"
122           },
123           {
124            "id" : "rootURL",
125            "xtype" : "Entry",
126            "* pack" : "add",
127            "$ xns" : "Gtk"
128           }
129          ]
130         },
131         {
132          "label" : "HTML To insert at end of <HEAD>",
133          "xtype" : "Label",
134          "* pack" : "pack_start,false,false,0",
135          "$ xns" : "Gtk"
136         },
137         {
138          "* pack" : "pack_start,true,true,0",
139          "xtype" : "ScrolledWindow",
140          "$ xns" : "Gtk",
141          "items" : [
142           {
143            "listeners" : {
144             "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}"
145            },
146            "id" : "view",
147            "* init" : " \n    var description =   Pango.FontDescription.from_string(\"monospace\");\n    description.set_size(9000);\n    this.el.override_font(description);",
148            "xtype" : "View",
149            "* pack" : "add",
150            "$ xns" : "GtkSource"
151           }
152          ]
153         }
154        ]
155       },
156       {
157        "* pack" : "append_page,_this.label_database.el",
158        "xtype" : "Box",
159        "gboolean homogeneous" : false,
160        "$ xns" : "Gtk",
161        "items" : [
162         {
163          "label" : "Type (eg. MySQL or PostgreSQL)",
164          "xalign" : 0,
165          "* pack" : "pack_start,false,false,0",
166          "xtype" : "Label",
167          "$ xns" : "Gtk"
168         },
169         {
170          "listeners" : {
171           "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"
172          },
173          "id" : "database_DBTYPE",
174          "* pack" : "pack_start,false,false,0",
175          "xtype" : "Entry",
176          "$ xns" : "Gtk"
177         },
178         {
179          "label" : "Name",
180          "xalign" : 0,
181          "* pack" : "pack_start,false,false,0",
182          "xtype" : "Label",
183          "$ xns" : "Gtk"
184         },
185         {
186          "listeners" : {
187           "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"
188          },
189          "id" : "database_DBNAME",
190          "xtype" : "Entry",
191          "* pack" : "pack_start,false,false,0",
192          "$ xns" : "Gtk"
193         },
194         {
195          "label" : "Username",
196          "xalign" : 0,
197          "* pack" : "pack_start,false,false,0",
198          "xtype" : "Label",
199          "$ xns" : "Gtk"
200         },
201         {
202          "listeners" : {
203           "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"
204          },
205          "id" : "database_DBUSERNAME",
206          "* pack" : "pack_start,false,false,0",
207          "xtype" : "Entry",
208          "$ xns" : "Gtk"
209         },
210         {
211          "label" : "Password",
212          "xalign" : 0,
213          "* pack" : "pack_start,false,false,0",
214          "xtype" : "Label",
215          "$ xns" : "Gtk"
216         },
217         {
218          "id" : "database_DBPASSWORD",
219          "xtype" : "Entry",
220          "* pack" : "pack_start,false,false,0",
221          "$ xns" : "Gtk"
222         },
223         {
224          "listeners" : {
225           "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}"
226          },
227          "* pack" : "pack_start,false,false,0",
228          "xtype" : "Button",
229          "$ xns" : "Gtk",
230          "utf8 label" : "Check Connection"
231         },
232         {
233          "label" : " ",
234          "id" : "database_ERROR",
235          "xalign" : 0,
236          "* pack" : "pack_start,false,false,0",
237          "xtype" : "Label",
238          "gint margin" : 3,
239          "$ xns" : "Gtk"
240         }
241        ]
242       }
243      ]
244     }
245    ]
246   }
247  ]
248 }