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