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_rootURL rootURL;
21 public Xcls_html_gen html_gen;
22 public Xcls_view view;
23 public Xcls_database_DBTYPE database_DBTYPE;
24 public Xcls_database_DBNAME database_DBNAME;
25 public Xcls_database_ERROR database_ERROR;
28 public signal void buttonPressed (string btn);
30 public Project.Roo project;
33 public Xcls_RooProjectSettings()
36 this.el = new Gtk.Window();
42 this.el.title = "Edit Project settings";
44 var child_1 = new Xcls_Box1( _this );
46 this.el.set_child ( child_1.el );
47 var child_2 = new Xcls_HeaderBar37( _this );
49 this.el.titlebar = child_2.el;
52 // user defined functions
53 public void show (Gtk.Window pwin, Project.Roo project) {
56 _this.project = project;
57 _this.path.el.label = project.path;
58 // get the active project.
59 var lm = GtkSource.LanguageManager.get_default();
61 ((GtkSource.Buffer)(_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);
70 _this.rootURL.el.set_text( _this.project.rootURL );
74 switch (this.project.html_gen) {
75 case "bjs": tv = 1; break;
76 case "template": tv = 2; break;
78 this.html_gen.el.selected = tv;
82 var sm = (Gtk.StringList) _this.base_template.el.model;
83 this.base_template.loading = true;
84 this.base_template.el.selected = Gtk.INVALID_LIST_POSITION;
85 for(var i=0;i< sm.get_n_items(); i++) {
86 if (sm.get_string( i ) == this.project.base_template) {
87 this.base_template.el.selected = i;
91 this.base_template.loading = false;
92 //var js = _this.project;
93 _this.database_DBTYPE.el.set_text( _this.project.DBTYPE );
94 _this.database_DBNAME.el.set_text( _this.project.DBNAME );
95 //_this.database_DBUSERNAME.el.set_text( _this.project.DBUSERNAME );
96 //_this.database_DBPASSWORD.el.set_text( _this.project.DBPASSWORD );
98 //console.log('show all');
101 this.el.set_transient_for(pwin);
103 print("SHOWALL - POPIP\n");
105 this.el.set_size_request(800,600);
106 this.view.el.grab_focus();
109 //this.el.show_all();
111 public void save () {
112 var buf = _this.view.el.get_buffer();
115 buf.get_start_iter(out s);
116 buf.get_end_iter(out e);
117 _this.project.runhtml = buf.get_text(s,e,true);
119 _this.project.rootURL = _this.rootURL.el.get_text();
125 switch (this.html_gen.el.selected) {
126 case 1: val = "bjs"; break;
127 case 2: val = "template"; break;
130 _this.project.html_gen = val;
132 // set by event changed...
133 //_this.project.base_template = _this.base_template.el.get_text();
135 var js = _this.project;
136 js.DBTYPE = _this.database_DBTYPE.el.get_text();
137 js.DBNAME= _this.database_DBNAME.el.get_text();
138 // js.DBUSERNAME= _this.database_DBUSERNAME.el.get_text();
139 // js.DBPASSWORD= _this.database_DBPASSWORD.el.get_text();
140 // _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());
142 // need to re-init the database
144 _this.project.initDatabase();
148 public class Xcls_Box1 : Object
151 private Xcls_RooProjectSettings _this;
157 public Xcls_Box1(Xcls_RooProjectSettings _owner )
160 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
164 // set gobject values
165 this.el.homogeneous = false;
166 var child_1 = new Xcls_Notebook2( _this );
168 this.el.append( child_1.el );
171 // user defined functions
173 public class Xcls_Notebook2 : Object
175 public Gtk.Notebook el;
176 private Xcls_RooProjectSettings _this;
182 public Xcls_Notebook2(Xcls_RooProjectSettings _owner )
185 this.el = new Gtk.Notebook();
189 // set gobject values
190 new Xcls_label_global( _this );
191 new Xcls_label_database( _this );
192 var child_3 = new Xcls_Box5( _this );
194 this.el.append_page ( child_3.el , _this.label_global.el );
195 var child_4 = new Xcls_Box23( _this );
197 this.el.append_page ( child_4.el , _this.label_database.el );
200 // user defined functions
202 public class Xcls_label_global : Object
205 private Xcls_RooProjectSettings _this;
211 public Xcls_label_global(Xcls_RooProjectSettings _owner )
214 _this.label_global = this;
215 this.el = new Gtk.Label( "Global" );
219 // set gobject values
222 // user defined functions
225 public class Xcls_label_database : Object
228 private Xcls_RooProjectSettings _this;
234 public Xcls_label_database(Xcls_RooProjectSettings _owner )
237 _this.label_database = this;
238 this.el = new Gtk.Label( "Database" );
242 // set gobject values
245 // user defined functions
248 public class Xcls_Box5 : Object
251 private Xcls_RooProjectSettings _this;
257 public Xcls_Box5(Xcls_RooProjectSettings _owner )
260 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
264 // set gobject values
265 this.el.homogeneous = false;
266 new Xcls_grid( _this );
267 this.el.append( _this.grid.el );
268 var child_2 = new Xcls_Label19( _this );
270 this.el.append( child_2.el );
271 var child_3 = new Xcls_ScrolledWindow20( _this );
273 this.el.append( child_3.el );
276 // user defined functions
278 public class Xcls_grid : Object
281 private Xcls_RooProjectSettings _this;
287 public Xcls_grid(Xcls_RooProjectSettings _owner )
291 this.el = new Gtk.Grid();
295 // set gobject values
296 this.el.margin_end = 4;
297 this.el.margin_start = 4;
298 this.el.row_spacing = 2;
299 var child_1 = new Xcls_Label7( _this );
301 this.el.attach ( child_1.el , 0,0,1,1 );
302 new Xcls_path( _this );
303 this.el.attach ( _this.path.el , 1,0,1,1 );
304 var child_3 = new Xcls_Label9( _this );
306 this.el.attach ( child_3.el , 0,1,1,1 );
307 new Xcls_base_template( _this );
308 this.el.attach ( _this.base_template.el , 1,1,1,1 );
309 var child_5 = new Xcls_Label13( _this );
311 this.el.attach ( child_5.el , 0,2,1,1 );
312 new Xcls_rootURL( _this );
313 this.el.attach ( _this.rootURL.el , 1,2,1,1 );
314 var child_7 = new Xcls_Label15( _this );
316 this.el.attach ( child_7.el , 0,3,1,1 );
317 new Xcls_html_gen( _this );
318 this.el.attach ( _this.html_gen.el , 1,3,1,1 );
321 // user defined functions
323 public class Xcls_Label7 : Object
326 private Xcls_RooProjectSettings _this;
332 public Xcls_Label7(Xcls_RooProjectSettings _owner )
335 this.el = new Gtk.Label( "Filename" );
339 // set gobject values
340 this.el.margin_end = 3;
341 this.el.margin_start = 3;
343 this.el.margin_bottom = 3;
344 this.el.margin_top = 3;
347 // user defined functions
350 public class Xcls_path : Object
353 private Xcls_RooProjectSettings _this;
359 public Xcls_path(Xcls_RooProjectSettings _owner )
363 this.el = new Gtk.Label( "filename" );
367 // set gobject values
368 this.el.margin_end = 3;
369 this.el.margin_start = 3;
371 this.el.margin_bottom = 3;
372 this.el.margin_top = 3;
375 // user defined functions
378 public class Xcls_Label9 : Object
381 private Xcls_RooProjectSettings _this;
387 public Xcls_Label9(Xcls_RooProjectSettings _owner )
390 this.el = new Gtk.Label( "HTML template file" );
394 // set gobject values
395 this.el.margin_end = 3;
396 this.el.margin_start = 3;
397 this.el.margin_bottom = 3;
398 this.el.margin_top = 3;
401 // user defined functions
404 public class Xcls_base_template : Object
406 public Gtk.DropDown el;
407 private Xcls_RooProjectSettings _this;
414 public Xcls_base_template(Xcls_RooProjectSettings _owner )
417 _this.base_template = this;
418 var child_1 = new Xcls_StringList221( _this );
420 this.el = new Gtk.DropDown( child_1.el, null );
423 this.loading = false;
425 // set gobject values
428 this.el.notify["selected"].connect( () => {
431 // this get's called when we are filling in the data... ???
435 var sm = (Gtk.StringList) this.el.model;
436 _this.project.base_template = sm.get_string(this.el.selected);
438 print("\nSET base template to %s\n", _this.project.base_template );
439 // is_bjs = ((string)vfname) == "bjs";
445 // user defined functions
447 public class Xcls_StringList221 : Object
449 public Gtk.StringList el;
450 private Xcls_RooProjectSettings _this;
456 public Xcls_StringList221(Xcls_RooProjectSettings _owner )
459 this.el = new Gtk.StringList( {
461 "bootstrap.builder.html",
462 "bootstrap4.builder.html",
463 "mailer.builder.html"
468 // set gobject values
471 // user defined functions
475 public class Xcls_Label13 : Object
478 private Xcls_RooProjectSettings _this;
484 public Xcls_Label13(Xcls_RooProjectSettings _owner )
487 this.el = new Gtk.Label( "root URL" );
491 // set gobject values
492 this.el.margin_end = 3;
493 this.el.margin_start = 3;
494 this.el.margin_bottom = 3;
495 this.el.margin_top = 3;
498 // user defined functions
501 public class Xcls_rootURL : Object
504 private Xcls_RooProjectSettings _this;
510 public Xcls_rootURL(Xcls_RooProjectSettings _owner )
513 _this.rootURL = this;
514 this.el = new Gtk.Entry();
518 // set gobject values
521 // user defined functions
524 public class Xcls_Label15 : Object
527 private Xcls_RooProjectSettings _this;
533 public Xcls_Label15(Xcls_RooProjectSettings _owner )
536 this.el = new Gtk.Label( "Generate HTML in" );
540 // set gobject values
543 // user defined functions
546 public class Xcls_html_gen : Object
548 public Gtk.DropDown el;
549 private Xcls_RooProjectSettings _this;
556 public Xcls_html_gen(Xcls_RooProjectSettings _owner )
559 _this.html_gen = this;
560 var child_1 = new Xcls_StringList322( _this );
562 this.el = new Gtk.DropDown( child_1.el, null );
565 this.loading = false;
567 // set gobject values
570 this.el.notify["selected"].connect( () => {
573 // this get's called when we are filling in the data... ???
577 var sm = (Gtk.StringList) this.el.model;
578 _this.project.base_template = sm.get_string(this.el.selected);
580 print("\nSET base template to %s\n", _this.project.base_template );
581 // is_bjs = ((string)vfname) == "bjs";
587 // user defined functions
589 public class Xcls_StringList322 : Object
591 public Gtk.StringList el;
592 private Xcls_RooProjectSettings _this;
598 public Xcls_StringList322(Xcls_RooProjectSettings _owner )
601 this.el = new Gtk.StringList( {
602 "Do not Generate", // ""
603 "same directory as BJS file", // bjs
604 "in templates subdirectory" // tmeplate
610 // set gobject values
613 // user defined functions
618 public class Xcls_Label19 : Object
621 private Xcls_RooProjectSettings _this;
627 public Xcls_Label19(Xcls_RooProjectSettings _owner )
630 this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
634 // set gobject values
637 // user defined functions
640 public class Xcls_ScrolledWindow20 : Object
642 public Gtk.ScrolledWindow el;
643 private Xcls_RooProjectSettings _this;
649 public Xcls_ScrolledWindow20(Xcls_RooProjectSettings _owner )
652 this.el = new Gtk.ScrolledWindow();
656 // set gobject values
657 this.el.vexpand = true;
658 new Xcls_view( _this );
659 this.el.set_child ( _this.view.el );
662 // user defined functions
664 public class Xcls_view : Object
666 public GtkSource.View el;
667 private Xcls_RooProjectSettings _this;
673 public Xcls_view(Xcls_RooProjectSettings _owner )
677 this.el = new GtkSource.View();
681 // set gobject values
682 this.el.css_classes = { "code-editor" };
683 var child_1 = new Xcls_EventControllerKey22( _this );
685 this.el.add_controller( child_1.el );
688 // user defined functions
690 public class Xcls_EventControllerKey22 : Object
692 public Gtk.EventControllerKey el;
693 private Xcls_RooProjectSettings _this;
699 public Xcls_EventControllerKey22(Xcls_RooProjectSettings _owner )
702 this.el = new Gtk.EventControllerKey();
706 // set gobject values
709 this.el.key_released.connect( (keyval, keycode, state) => {
716 if ( (state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
719 var buf = _this.view.el.get_buffer();
722 buf.get_start_iter(out s);
723 buf.get_end_iter(out e);
724 _this.project.runhtml = buf.get_text(s,e,true);
727 _this.buttonPressed("save");
734 // user defined functions
740 public class Xcls_Box23 : Object
743 private Xcls_RooProjectSettings _this;
749 public Xcls_Box23(Xcls_RooProjectSettings _owner )
752 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
756 // set gobject values
757 this.el.homogeneous = false;
758 var child_1 = new Xcls_Label24( _this );
760 this.el.append( child_1.el );
761 new Xcls_database_DBTYPE( _this );
762 this.el.append( _this.database_DBTYPE.el );
763 var child_3 = new Xcls_Label27( _this );
765 this.el.append( child_3.el );
766 new Xcls_database_DBNAME( _this );
767 this.el.append( _this.database_DBNAME.el );
768 var child_5 = new Xcls_Button35( _this );
770 this.el.append( child_5.el );
771 new Xcls_database_ERROR( _this );
772 this.el.append( _this.database_ERROR.el );
775 // user defined functions
777 public class Xcls_Label24 : Object
780 private Xcls_RooProjectSettings _this;
786 public Xcls_Label24(Xcls_RooProjectSettings _owner )
789 this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
793 // set gobject values
797 // user defined functions
800 public class Xcls_database_DBTYPE : Object
803 private Xcls_RooProjectSettings _this;
809 public Xcls_database_DBTYPE(Xcls_RooProjectSettings _owner )
812 _this.database_DBTYPE = this;
813 this.el = new Gtk.Entry();
817 // set gobject values
818 var child_1 = new Xcls_EventControllerKey26( _this );
820 this.el.add_controller( child_1.el );
823 // user defined functions
825 public class Xcls_EventControllerKey26 : Object
827 public Gtk.EventControllerKey el;
828 private Xcls_RooProjectSettings _this;
834 public Xcls_EventControllerKey26(Xcls_RooProjectSettings _owner )
837 this.el = new Gtk.EventControllerKey();
841 // set gobject values
844 this.el.key_pressed.connect( (keyval, keycode, state) => {
845 if (keyval == Gdk.Key.Tab) {
846 _this.database_DBNAME.el.grab_focus();
855 // user defined functions
859 public class Xcls_Label27 : Object
862 private Xcls_RooProjectSettings _this;
868 public Xcls_Label27(Xcls_RooProjectSettings _owner )
871 this.el = new Gtk.Label( "Name" );
875 // set gobject values
879 // user defined functions
882 public class Xcls_database_DBNAME : Object
885 private Xcls_RooProjectSettings _this;
891 public Xcls_database_DBNAME(Xcls_RooProjectSettings _owner )
894 _this.database_DBNAME = this;
895 this.el = new Gtk.Entry();
899 // set gobject values
900 var child_1 = new Xcls_EventControllerKey29( _this );
902 this.el.add_controller( child_1.el );
905 // user defined functions
907 public class Xcls_EventControllerKey29 : Object
909 public Gtk.EventControllerKey el;
910 private Xcls_RooProjectSettings _this;
916 public Xcls_EventControllerKey29(Xcls_RooProjectSettings _owner )
919 this.el = new Gtk.EventControllerKey();
923 // set gobject values
926 this.el.key_pressed.connect( (keyval, keycode, state) => {
927 if (keyval == Gdk.Key.Tab) {
928 _this.database_DBUSERNAME.el.grab_focus();
938 // user defined functions
942 public class Xcls_Button35 : Object
944 public Gtk.Button el;
945 private Xcls_RooProjectSettings _this;
951 public Xcls_Button35(Xcls_RooProjectSettings _owner )
954 this.el = new Gtk.Button();
958 // set gobject values
959 this.el.label = "Check Connection";
962 this.el.clicked.connect( () => {
965 _this.database_ERROR.el.label = "";
969 // assumes localhost...
970 cnc = Gda.Connection.open_from_string (
971 _this.database_DBTYPE.el.get_text(),
972 "DB_NAME=" + _this.database_DBNAME.el.get_text(),
973 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() +
974 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
975 Gda.ConnectionOptions.NONE
977 //} catch (Gda.ConnectionError ce) {
978 // _this.database_ERROR.el.label = ce.message;
979 } catch(GLib.Error ue) {
980 _this.database_ERROR.el.label = ue.message;
983 _this.database_ERROR.el.label = "Connection Succeeded";
989 // user defined functions
992 public class Xcls_database_ERROR : Object
995 private Xcls_RooProjectSettings _this;
1001 public Xcls_database_ERROR(Xcls_RooProjectSettings _owner )
1004 _this.database_ERROR = this;
1005 this.el = new Gtk.Label( " " );
1009 // set gobject values
1010 this.el.xalign = 0f;
1013 // user defined functions
1019 public class Xcls_HeaderBar37 : Object
1021 public Gtk.HeaderBar el;
1022 private Xcls_RooProjectSettings _this;
1028 public Xcls_HeaderBar37(Xcls_RooProjectSettings _owner )
1031 this.el = new Gtk.HeaderBar();
1035 // set gobject values
1036 this.el.show_title_buttons = false;
1037 var child_1 = new Xcls_Button38( _this );
1039 this.el.pack_start ( child_1.el );
1040 var child_2 = new Xcls_Button39( _this );
1042 this.el.pack_end ( child_2.el );
1045 // user defined functions
1047 public class Xcls_Button38 : Object
1049 public Gtk.Button el;
1050 private Xcls_RooProjectSettings _this;
1056 public Xcls_Button38(Xcls_RooProjectSettings _owner )
1059 this.el = new Gtk.Button();
1063 // set gobject values
1064 this.el.label = "Cancel";
1067 this.el.clicked.connect( () => {
1074 // user defined functions
1077 public class Xcls_Button39 : Object
1079 public Gtk.Button el;
1080 private Xcls_RooProjectSettings _this;
1086 public Xcls_Button39(Xcls_RooProjectSettings _owner )
1089 this.el = new Gtk.Button();
1093 // set gobject values
1094 this.el.css_classes = { "suggested-action" };
1095 this.el.label = "Save";
1098 this.el.clicked.connect( ( ) => {
1101 _this.buttonPressed("save");
1107 // hopefull this will work with bjs files..
1114 // user defined functions