1 static Xcls_RooProjectSettings _RooProjectSettings;
3 public class Xcls_RooProjectSettings : Object
6 private Xcls_RooProjectSettings _this;
8 public static Xcls_RooProjectSettings singleton()
10 if (_RooProjectSettings == null) {
11 _RooProjectSettings= new Xcls_RooProjectSettings();
13 return _RooProjectSettings;
15 public Xcls_label_global label_global;
16 public Xcls_label_database label_database;
17 public Xcls_grid grid;
18 public Xcls_path path;
19 public Xcls_base_template base_template;
20 public Xcls_base_template_cellrenderer base_template_cellrenderer;
21 public Xcls_base_template_model base_template_model;
22 public Xcls_rootURL rootURL;
23 public Xcls_html_gen html_gen;
24 public Xcls_html_gen_cellrenderer html_gen_cellrenderer;
25 public Xcls_html_gen_model html_gen_model;
26 public Xcls_view view;
27 public Xcls_database_DBTYPE database_DBTYPE;
28 public Xcls_database_DBNAME database_DBNAME;
29 public Xcls_database_DBUSERNAME database_DBUSERNAME;
30 public Xcls_database_DBPASSWORD database_DBPASSWORD;
31 public Xcls_database_ERROR database_ERROR;
34 public signal void buttonPressed (string btn);
35 public Project.Project project;
38 public Xcls_RooProjectSettings()
41 this.el = new Gtk.Popover( null );
46 this.el.border_width = 0;
48 this.el.position = Gtk.PositionType.RIGHT;
49 var child_0 = new Xcls_Box2( _this );
51 this.el.add ( child_0.el );
54 // user defined functions
55 public void show (Gtk.Widget btn, Project.Project project) {
56 _this.project = project;
57 _this.path.el.label = project.firstPath();
58 // get the active project.
59 var lm = Gtk.SourceLanguageManager.get_default();
61 ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
62 lm.get_language("html")
66 //project.runhtml = project.runhtml || '';
67 _this.view.el.get_buffer().set_text(project.runhtml);
71 _this.rootURL.el.set_text( _this.project.rootURL );
73 _this.html_gen_model.loadData(_this.project.html_gen);
75 _this.base_template_model.loadData();
77 var js = _this.project;
78 _this.database_DBTYPE.el.set_text( js.get_string_member("DBTYPE") );
79 _this.database_DBNAME.el.set_text( js.get_string_member("DBNAME") );
80 _this.database_DBUSERNAME.el.set_text( js.get_string_member("DBUSERNAME") );
81 _this.database_DBPASSWORD.el.set_text( js.get_string_member("DBPASSWORD") );
83 //console.log('show all');
84 this.el.set_modal(true);
85 this.el.set_relative_to(btn);
87 this.el.set_position(Gtk.PositionType.RIGHT);
90 print("SHOWALL - POPIP\n");
92 this.el.set_size_request(800,500);
93 this.view.el.grab_focus();
99 var buf = _this.view.el.get_buffer();
102 buf.get_start_iter(out s);
103 buf.get_end_iter(out e);
104 _this.project.runhtml = buf.get_text(s,e,true);
106 _this.project.rootURL = _this.rootURL.el.get_text();
111 _this.html_gen.el.get_active_iter(out iter);
112 _this.html_gen_model.el.get_value (iter, 0, out html_gen_val);
114 _this.project.html_gen = (string)html_gen_val;
116 // set by event changed...
117 //_this.project.base_template = _this.base_template.el.get_text();
119 var js = _this.project.json_project_data;
120 js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text());
121 js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text());
122 js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text());
123 js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text());
124 // _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());
126 // need to re-init the database
128 _this.project.initRooDatabase();
132 public class Xcls_Box2 : Object
135 private Xcls_RooProjectSettings _this;
141 public Xcls_Box2(Xcls_RooProjectSettings _owner )
144 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
148 // set gobject values
149 this.el.homogeneous = false;
150 this.el.border_width = 5;
151 var child_0 = new Xcls_Notebook3( _this );
153 this.el.pack_start ( child_0.el , true,true,0 );
154 var child_1 = new Xcls_Box34( _this );
156 this.el.pack_end ( child_1.el , false,false,0 );
159 // user defined functions
161 public class Xcls_Notebook3 : Object
163 public Gtk.Notebook el;
164 private Xcls_RooProjectSettings _this;
170 public Xcls_Notebook3(Xcls_RooProjectSettings _owner )
173 this.el = new Gtk.Notebook();
177 // set gobject values
178 var child_0 = new Xcls_label_global( _this );
180 var child_1 = new Xcls_label_database( _this );
182 var child_2 = new Xcls_Box6( _this );
184 this.el.append_page ( child_2.el , _this.label_global.el );
185 var child_3 = new Xcls_Box23( _this );
187 this.el.append_page ( child_3.el , _this.label_database.el );
190 // user defined functions
192 public class Xcls_label_global : Object
195 private Xcls_RooProjectSettings _this;
201 public Xcls_label_global(Xcls_RooProjectSettings _owner )
204 _this.label_global = this;
205 this.el = new Gtk.Label( "Global" );
209 // set gobject values
212 // user defined functions
215 public class Xcls_label_database : Object
218 private Xcls_RooProjectSettings _this;
224 public Xcls_label_database(Xcls_RooProjectSettings _owner )
227 _this.label_database = this;
228 this.el = new Gtk.Label( "Database" );
232 // set gobject values
235 // user defined functions
238 public class Xcls_Box6 : Object
241 private Xcls_RooProjectSettings _this;
247 public Xcls_Box6(Xcls_RooProjectSettings _owner )
250 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
254 // set gobject values
255 this.el.homogeneous = false;
256 var child_0 = new Xcls_grid( _this );
258 this.el.pack_start ( child_0.el , false,false,4 );
259 var child_1 = new Xcls_Label20( _this );
261 this.el.pack_start ( child_1.el , false,false,0 );
262 var child_2 = new Xcls_ScrolledWindow21( _this );
264 this.el.pack_start ( child_2.el , true,true,0 );
267 // user defined functions
269 public class Xcls_grid : Object
272 private Xcls_RooProjectSettings _this;
278 public Xcls_grid(Xcls_RooProjectSettings _owner )
282 this.el = new Gtk.Grid();
286 // set gobject values
287 this.el.margin_right = 4;
288 this.el.margin_left = 4;
289 this.el.row_spacing = 2;
290 var child_0 = new Xcls_Label8( _this );
292 this.el.attach ( child_0.el , 0,0,1,1 );
293 var child_1 = new Xcls_path( _this );
295 this.el.attach ( child_1.el , 1,0,1,1 );
296 var child_2 = new Xcls_Label10( _this );
298 this.el.attach ( child_2.el , 0,1,1,1 );
299 var child_3 = new Xcls_base_template( _this );
301 this.el.attach ( child_3.el , 1,1,1,1 );
302 var child_4 = new Xcls_Label14( _this );
304 this.el.attach ( child_4.el , 0,2,1,1 );
305 var child_5 = new Xcls_rootURL( _this );
307 this.el.attach ( child_5.el , 1,2,1,1 );
308 var child_6 = new Xcls_Label16( _this );
310 this.el.attach ( child_6.el , 0,3,1,1 );
311 var child_7 = new Xcls_html_gen( _this );
313 this.el.attach ( child_7.el , 1,3,1,1 );
316 // user defined functions
318 public class Xcls_Label8 : Object
321 private Xcls_RooProjectSettings _this;
327 public Xcls_Label8(Xcls_RooProjectSettings _owner )
330 this.el = new Gtk.Label( "Filename" );
334 // set gobject values
339 // user defined functions
342 public class Xcls_path : Object
345 private Xcls_RooProjectSettings _this;
351 public Xcls_path(Xcls_RooProjectSettings _owner )
355 this.el = new Gtk.Label( "filename" );
359 // set gobject values
364 // user defined functions
367 public class Xcls_Label10 : Object
370 private Xcls_RooProjectSettings _this;
376 public Xcls_Label10(Xcls_RooProjectSettings _owner )
379 this.el = new Gtk.Label( "HTML template file" );
383 // set gobject values
387 // user defined functions
390 public class Xcls_base_template : Object
392 public Gtk.ComboBox el;
393 private Xcls_RooProjectSettings _this;
400 public Xcls_base_template(Xcls_RooProjectSettings _owner )
403 _this.base_template = this;
404 this.el = new Gtk.ComboBox();
407 this.loading = false;
409 // set gobject values
410 var child_0 = new Xcls_base_template_cellrenderer( _this );
412 this.el.pack_start ( child_0.el , true );
413 var child_1 = new Xcls_base_template_model( _this );
415 this.el.set_model ( child_1.el );
419 this.el.add_attribute(_this.base_template_cellrenderer.el , "markup", 0 );
422 this.el.changed.connect( () => {
425 // this get's called when we are filling in the data... ???
431 if (this.el.get_active_iter(out iter)) {
433 _this.base_template_model.el.get_value (iter, 0, out vfname);
434 _this.project.base_template = ((string)vfname) ;
436 print("\nSET base template to %s\n", _this.project.base_template );
437 // is_bjs = ((string)vfname) == "bjs";
441 // directory is only available for non-bjs
448 // user defined functions
450 public class Xcls_base_template_cellrenderer : Object
452 public Gtk.CellRendererText el;
453 private Xcls_RooProjectSettings _this;
459 public Xcls_base_template_cellrenderer(Xcls_RooProjectSettings _owner )
462 _this.base_template_cellrenderer = this;
463 this.el = new Gtk.CellRendererText();
467 // set gobject values
470 // user defined functions
473 public class Xcls_base_template_model : Object
475 public Gtk.ListStore el;
476 private Xcls_RooProjectSettings _this;
482 public Xcls_base_template_model(Xcls_RooProjectSettings _owner )
485 _this.base_template_model = this;
486 this.el = new Gtk.ListStore( 1, typeof(string) );
490 // set gobject values
493 // user defined functions
494 public void loadData () {
495 _this.base_template.loading = true;
501 /// el.append(out iter);
505 el.set_value(iter, 0, "roo.builder.html");
506 _this.base_template.el.set_active_iter(iter);
507 if (_this.project.base_template == "roo.builder.html") {
508 _this.base_template.el.set_active_iter(iter);
512 el.set_value(iter, 0, "bootstrap.builder.html");
514 print("\ncur template = %s\n", _this.project.base_template);
516 if (_this.project.base_template == "bootstrap.builder.html") {
517 _this.base_template.el.set_active_iter(iter);
521 el.set_value(iter, 0, "mailer.builder.html");
523 if (_this.project.base_template == "mailer.builder.html") {
524 _this.base_template.el.set_active_iter(iter);
526 _this.base_template.loading = false;
532 public class Xcls_Label14 : Object
535 private Xcls_RooProjectSettings _this;
541 public Xcls_Label14(Xcls_RooProjectSettings _owner )
544 this.el = new Gtk.Label( "root URL" );
548 // set gobject values
552 // user defined functions
555 public class Xcls_rootURL : Object
558 private Xcls_RooProjectSettings _this;
564 public Xcls_rootURL(Xcls_RooProjectSettings _owner )
567 _this.rootURL = this;
568 this.el = new Gtk.Entry();
572 // set gobject values
575 // user defined functions
578 public class Xcls_Label16 : Object
581 private Xcls_RooProjectSettings _this;
587 public Xcls_Label16(Xcls_RooProjectSettings _owner )
590 this.el = new Gtk.Label( "Generate HTML in" );
594 // set gobject values
598 // user defined functions
601 public class Xcls_html_gen : Object
603 public Gtk.ComboBox el;
604 private Xcls_RooProjectSettings _this;
610 public Xcls_html_gen(Xcls_RooProjectSettings _owner )
613 _this.html_gen = this;
614 this.el = new Gtk.ComboBox();
618 // set gobject values
619 var child_0 = new Xcls_html_gen_cellrenderer( _this );
621 this.el.pack_start ( child_0.el , true );
622 var child_1 = new Xcls_html_gen_model( _this );
624 this.el.set_model ( child_1.el );
628 this.el.add_attribute(_this.html_gen_cellrenderer.el , "markup", 1 );
631 // user defined functions
633 public class Xcls_html_gen_cellrenderer : Object
635 public Gtk.CellRendererText el;
636 private Xcls_RooProjectSettings _this;
642 public Xcls_html_gen_cellrenderer(Xcls_RooProjectSettings _owner )
645 _this.html_gen_cellrenderer = this;
646 this.el = new Gtk.CellRendererText();
650 // set gobject values
653 // user defined functions
656 public class Xcls_html_gen_model : Object
658 public Gtk.ListStore el;
659 private Xcls_RooProjectSettings _this;
665 public Xcls_html_gen_model(Xcls_RooProjectSettings _owner )
668 _this.html_gen_model = this;
669 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
673 // set gobject values
676 // user defined functions
677 public void loadData (string cur) {
686 el.set_value(iter, 0, "");
687 el.set_value(iter, 1, "Do not Generate");
688 _this.html_gen.el.set_active_iter(iter);
692 el.set_value(iter, 0, "same directory as BJS file");
693 el.set_value(iter, 1, "bjs");
695 _this.html_gen.el.set_active_iter(iter);
702 el.set_value(iter, 0, "template");
703 el.set_value(iter, 1, "in template subdirectory");
705 if (cur == "template") {
706 _this.html_gen.el.set_active_iter(iter);
715 public class Xcls_Label20 : Object
718 private Xcls_RooProjectSettings _this;
724 public Xcls_Label20(Xcls_RooProjectSettings _owner )
727 this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
731 // set gobject values
734 // user defined functions
737 public class Xcls_ScrolledWindow21 : Object
739 public Gtk.ScrolledWindow el;
740 private Xcls_RooProjectSettings _this;
746 public Xcls_ScrolledWindow21(Xcls_RooProjectSettings _owner )
749 this.el = new Gtk.ScrolledWindow( null, null );
753 // set gobject values
754 var child_0 = new Xcls_view( _this );
756 this.el.add ( child_0.el );
759 // user defined functions
761 public class Xcls_view : Object
763 public Gtk.SourceView el;
764 private Xcls_RooProjectSettings _this;
770 public Xcls_view(Xcls_RooProjectSettings _owner )
774 this.el = new Gtk.SourceView();
780 var description = Pango.FontDescription.from_string("monospace");
781 description.set_size(9000);
782 this.el.override_font(description);
785 this.el.key_release_event.connect( ( event) =>{
786 if (event.keyval != 115) {
790 if ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
793 var buf = this.el.get_buffer();
796 buf.get_start_iter(out s);
797 buf.get_end_iter(out e);
798 _this.project.runhtml = buf.get_text(s,e,true);
801 _this.buttonPressed("save");
808 // user defined functions
813 public class Xcls_Box23 : Object
816 private Xcls_RooProjectSettings _this;
822 public Xcls_Box23(Xcls_RooProjectSettings _owner )
825 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
829 // set gobject values
830 this.el.homogeneous = false;
831 var child_0 = new Xcls_Label24( _this );
833 this.el.pack_start ( child_0.el , false,false,0 );
834 var child_1 = new Xcls_database_DBTYPE( _this );
836 this.el.pack_start ( child_1.el , false,false,0 );
837 var child_2 = new Xcls_Label26( _this );
839 this.el.pack_start ( child_2.el , false,false,0 );
840 var child_3 = new Xcls_database_DBNAME( _this );
842 this.el.pack_start ( child_3.el , false,false,0 );
843 var child_4 = new Xcls_Label28( _this );
845 this.el.pack_start ( child_4.el , false,false,0 );
846 var child_5 = new Xcls_database_DBUSERNAME( _this );
848 this.el.pack_start ( child_5.el , false,false,0 );
849 var child_6 = new Xcls_Label30( _this );
851 this.el.pack_start ( child_6.el , false,false,0 );
852 var child_7 = new Xcls_database_DBPASSWORD( _this );
854 this.el.pack_start ( child_7.el , false,false,0 );
855 var child_8 = new Xcls_Button32( _this );
857 this.el.pack_start ( child_8.el , false,false,0 );
858 var child_9 = new Xcls_database_ERROR( _this );
860 this.el.pack_start ( child_9.el , false,false,0 );
863 // user defined functions
865 public class Xcls_Label24 : Object
868 private Xcls_RooProjectSettings _this;
874 public Xcls_Label24(Xcls_RooProjectSettings _owner )
877 this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
881 // set gobject values
885 // user defined functions
888 public class Xcls_database_DBTYPE : Object
891 private Xcls_RooProjectSettings _this;
897 public Xcls_database_DBTYPE(Xcls_RooProjectSettings _owner )
900 _this.database_DBTYPE = this;
901 this.el = new Gtk.Entry();
905 // set gobject values
908 this.el.key_press_event.connect( (ev) => {
910 if (ev.keyval == Gdk.Key.Tab) {
911 _this.database_DBNAME.el.grab_focus();
920 // user defined functions
923 public class Xcls_Label26 : Object
926 private Xcls_RooProjectSettings _this;
932 public Xcls_Label26(Xcls_RooProjectSettings _owner )
935 this.el = new Gtk.Label( "Name" );
939 // set gobject values
943 // user defined functions
946 public class Xcls_database_DBNAME : Object
949 private Xcls_RooProjectSettings _this;
955 public Xcls_database_DBNAME(Xcls_RooProjectSettings _owner )
958 _this.database_DBNAME = this;
959 this.el = new Gtk.Entry();
963 // set gobject values
966 this.el.key_press_event.connect( (ev) => {
968 if (ev.keyval == Gdk.Key.Tab) {
969 _this.database_DBUSERNAME.el.grab_focus();
978 // user defined functions
981 public class Xcls_Label28 : Object
984 private Xcls_RooProjectSettings _this;
990 public Xcls_Label28(Xcls_RooProjectSettings _owner )
993 this.el = new Gtk.Label( "Username" );
997 // set gobject values
1001 // user defined functions
1004 public class Xcls_database_DBUSERNAME : Object
1006 public Gtk.Entry el;
1007 private Xcls_RooProjectSettings _this;
1013 public Xcls_database_DBUSERNAME(Xcls_RooProjectSettings _owner )
1016 _this.database_DBUSERNAME = this;
1017 this.el = new Gtk.Entry();
1021 // set gobject values
1024 this.el.key_press_event.connect( (ev) => {
1026 if (ev.keyval == Gdk.Key.Tab) {
1027 _this.database_DBPASSWORD.el.grab_focus();
1036 // user defined functions
1039 public class Xcls_Label30 : Object
1041 public Gtk.Label el;
1042 private Xcls_RooProjectSettings _this;
1048 public Xcls_Label30(Xcls_RooProjectSettings _owner )
1051 this.el = new Gtk.Label( "Password" );
1055 // set gobject values
1056 this.el.xalign = 0f;
1059 // user defined functions
1062 public class Xcls_database_DBPASSWORD : Object
1064 public Gtk.Entry el;
1065 private Xcls_RooProjectSettings _this;
1071 public Xcls_database_DBPASSWORD(Xcls_RooProjectSettings _owner )
1074 _this.database_DBPASSWORD = this;
1075 this.el = new Gtk.Entry();
1079 // set gobject values
1082 // user defined functions
1085 public class Xcls_Button32 : Object
1087 public Gtk.Button el;
1088 private Xcls_RooProjectSettings _this;
1094 public Xcls_Button32(Xcls_RooProjectSettings _owner )
1097 this.el = new Gtk.Button();
1101 // set gobject values
1102 this.el.label = "Check Connection";
1105 this.el.clicked.connect( () => {
1108 _this.database_ERROR.el.label = "";
1111 // assumes localhost...
1112 cnc = Gda.Connection.open_from_string (
1113 _this.database_DBTYPE.el.get_text(),
1114 "DB_NAME=" + _this.database_DBNAME.el.get_text(),
1115 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() +
1116 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
1117 Gda.ConnectionOptions.NONE
1119 //} catch (Gda.ConnectionError ce) {
1120 // _this.database_ERROR.el.label = ce.message;
1121 } catch(Gda.ConnectionError ue) {
1122 _this.database_ERROR.el.label = ue.message;
1124 } catch(Gda.ConfigError ue) {
1125 _this.database_ERROR.el.label = ue.message;
1128 _this.database_ERROR.el.label = "Connection Succeeded";
1133 // user defined functions
1136 public class Xcls_database_ERROR : Object
1138 public Gtk.Label el;
1139 private Xcls_RooProjectSettings _this;
1145 public Xcls_database_ERROR(Xcls_RooProjectSettings _owner )
1148 _this.database_ERROR = this;
1149 this.el = new Gtk.Label( " " );
1153 // set gobject values
1155 this.el.xalign = 0f;
1158 // user defined functions
1163 public class Xcls_Box34 : Object
1166 private Xcls_RooProjectSettings _this;
1172 public Xcls_Box34(Xcls_RooProjectSettings _owner )
1175 this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
1179 // set gobject values
1180 this.el.homogeneous = true;
1181 this.el.expand = false;
1182 this.el.vexpand = false;
1183 var child_0 = new Xcls_Button35( _this );
1185 this.el.add ( child_0.el );
1186 var child_1 = new Xcls_Button36( _this );
1188 this.el.add ( child_1.el );
1191 // user defined functions
1193 public class Xcls_Button35 : Object
1195 public Gtk.Button el;
1196 private Xcls_RooProjectSettings _this;
1202 public Xcls_Button35(Xcls_RooProjectSettings _owner )
1205 this.el = new Gtk.Button();
1209 // set gobject values
1210 this.el.label = "Apply";
1213 this.el.button_press_event.connect( () => {
1216 _this.buttonPressed("apply");
1221 // user defined functions
1224 public class Xcls_Button36 : Object
1226 public Gtk.Button el;
1227 private Xcls_RooProjectSettings _this;
1233 public Xcls_Button36(Xcls_RooProjectSettings _owner )
1236 this.el = new Gtk.Button();
1240 // set gobject values
1241 this.el.label = "Save";
1244 this.el.button_press_event.connect( () => {
1247 _this.buttonPressed("save");
1252 // user defined functions