1 static Xcls_PopoverFileDetails _PopoverFileDetails;
3 public class Xcls_PopoverFileDetails : Object
6 private Xcls_PopoverFileDetails _this;
8 public static Xcls_PopoverFileDetails singleton()
10 if (_PopoverFileDetails == null) {
11 _PopoverFileDetails= new Xcls_PopoverFileDetails();
13 return _PopoverFileDetails;
15 public Xcls_grid grid;
16 public Xcls_filetypelbl filetypelbl;
17 public Xcls_filetype filetype;
18 public Xcls_ftdbcellrenderer ftdbcellrenderer;
19 public Xcls_ftdbmodel ftdbmodel;
20 public Xcls_name name;
21 public Xcls_title title;
22 public Xcls_region region;
23 public Xcls_parent parent;
24 public Xcls_permname permname;
25 public Xcls_modOrder modOrder;
26 public Xcls_build_module build_module;
27 public Xcls_dbcellrenderer dbcellrenderer;
28 public Xcls_dbmodel dbmodel;
29 public Xcls_save_btn save_btn;
32 public signal void success (Project.Project pr, JsRender.JsRender file);
34 public Project.Project project;
35 public JsRender.JsRender file;
36 public Xcls_MainWindow mainwindow;
39 public Xcls_PopoverFileDetails()
42 this.el = new Gtk.Popover( null );
47 this.mainwindow = null;
50 this.el.border_width = 0;
52 this.el.position = Gtk.PositionType.RIGHT;
53 var child_0 = new Xcls_Box2( _this );
55 this.el.add ( child_0.el );
58 this.el.closed.connect( () => {
66 // user defined functions
67 public void updateFileFromEntry () {
69 _this.file.title = _this.title.el.get_text();
70 _this.file.region = _this.region.el.get_text();
71 _this.file.parent = _this.parent.el.get_text();
72 _this.file.permname = _this.permname.el.get_text();
73 _this.file.modOrder = _this.modOrder.el.get_text();
75 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
76 _this.file.renameTo(_this.name.el.get_text());
78 // store the module...
79 _this.file.build_module = "";
81 if (_this.build_module.el.get_active_iter (out iter)) {
83 this.dbmodel.el.get_value (iter, 0, out vfname);
84 if (((string)vfname).length > 0) {
85 _this.file.build_module = (string)vfname;
94 public void show (JsRender.JsRender c, Gtk.Widget btn)
96 this.project = c.project;
104 _this.name.el.set_text(c.name);
105 _this.title.el.set_text(c.title);
106 _this.parent.el.set_text(c.parent);
107 _this.region.el.set_text(c.region);
108 _this.modOrder.el.set_text(c.modOrder);
109 _this.permname.el.set_text(c.permname);
117 if (c.path.length > 0) {
119 this.save_btn.el.set_label("Save");
121 this.save_btn.el.set_label("Create");
126 var ar = new Gee.ArrayList<string>();
127 _this.dbmodel.loadData(ar,"");
128 // load the modules... if relivant..
129 if (this.project.xtype == "Gtk") {
130 var p = (Project.Gtk)c.project;
131 var cg = p.compilegroups;
133 var iter = cg.map_iterator();
135 var key = iter.get_key();
136 if (key == "_default_") {
141 _this.dbmodel.loadData(ar, c.build_module);
147 //console.log('show all');
148 this.el.set_modal(true);
149 this.el.set_relative_to(btn);
151 this.el.set_position(Gtk.PositionType.RIGHT);
154 print("SHOWALL - POPIP\n");
156 this.name.el.grab_focus();
160 if (c.path.length > 0) {
161 _this.filetype.el.hide();
162 _this.filetypelbl.el.hide();
166 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
167 _this.filetype.el.show();
168 _this.filetypelbl.el.show();
172 //this.success = c.success;
176 public class Xcls_Box2 : Object
179 private Xcls_PopoverFileDetails _this;
185 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
188 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
192 // set gobject values
193 this.el.homogeneous = false;
194 var child_0 = new Xcls_HeaderBar3( _this );
196 this.el.pack_start ( child_0.el , false,true,0 );
197 var child_1 = new Xcls_grid( _this );
199 this.el.pack_start ( child_1.el , false,false,4 );
200 var child_2 = new Xcls_Label25( _this );
202 this.el.attach ( child_2.el , 0,7,1,1 );
203 var child_3 = new Xcls_HButtonBox26( _this );
205 this.el.pack_end ( child_3.el , false,true,0 );
208 // user defined functions
210 public class Xcls_HeaderBar3 : Object
212 public Gtk.HeaderBar el;
213 private Xcls_PopoverFileDetails _this;
219 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
222 this.el = new Gtk.HeaderBar();
226 // set gobject values
227 this.el.title = "Add / Edit File";
230 // user defined functions
233 public class Xcls_grid : Object
236 private Xcls_PopoverFileDetails _this;
242 public Xcls_grid(Xcls_PopoverFileDetails _owner )
246 this.el = new Gtk.Grid();
250 // set gobject values
251 this.el.margin_right = 4;
252 this.el.margin_left = 4;
253 this.el.row_spacing = 2;
254 var child_0 = new Xcls_filetypelbl( _this );
256 this.el.attach ( child_0.el , 0,0,1,1 );
257 var child_1 = new Xcls_filetype( _this );
259 this.el.attach ( child_1.el , 1,0,1,1 );
260 var child_2 = new Xcls_Label9( _this );
262 this.el.attach ( child_2.el , 0,1,1,1 );
263 var child_3 = new Xcls_name( _this );
265 this.el.attach ( child_3.el , 1,1,1,1 );
266 var child_4 = new Xcls_Label11( _this );
268 this.el.attach ( child_4.el , 0,2,1,1 );
269 var child_5 = new Xcls_title( _this );
271 this.el.attach ( child_5.el , 1,2,1,1 );
272 var child_6 = new Xcls_Label13( _this );
274 this.el.attach ( child_6.el , 0,3,1,1 );
275 var child_7 = new Xcls_region( _this );
277 this.el.attach ( child_7.el , 1,3,1,1 );
278 var child_8 = new Xcls_Label15( _this );
280 this.el.attach ( child_8.el , 0,4,1,1 );
281 var child_9 = new Xcls_parent( _this );
283 this.el.attach ( child_9.el , 1,4,1,1 );
284 var child_10 = new Xcls_Label17( _this );
286 this.el.attach ( child_10.el , 0,5,1,1 );
287 var child_11 = new Xcls_permname( _this );
289 this.el.attach ( child_11.el , 1,5,1,1 );
290 var child_12 = new Xcls_Label19( _this );
292 this.el.attach ( child_12.el , 0,6,1,1 );
293 var child_13 = new Xcls_modOrder( _this );
295 this.el.attach ( child_13.el , 1,6,1,1 );
296 var child_14 = new Xcls_Label21( _this );
298 this.el.attach ( child_14.el , 0,7,1,1 );
299 var child_15 = new Xcls_build_module( _this );
301 this.el.attach ( child_15.el , 1,7,1,1 );
304 // user defined functions
306 public class Xcls_filetypelbl : Object
309 private Xcls_PopoverFileDetails _this;
315 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
318 _this.filetypelbl = this;
319 this.el = new Gtk.Label( "File type" );
323 // set gobject values
324 this.el.justify = Gtk.Justification.RIGHT;
325 this.el.xalign = 0.900000f;
328 // user defined functions
331 public class Xcls_filetype : Object
333 public Gtk.ComboBox el;
334 private Xcls_PopoverFileDetails _this;
340 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
343 _this.filetype = this;
344 this.el = new Gtk.ComboBox();
348 // set gobject values
349 var child_0 = new Xcls_ftdbcellrenderer( _this );
351 this.el.pack_start ( child_0.el , true );
352 var child_1 = new Xcls_ftdbmodel( _this );
354 this.el.set_model ( child_1.el );
358 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
361 this.el.changed.connect( () => {
364 if (this.el.get_active_iter(out iter)) {
366 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
367 is_bjs = ((string)vfname) == "bjs";
370 for (var i = 2; i < 8;i++) {
371 var el = _this.grid.el.get_child_at(0,i);
377 el = _this.grid.el.get_child_at(1,i);
391 // user defined functions
393 public class Xcls_ftdbcellrenderer : Object
395 public Gtk.CellRendererText el;
396 private Xcls_PopoverFileDetails _this;
402 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
405 _this.ftdbcellrenderer = this;
406 this.el = new Gtk.CellRendererText();
410 // set gobject values
413 // user defined functions
416 public class Xcls_ftdbmodel : Object
418 public Gtk.ListStore el;
419 private Xcls_PopoverFileDetails _this;
425 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
428 _this.ftdbmodel = this;
429 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
433 // set gobject values
436 // user defined functions
437 public void loadData (string cur) {
442 /// el.append(out iter);
445 // el.set_value(iter, 0, "");
446 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
451 el.set_value(iter, 0, "bjs");
452 el.set_value(iter, 1, "User Interface File (bjs)");
453 _this.filetype.el.set_active_iter(iter);
457 el.set_value(iter, 0, "vala");
458 el.set_value(iter, 1, "Vala");
460 _this.filetype.el.set_active_iter(iter);
467 el.set_value(iter, 0, "js");
468 el.set_value(iter, 1, "Javascript");
471 _this.filetype.el.set_active_iter(iter);
476 el.set_value(iter, 0, "css");
477 el.set_value(iter, 1, "CSS");
480 _this.filetype.el.set_active_iter(iter);
487 public class Xcls_Label9 : Object
490 private Xcls_PopoverFileDetails _this;
496 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
499 this.el = new Gtk.Label( "Component Name" );
503 // set gobject values
504 this.el.justify = Gtk.Justification.RIGHT;
505 this.el.xalign = 0.900000f;
508 // user defined functions
511 public class Xcls_name : Object
514 private Xcls_PopoverFileDetails _this;
520 public Xcls_name(Xcls_PopoverFileDetails _owner )
524 this.el = new Gtk.Entry();
528 // set gobject values
529 this.el.visible = true;
532 // user defined functions
535 public class Xcls_Label11 : Object
538 private Xcls_PopoverFileDetails _this;
544 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
547 this.el = new Gtk.Label( "Title" );
551 // set gobject values
552 this.el.justify = Gtk.Justification.RIGHT;
553 this.el.xalign = 0.900000f;
554 this.el.visible = true;
557 // user defined functions
560 public class Xcls_title : Object
563 private Xcls_PopoverFileDetails _this;
569 public Xcls_title(Xcls_PopoverFileDetails _owner )
573 this.el = new Gtk.Entry();
577 // set gobject values
578 this.el.visible = true;
581 // user defined functions
584 public class Xcls_Label13 : Object
587 private Xcls_PopoverFileDetails _this;
593 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
596 this.el = new Gtk.Label( "Region" );
600 // set gobject values
601 this.el.justify = Gtk.Justification.RIGHT;
602 this.el.xalign = 0.900000f;
603 this.el.tooltip_text = "center, north, south, east, west";
604 this.el.visible = true;
607 // user defined functions
610 public class Xcls_region : Object
613 private Xcls_PopoverFileDetails _this;
619 public Xcls_region(Xcls_PopoverFileDetails _owner )
623 this.el = new Gtk.Entry();
627 // set gobject values
628 this.el.visible = true;
631 // user defined functions
634 public class Xcls_Label15 : Object
637 private Xcls_PopoverFileDetails _this;
643 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
646 this.el = new Gtk.Label( "Parent Name" );
650 // set gobject values
651 this.el.justify = Gtk.Justification.RIGHT;
652 this.el.xalign = 0.900000f;
653 this.el.visible = true;
656 // user defined functions
659 public class Xcls_parent : Object
662 private Xcls_PopoverFileDetails _this;
668 public Xcls_parent(Xcls_PopoverFileDetails _owner )
672 this.el = new Gtk.Entry();
676 // set gobject values
677 this.el.visible = true;
680 // user defined functions
683 public class Xcls_Label17 : Object
686 private Xcls_PopoverFileDetails _this;
692 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
695 this.el = new Gtk.Label( "Permission Name" );
699 // set gobject values
700 this.el.justify = Gtk.Justification.RIGHT;
701 this.el.xalign = 0.900000f;
702 this.el.visible = true;
705 // user defined functions
708 public class Xcls_permname : Object
711 private Xcls_PopoverFileDetails _this;
717 public Xcls_permname(Xcls_PopoverFileDetails _owner )
720 _this.permname = this;
721 this.el = new Gtk.Entry();
725 // set gobject values
726 this.el.visible = true;
729 // user defined functions
732 public class Xcls_Label19 : Object
735 private Xcls_PopoverFileDetails _this;
741 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
744 this.el = new Gtk.Label( "Order (for tabs)" );
748 // set gobject values
749 this.el.justify = Gtk.Justification.RIGHT;
750 this.el.xalign = 0.900000f;
751 this.el.visible = true;
754 // user defined functions
757 public class Xcls_modOrder : Object
760 private Xcls_PopoverFileDetails _this;
766 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
769 _this.modOrder = this;
770 this.el = new Gtk.Entry();
774 // set gobject values
775 this.el.visible = true;
778 // user defined functions
781 public class Xcls_Label21 : Object
784 private Xcls_PopoverFileDetails _this;
790 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
793 this.el = new Gtk.Label( "Module to build (Vala only)" );
797 // set gobject values
798 this.el.justify = Gtk.Justification.RIGHT;
799 this.el.xalign = 0.900000f;
800 this.el.visible = true;
803 // user defined functions
806 public class Xcls_build_module : Object
808 public Gtk.ComboBox el;
809 private Xcls_PopoverFileDetails _this;
815 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
818 _this.build_module = this;
819 this.el = new Gtk.ComboBox();
823 // set gobject values
824 var child_0 = new Xcls_dbcellrenderer( _this );
826 this.el.pack_start ( child_0.el , true );
827 var child_1 = new Xcls_dbmodel( _this );
829 this.el.set_model ( child_1.el );
833 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
836 // user defined functions
838 public class Xcls_dbcellrenderer : Object
840 public Gtk.CellRendererText el;
841 private Xcls_PopoverFileDetails _this;
847 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
850 _this.dbcellrenderer = this;
851 this.el = new Gtk.CellRendererText();
855 // set gobject values
858 // user defined functions
861 public class Xcls_dbmodel : Object
863 public Gtk.ListStore el;
864 private Xcls_PopoverFileDetails _this;
870 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
873 _this.dbmodel = this;
874 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
878 // set gobject values
881 // user defined functions
882 public void loadData (Gee.ArrayList<string> data, string cur) {
887 /// el.append(out iter);
890 // el.set_value(iter, 0, "");
891 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
896 el.set_value(iter, 0, "");
897 el.set_value(iter, 1, "-- select a module --");
898 _this.build_module.el.set_active_iter(iter);
900 for (var i = 0; i < data.size;i++) {
905 el.set_value(iter, 0, data.get(i));
906 el.set_value(iter, 1, data.get(i));
908 if (data.get(i) == cur) {
909 _this.build_module.el.set_active_iter(iter);
913 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
920 public class Xcls_Label25 : Object
923 private Xcls_PopoverFileDetails _this;
929 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
932 this.el = new Gtk.Label( "Module to build (Vala only)" );
936 // set gobject values
937 this.el.justify = Gtk.Justification.RIGHT;
938 this.el.xalign = 0.900000f;
939 this.el.visible = true;
942 // user defined functions
945 public class Xcls_HButtonBox26 : Object
947 public Gtk.HButtonBox el;
948 private Xcls_PopoverFileDetails _this;
954 public Xcls_HButtonBox26(Xcls_PopoverFileDetails _owner )
957 this.el = new Gtk.HButtonBox();
961 // set gobject values
962 this.el.margin_right = 4;
963 this.el.margin_left = 4;
964 this.el.margin_bottom = 4;
965 var child_0 = new Xcls_Button27( _this );
967 this.el.add ( child_0.el );
968 var child_1 = new Xcls_save_btn( _this );
970 this.el.add ( child_1.el );
973 // user defined functions
975 public class Xcls_Button27 : Object
977 public Gtk.Button el;
978 private Xcls_PopoverFileDetails _this;
984 public Xcls_Button27(Xcls_PopoverFileDetails _owner )
987 this.el = new Gtk.Button();
991 // set gobject values
992 this.el.label = "Cancel";
995 this.el.clicked.connect( () => {
1002 // user defined functions
1005 public class Xcls_save_btn : Object
1007 public Gtk.Button el;
1008 private Xcls_PopoverFileDetails _this;
1014 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1017 _this.save_btn = this;
1018 this.el = new Gtk.Button();
1022 // set gobject values
1023 this.el.label = "Save";
1026 this.el.clicked.connect( ( ) => {
1031 if (_this.name.el.get_text().length < 1) {
1032 StandardErrorDialog.show(
1033 _this.mainwindow.el,
1034 "You have to set Component name "
1039 // what does this do?
1041 var isNew = _this.file.name.length > 0 ? false : true;
1043 if (!isNew && this.file.name != _this.name.el.get_text()) {
1044 Xcls_StandardErrorDialog.singleton().show(
1046 "Sorry changing names does not work yet. "
1055 // FIXME - this may be more complicated...
1056 //for (var i in this.def) {
1057 // this.file[i] = this.get(i).el.get_text();
1062 _this.updateFileFromEntry();
1063 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1064 Xcls_StandardErrorDialog.singleton().show(
1065 _this.mainwindow.el,
1066 "The name you used already exists "
1078 // ---------------- NEW FILES...
1080 var fn = _this.name.el.get_text();
1081 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1083 var targetfile = dir + "/" + fn;
1085 // strip the file type off the end..
1088 if (!_this.filetype.el.get_active_iter(out iter)) {
1089 // should not happen...
1090 // so we are jut going to return without
1091 StandardErrorDialog.show(
1092 _this.mainwindow.el,
1093 "You must select a file type. "
1097 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1098 var ext = ((string)ftypename);
1100 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1101 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1103 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1104 Xcls_StandardErrorDialog.singleton().show(
1105 _this.mainwindow.el,
1106 "That file already exists"
1111 var f = JsRender.JsRender.factory(
1112 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1114 targetfile + "." + ext);
1120 _this.updateFileFromEntry();
1121 _this.file.loaded = true;
1124 _this.file.project.addFile(_this.file);
1132 // hopefull this will work with bjs files..
1134 _this.success(_this.project, _this.file);
1139 // user defined functions