src/Builder4/RooProjectSettings.bjs
[roobuilder] / src / Builder4 / RooProjectSettings.vala
1 static RooProjectSettings  _RooProjectSettings;
2
3 public class RooProjectSettings : Object
4 {
5     public Gtk.Popover el;
6     private RooProjectSettings  _this;
7
8     public static RooProjectSettings singleton()
9     {
10         if (_RooProjectSettings == null) {
11             _RooProjectSettings= new RooProjectSettings();
12         }
13         return _RooProjectSettings;
14     }
15     public Xcls_ProjectSettings ProjectSettings;
16     public Xcls_label_global label_global;
17     public Xcls_label_database label_database;
18     public Xcls_path path;
19     public Xcls_base_template base_template;
20     public Xcls_rootURL rootURL;
21     public Xcls_view view;
22     public Xcls_database_DBTYPE database_DBTYPE;
23     public Xcls_database_DBNAME database_DBNAME;
24     public Xcls_database_DBUSERNAME database_DBUSERNAME;
25     public Xcls_database_DBPASSWORD database_DBPASSWORD;
26     public Xcls_database_ERROR database_ERROR;
27
28         // my vars (def)
29
30     // ctor
31     public RooProjectSettings()
32     {
33         _this = this;
34         this.el = new Gtk.Popover( null );
35
36         // my vars (dec)
37
38         // set gobject values
39         var child_0 = new Xcls_ProjectSettings( _this );
40         child_0.ref();
41     }
42
43     // user defined functions
44     public class Xcls_ProjectSettings : Object
45     {
46         public Gtk.Box el;
47         private RooProjectSettings  _this;
48
49
50             // my vars (def)
51         public signal void buttonPressed (string btn);
52         public Project.Project project;
53
54         // ctor
55         public Xcls_ProjectSettings(RooProjectSettings _owner )
56         {
57             _this = _owner;
58             _this.ProjectSettings = this;
59             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
60
61             // my vars (dec)
62
63             // set gobject values
64             this.el.homogeneous = false;
65             this.el.border_width = 5;
66             var child_0 = new Xcls_Box3( _this );
67             child_0.ref();
68             this.el.pack_start (  child_0.el , false,false,0 );
69             var child_1 = new Xcls_Notebook6( _this );
70             child_1.ref();
71             this.el.pack_end (  child_1.el , true,true,0 );
72         }
73
74         // user defined functions
75         public void show (Project.Project project) {
76             _this.project = project;
77             _this.path.el.label = project.firstPath();
78             // get the active project.
79              var lm = Gtk.SourceLanguageManager.get_default();
80                         
81             ((Gtk.SourceBuffer)(_this.view.el.get_buffer())) .set_language(
82             
83                 lm.get_language("html"));
84           
85             //print (project.fn);
86             //project.runhtml = project.runhtml || '';
87             _this.view.el.get_buffer().set_text(project.runhtml);
88             
89                
90             _this.rootURL.el.set_text( _this.project.rootURL );
91             _this.base_template.el.set_text(_this.project.base_template);    
92              var js = _this.project;
93             _this.database_DBTYPE.el.set_text(     js.get_string_member("DBTYPE") );
94             _this.database_DBNAME.el.set_text(    js.get_string_member("DBNAME") );
95             _this.database_DBUSERNAME.el.set_text(    js.get_string_member("DBUSERNAME") );
96             _this.database_DBPASSWORD.el.set_text(    js.get_string_member("DBPASSWORD") );
97             //this.el.show_all();
98         }
99         public void save ()
100         {
101            var buf =    _this.view.el.get_buffer();
102            Gtk.TextIter s;
103              Gtk.TextIter e;
104             buf.get_start_iter(out s);
105             buf.get_end_iter(out e);
106               _this.project.runhtml = buf.get_text(s,e,true);
107               
108             _this.project.rootURL = _this.rootURL.el.get_text();
109             _this.project.base_template = _this.base_template.el.get_text();    
110             
111             var js = _this.project.json_project_data;
112             js.set_string_member("DBTYPE", _this.database_DBTYPE.el.get_text());
113            js.set_string_member("DBNAME", _this.database_DBNAME.el.get_text());
114             js.set_string_member("DBUSERNAME", _this.database_DBUSERNAME.el.get_text());
115             js.set_string_member("DBPASSWORD", _this.database_DBPASSWORD.el.get_text());
116         //    _this.project.set_string_member("DBHOST", _this.DBTYPE.el.get_text());    
117             
118             // need to re-init the database 
119             
120             _this.project.initRooDatabase();
121              
122             
123         }
124     }
125     public class Xcls_Box3 : Object
126     {
127         public Gtk.Box el;
128         private RooProjectSettings  _this;
129
130
131             // my vars (def)
132
133         // ctor
134         public Xcls_Box3(RooProjectSettings _owner )
135         {
136             _this = _owner;
137             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
138
139             // my vars (dec)
140
141             // set gobject values
142             this.el.homogeneous = true;
143             this.el.expand = false;
144             this.el.vexpand = false;
145             var child_0 = new Xcls_Button4( _this );
146             child_0.ref();
147             this.el.add (  child_0.el  );
148             var child_1 = new Xcls_Button5( _this );
149             child_1.ref();
150             this.el.add (  child_1.el  );
151         }
152
153         // user defined functions
154     }
155     public class Xcls_Button4 : Object
156     {
157         public Gtk.Button el;
158         private RooProjectSettings  _this;
159
160
161             // my vars (def)
162
163         // ctor
164         public Xcls_Button4(RooProjectSettings _owner )
165         {
166             _this = _owner;
167             this.el = new Gtk.Button();
168
169             // my vars (dec)
170
171             // set gobject values
172             this.el.label = "Apply";
173
174             //listeners
175             this.el.button_press_event.connect( () => {
176                 _this.save();
177                       
178                 _this.buttonPressed("apply");
179                     return false;
180             });
181         }
182
183         // user defined functions
184     }
185
186     public class Xcls_Button5 : Object
187     {
188         public Gtk.Button el;
189         private RooProjectSettings  _this;
190
191
192             // my vars (def)
193
194         // ctor
195         public Xcls_Button5(RooProjectSettings _owner )
196         {
197             _this = _owner;
198             this.el = new Gtk.Button();
199
200             // my vars (dec)
201
202             // set gobject values
203             this.el.label = "Save";
204
205             //listeners
206             this.el.button_press_event.connect( () => {
207                    _this.save();
208                       
209                 _this.buttonPressed("save");
210                     return false;
211             });
212         }
213
214         // user defined functions
215     }
216
217
218     public class Xcls_Notebook6 : Object
219     {
220         public Gtk.Notebook el;
221         private RooProjectSettings  _this;
222
223
224             // my vars (def)
225
226         // ctor
227         public Xcls_Notebook6(RooProjectSettings _owner )
228         {
229             _this = _owner;
230             this.el = new Gtk.Notebook();
231
232             // my vars (dec)
233
234             // set gobject values
235             var child_0 = new Xcls_label_global( _this );
236             child_0.ref();
237             var child_1 = new Xcls_label_database( _this );
238             child_1.ref();
239             var child_2 = new Xcls_Box9( _this );
240             child_2.ref();
241             this.el.append_page (  child_2.el , _this.label_global.el );
242             var child_3 = new Xcls_Box20( _this );
243             child_3.ref();
244             this.el.append_page (  child_3.el , _this.label_database.el );
245         }
246
247         // user defined functions
248     }
249     public class Xcls_label_global : Object
250     {
251         public Gtk.Label el;
252         private RooProjectSettings  _this;
253
254
255             // my vars (def)
256
257         // ctor
258         public Xcls_label_global(RooProjectSettings _owner )
259         {
260             _this = _owner;
261             _this.label_global = this;
262             this.el = new Gtk.Label( "Global" );
263
264             // my vars (dec)
265
266             // set gobject values
267         }
268
269         // user defined functions
270     }
271
272     public class Xcls_label_database : Object
273     {
274         public Gtk.Label el;
275         private RooProjectSettings  _this;
276
277
278             // my vars (def)
279
280         // ctor
281         public Xcls_label_database(RooProjectSettings _owner )
282         {
283             _this = _owner;
284             _this.label_database = this;
285             this.el = new Gtk.Label( "Database" );
286
287             // my vars (dec)
288
289             // set gobject values
290         }
291
292         // user defined functions
293     }
294
295     public class Xcls_Box9 : Object
296     {
297         public Gtk.Box el;
298         private RooProjectSettings  _this;
299
300
301             // my vars (def)
302
303         // ctor
304         public Xcls_Box9(RooProjectSettings _owner )
305         {
306             _this = _owner;
307             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
308
309             // my vars (dec)
310
311             // set gobject values
312             this.el.homogeneous = false;
313             var child_0 = new Xcls_path( _this );
314             child_0.ref();
315             this.el.pack_start (  child_0.el , false,false,0 );
316             var child_1 = new Xcls_Box11( _this );
317             child_1.ref();
318             this.el.pack_start (  child_1.el , false,false,0 );
319             var child_2 = new Xcls_Box14( _this );
320             child_2.ref();
321             this.el.pack_start (  child_2.el , false,false,0 );
322             var child_3 = new Xcls_Label17( _this );
323             child_3.ref();
324             this.el.pack_start (  child_3.el , false,false,0 );
325             var child_4 = new Xcls_ScrolledWindow18( _this );
326             child_4.ref();
327             this.el.pack_start (  child_4.el , true,true,0 );
328         }
329
330         // user defined functions
331     }
332     public class Xcls_path : Object
333     {
334         public Gtk.Label el;
335         private RooProjectSettings  _this;
336
337
338             // my vars (def)
339
340         // ctor
341         public Xcls_path(RooProjectSettings _owner )
342         {
343             _this = _owner;
344             _this.path = this;
345             this.el = new Gtk.Label( "filename" );
346
347             // my vars (dec)
348
349             // set gobject values
350             this.el.margin = 3;
351             this.el.xalign = 0f;
352         }
353
354         // user defined functions
355     }
356
357     public class Xcls_Box11 : Object
358     {
359         public Gtk.Box el;
360         private RooProjectSettings  _this;
361
362
363             // my vars (def)
364
365         // ctor
366         public Xcls_Box11(RooProjectSettings _owner )
367         {
368             _this = _owner;
369             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
370
371             // my vars (dec)
372
373             // set gobject values
374             this.el.homogeneous = false;
375             this.el.expand = false;
376             var child_0 = new Xcls_Label12( _this );
377             child_0.ref();
378             this.el.pack_start (  child_0.el , false,false,0 );
379             var child_1 = new Xcls_base_template( _this );
380             child_1.ref();
381             this.el.add (  child_1.el  );
382         }
383
384         // user defined functions
385     }
386     public class Xcls_Label12 : Object
387     {
388         public Gtk.Label el;
389         private RooProjectSettings  _this;
390
391
392             // my vars (def)
393
394         // ctor
395         public Xcls_Label12(RooProjectSettings _owner )
396         {
397             _this = _owner;
398             this.el = new Gtk.Label( "HTML template file" );
399
400             // my vars (dec)
401
402             // set gobject values
403             this.el.margin = 3;
404         }
405
406         // user defined functions
407     }
408
409     public class Xcls_base_template : Object
410     {
411         public Gtk.Entry el;
412         private RooProjectSettings  _this;
413
414
415             // my vars (def)
416
417         // ctor
418         public Xcls_base_template(RooProjectSettings _owner )
419         {
420             _this = _owner;
421             _this.base_template = this;
422             this.el = new Gtk.Entry();
423
424             // my vars (dec)
425
426             // set gobject values
427         }
428
429         // user defined functions
430     }
431
432
433     public class Xcls_Box14 : Object
434     {
435         public Gtk.Box el;
436         private RooProjectSettings  _this;
437
438
439             // my vars (def)
440
441         // ctor
442         public Xcls_Box14(RooProjectSettings _owner )
443         {
444             _this = _owner;
445             this.el = new Gtk.Box( Gtk.Orientation.HORIZONTAL, 0 );
446
447             // my vars (dec)
448
449             // set gobject values
450             this.el.homogeneous = false;
451             this.el.expand = false;
452             var child_0 = new Xcls_Label15( _this );
453             child_0.ref();
454             this.el.pack_start (  child_0.el , false,false,0 );
455             var child_1 = new Xcls_rootURL( _this );
456             child_1.ref();
457             this.el.add (  child_1.el  );
458         }
459
460         // user defined functions
461     }
462     public class Xcls_Label15 : Object
463     {
464         public Gtk.Label el;
465         private RooProjectSettings  _this;
466
467
468             // my vars (def)
469
470         // ctor
471         public Xcls_Label15(RooProjectSettings _owner )
472         {
473             _this = _owner;
474             this.el = new Gtk.Label( "root URL" );
475
476             // my vars (dec)
477
478             // set gobject values
479             this.el.margin = 3;
480         }
481
482         // user defined functions
483     }
484
485     public class Xcls_rootURL : Object
486     {
487         public Gtk.Entry el;
488         private RooProjectSettings  _this;
489
490
491             // my vars (def)
492
493         // ctor
494         public Xcls_rootURL(RooProjectSettings _owner )
495         {
496             _this = _owner;
497             _this.rootURL = this;
498             this.el = new Gtk.Entry();
499
500             // my vars (dec)
501
502             // set gobject values
503         }
504
505         // user defined functions
506     }
507
508
509     public class Xcls_Label17 : Object
510     {
511         public Gtk.Label el;
512         private RooProjectSettings  _this;
513
514
515             // my vars (def)
516
517         // ctor
518         public Xcls_Label17(RooProjectSettings _owner )
519         {
520             _this = _owner;
521             this.el = new Gtk.Label( "HTML To insert at end of <HEAD>" );
522
523             // my vars (dec)
524
525             // set gobject values
526         }
527
528         // user defined functions
529     }
530
531     public class Xcls_ScrolledWindow18 : Object
532     {
533         public Gtk.ScrolledWindow el;
534         private RooProjectSettings  _this;
535
536
537             // my vars (def)
538
539         // ctor
540         public Xcls_ScrolledWindow18(RooProjectSettings _owner )
541         {
542             _this = _owner;
543             this.el = new Gtk.ScrolledWindow( null, null );
544
545             // my vars (dec)
546
547             // set gobject values
548             var child_0 = new Xcls_view( _this );
549             child_0.ref();
550             this.el.add (  child_0.el  );
551         }
552
553         // user defined functions
554     }
555     public class Xcls_view : Object
556     {
557         public Gtk.SourceView el;
558         private RooProjectSettings  _this;
559
560
561             // my vars (def)
562
563         // ctor
564         public Xcls_view(RooProjectSettings _owner )
565         {
566             _this = _owner;
567             _this.view = this;
568             this.el = new Gtk.SourceView();
569
570             // my vars (dec)
571
572             // init method
573
574             var description =   Pango.FontDescription.from_string("monospace");
575                 description.set_size(9000);
576                 this.el.override_font(description);
577
578             //listeners
579             this.el.key_release_event.connect( ( event) =>{
580                 if (event.keyval != 115) {
581                     return false;
582                      
583                 }
584                 if   ( (event.state & Gdk.ModifierType.CONTROL_MASK ) < 1 ) {
585                     return false;
586                 }
587                  var buf =    this.el.get_buffer();
588                 Gtk.TextIter s;
589                 Gtk.TextIter e;
590                 buf.get_start_iter(out s);
591                 buf.get_end_iter(out e);
592                 _this.project.runhtml = buf.get_text(s,e,true);
593                 
594                       
595                 _this.buttonPressed("save");
596                  
597                 return false;
598                      
599             });
600         }
601
602         // user defined functions
603     }
604
605
606
607     public class Xcls_Box20 : Object
608     {
609         public Gtk.Box el;
610         private RooProjectSettings  _this;
611
612
613             // my vars (def)
614
615         // ctor
616         public Xcls_Box20(RooProjectSettings _owner )
617         {
618             _this = _owner;
619             this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
620
621             // my vars (dec)
622
623             // set gobject values
624             this.el.homogeneous = false;
625             var child_0 = new Xcls_Label21( _this );
626             child_0.ref();
627             this.el.pack_start (  child_0.el , false,false,0 );
628             var child_1 = new Xcls_database_DBTYPE( _this );
629             child_1.ref();
630             this.el.pack_start (  child_1.el , false,false,0 );
631             var child_2 = new Xcls_Label23( _this );
632             child_2.ref();
633             this.el.pack_start (  child_2.el , false,false,0 );
634             var child_3 = new Xcls_database_DBNAME( _this );
635             child_3.ref();
636             this.el.pack_start (  child_3.el , false,false,0 );
637             var child_4 = new Xcls_Label25( _this );
638             child_4.ref();
639             this.el.pack_start (  child_4.el , false,false,0 );
640             var child_5 = new Xcls_database_DBUSERNAME( _this );
641             child_5.ref();
642             this.el.pack_start (  child_5.el , false,false,0 );
643             var child_6 = new Xcls_Label27( _this );
644             child_6.ref();
645             this.el.pack_start (  child_6.el , false,false,0 );
646             var child_7 = new Xcls_database_DBPASSWORD( _this );
647             child_7.ref();
648             this.el.pack_start (  child_7.el , false,false,0 );
649             var child_8 = new Xcls_Button29( _this );
650             child_8.ref();
651             this.el.pack_start (  child_8.el , false,false,0 );
652             var child_9 = new Xcls_database_ERROR( _this );
653             child_9.ref();
654             this.el.pack_start (  child_9.el , false,false,0 );
655         }
656
657         // user defined functions
658     }
659     public class Xcls_Label21 : Object
660     {
661         public Gtk.Label el;
662         private RooProjectSettings  _this;
663
664
665             // my vars (def)
666
667         // ctor
668         public Xcls_Label21(RooProjectSettings _owner )
669         {
670             _this = _owner;
671             this.el = new Gtk.Label( "Type (eg. MySQL or PostgreSQL)" );
672
673             // my vars (dec)
674
675             // set gobject values
676             this.el.xalign = 0f;
677         }
678
679         // user defined functions
680     }
681
682     public class Xcls_database_DBTYPE : Object
683     {
684         public Gtk.Entry el;
685         private RooProjectSettings  _this;
686
687
688             // my vars (def)
689
690         // ctor
691         public Xcls_database_DBTYPE(RooProjectSettings _owner )
692         {
693             _this = _owner;
694             _this.database_DBTYPE = this;
695             this.el = new Gtk.Entry();
696
697             // my vars (dec)
698
699             // set gobject values
700
701             //listeners
702             this.el.key_press_event.connect( (ev) => {
703             
704                 if (ev.keyval == Gdk.Key.Tab) {
705                     _this.database_DBNAME.el.grab_focus();
706                     return true;
707                 }
708             
709             
710                 return false;
711             });
712         }
713
714         // user defined functions
715     }
716
717     public class Xcls_Label23 : Object
718     {
719         public Gtk.Label el;
720         private RooProjectSettings  _this;
721
722
723             // my vars (def)
724
725         // ctor
726         public Xcls_Label23(RooProjectSettings _owner )
727         {
728             _this = _owner;
729             this.el = new Gtk.Label( "Name" );
730
731             // my vars (dec)
732
733             // set gobject values
734             this.el.xalign = 0f;
735         }
736
737         // user defined functions
738     }
739
740     public class Xcls_database_DBNAME : Object
741     {
742         public Gtk.Entry el;
743         private RooProjectSettings  _this;
744
745
746             // my vars (def)
747
748         // ctor
749         public Xcls_database_DBNAME(RooProjectSettings _owner )
750         {
751             _this = _owner;
752             _this.database_DBNAME = this;
753             this.el = new Gtk.Entry();
754
755             // my vars (dec)
756
757             // set gobject values
758
759             //listeners
760             this.el.key_press_event.connect( (ev) => {
761             
762                 if (ev.keyval == Gdk.Key.Tab) {
763                     _this.database_DBUSERNAME.el.grab_focus();
764                     return true;
765                 }
766             
767             
768                 return false;
769             });
770         }
771
772         // user defined functions
773     }
774
775     public class Xcls_Label25 : Object
776     {
777         public Gtk.Label el;
778         private RooProjectSettings  _this;
779
780
781             // my vars (def)
782
783         // ctor
784         public Xcls_Label25(RooProjectSettings _owner )
785         {
786             _this = _owner;
787             this.el = new Gtk.Label( "Username" );
788
789             // my vars (dec)
790
791             // set gobject values
792             this.el.xalign = 0f;
793         }
794
795         // user defined functions
796     }
797
798     public class Xcls_database_DBUSERNAME : Object
799     {
800         public Gtk.Entry el;
801         private RooProjectSettings  _this;
802
803
804             // my vars (def)
805
806         // ctor
807         public Xcls_database_DBUSERNAME(RooProjectSettings _owner )
808         {
809             _this = _owner;
810             _this.database_DBUSERNAME = this;
811             this.el = new Gtk.Entry();
812
813             // my vars (dec)
814
815             // set gobject values
816
817             //listeners
818             this.el.key_press_event.connect( (ev) => {
819             
820                 if (ev.keyval == Gdk.Key.Tab) {
821                     _this.database_DBPASSWORD.el.grab_focus();
822                     return true;
823                 }
824             
825             
826                 return false;
827             });
828         }
829
830         // user defined functions
831     }
832
833     public class Xcls_Label27 : Object
834     {
835         public Gtk.Label el;
836         private RooProjectSettings  _this;
837
838
839             // my vars (def)
840
841         // ctor
842         public Xcls_Label27(RooProjectSettings _owner )
843         {
844             _this = _owner;
845             this.el = new Gtk.Label( "Password" );
846
847             // my vars (dec)
848
849             // set gobject values
850             this.el.xalign = 0f;
851         }
852
853         // user defined functions
854     }
855
856     public class Xcls_database_DBPASSWORD : Object
857     {
858         public Gtk.Entry el;
859         private RooProjectSettings  _this;
860
861
862             // my vars (def)
863
864         // ctor
865         public Xcls_database_DBPASSWORD(RooProjectSettings _owner )
866         {
867             _this = _owner;
868             _this.database_DBPASSWORD = this;
869             this.el = new Gtk.Entry();
870
871             // my vars (dec)
872
873             // set gobject values
874         }
875
876         // user defined functions
877     }
878
879     public class Xcls_Button29 : Object
880     {
881         public Gtk.Button el;
882         private RooProjectSettings  _this;
883
884
885             // my vars (def)
886
887         // ctor
888         public Xcls_Button29(RooProjectSettings _owner )
889         {
890             _this = _owner;
891             this.el = new Gtk.Button();
892
893             // my vars (dec)
894
895             // set gobject values
896             this.el.label = "Check Connection";
897
898             //listeners
899             this.el.clicked.connect( () => {
900             
901             
902               _this.database_ERROR.el.label    = "";
903                 Gda.Connection cnc;
904                 try {
905                     // assumes localhost...
906                      cnc = Gda.Connection.open_from_string (
907                                 _this.database_DBTYPE.el.get_text(),
908                                 "DB_NAME=" + _this.database_DBNAME.el.get_text(), 
909                                 "USERNAME=" + _this.database_DBUSERNAME.el.get_text() + 
910                                 ";PASSWORD=" + _this.database_DBPASSWORD.el.get_text(),
911                                 Gda.ConnectionOptions.NONE
912                         );
913                //} catch (Gda.ConnectionError ce) { 
914                //   _this.database_ERROR.el.label = ce.message;        
915                } catch(Gda.ConnectionError ue) {
916                   _this.database_ERROR.el.label = ue.message;
917                     return;
918                }  catch(Gda.ConfigError ue) {
919                   _this.database_ERROR.el.label = ue.message;
920                     return;
921                }
922               _this.database_ERROR.el.label = "Connection Succeeded";
923                cnc.close();
924             });
925         }
926
927         // user defined functions
928     }
929
930     public class Xcls_database_ERROR : Object
931     {
932         public Gtk.Label el;
933         private RooProjectSettings  _this;
934
935
936             // my vars (def)
937
938         // ctor
939         public Xcls_database_ERROR(RooProjectSettings _owner )
940         {
941             _this = _owner;
942             _this.database_ERROR = this;
943             this.el = new Gtk.Label( " " );
944
945             // my vars (dec)
946
947             // set gobject values
948             this.el.margin = 3;
949             this.el.xalign = 0f;
950         }
951
952         // user defined functions
953     }
954
955
956
957
958 }