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