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;
30 public Xcls_dircellrenderer dircellrenderer;
31 public Xcls_dirmodel dirmodel;
32 public Xcls_save_btn save_btn;
35 public signal void success (Project.Project pr, JsRender.JsRender file);
37 public Project.Project project;
38 public JsRender.JsRender file;
39 public Xcls_MainWindow mainwindow;
42 public Xcls_PopoverFileDetails()
45 this.el = new Gtk.Popover( null );
50 this.mainwindow = null;
53 this.el.border_width = 0;
55 this.el.position = Gtk.PositionType.RIGHT;
56 var child_0 = new Xcls_Box2( _this );
58 this.el.add ( child_0.el );
61 this.el.closed.connect( () => {
69 // user defined functions
70 public void updateFileFromEntry () {
72 _this.file.title = _this.title.el.get_text();
73 _this.file.region = _this.region.el.get_text();
74 _this.file.parent = _this.parent.el.get_text();
75 _this.file.permname = _this.permname.el.get_text();
76 _this.file.modOrder = _this.modOrder.el.get_text();
78 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
79 _this.file.renameTo(_this.name.el.get_text());
81 // store the module...
82 _this.file.build_module = "";
84 if (_this.build_module.el.get_active_iter (out iter)) {
86 this.dbmodel.el.get_value (iter, 0, out vfname);
87 if (((string)vfname).length > 0) {
88 _this.file.build_module = (string)vfname;
97 public void show (JsRender.JsRender c, Gtk.Widget btn)
99 this.project = c.project;
107 _this.name.el.set_text(c.name);
108 _this.title.el.set_text(c.title);
109 _this.parent.el.set_text(c.parent);
110 _this.region.el.set_text(c.region);
111 _this.modOrder.el.set_text(c.modOrder);
112 _this.permname.el.set_text(c.permname);
120 if (c.path.length > 0) {
122 this.save_btn.el.set_label("Save");
124 this.save_btn.el.set_label("Create");
129 var ar = new Gee.ArrayList<string>();
130 _this.dbmodel.loadData(ar,"");
131 // load the modules... if relivant..
132 if (this.project.xtype == "Gtk") {
133 var p = (Project.Gtk)c.project;
134 var cg = p.compilegroups;
136 var iter = cg.map_iterator();
138 var key = iter.get_key();
139 if (key == "_default_") {
144 _this.dbmodel.loadData(ar, c.build_module);
150 //console.log('show all');
151 this.el.set_modal(true);
152 this.el.set_relative_to(btn);
154 this.el.set_position(Gtk.PositionType.RIGHT);
157 print("SHOWALL - POPIP\n");
159 this.name.el.grab_focus();
163 if (c.path.length > 0) {
164 _this.filetype.el.hide();
165 _this.filetypelbl.el.hide();
169 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
170 _this.filetype.el.show();
171 _this.filetypelbl.el.show();
175 //this.success = c.success;
179 public class Xcls_Box2 : Object
182 private Xcls_PopoverFileDetails _this;
188 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
191 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
195 // set gobject values
196 this.el.homogeneous = false;
197 var child_0 = new Xcls_HeaderBar3( _this );
199 this.el.pack_start ( child_0.el , false,true,0 );
200 var child_1 = new Xcls_grid( _this );
202 this.el.pack_start ( child_1.el , false,false,4 );
203 var child_2 = new Xcls_HButtonBox29( _this );
205 this.el.pack_end ( child_2.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 );
302 var child_16 = new Xcls_Label25( _this );
304 this.el.attach ( child_16.el , 0,8 );
305 var child_17 = new Xcls_dir( _this );
307 this.el.attach ( child_17.el , 1,8 );
310 // user defined functions
312 public class Xcls_filetypelbl : Object
315 private Xcls_PopoverFileDetails _this;
321 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
324 _this.filetypelbl = this;
325 this.el = new Gtk.Label( "File type" );
329 // set gobject values
330 this.el.justify = Gtk.Justification.RIGHT;
331 this.el.xalign = 0.900000f;
334 // user defined functions
337 public class Xcls_filetype : Object
339 public Gtk.ComboBox el;
340 private Xcls_PopoverFileDetails _this;
346 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
349 _this.filetype = this;
350 this.el = new Gtk.ComboBox();
354 // set gobject values
355 var child_0 = new Xcls_ftdbcellrenderer( _this );
357 this.el.pack_start ( child_0.el , true );
358 var child_1 = new Xcls_ftdbmodel( _this );
360 this.el.set_model ( child_1.el );
364 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
367 this.el.changed.connect( () => {
370 if (this.el.get_active_iter(out iter)) {
372 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
373 is_bjs = ((string)vfname) == "bjs";
376 for (var i = 2; i < 9;i++) {
377 var el = _this.grid.el.get_child_at(0,i);
379 var showhide= is_bjs;
381 showhide = !showhide;
389 el = _this.grid.el.get_child_at(1,i);
396 // directory is only available for non-bjs
403 // user defined functions
405 public class Xcls_ftdbcellrenderer : Object
407 public Gtk.CellRendererText el;
408 private Xcls_PopoverFileDetails _this;
414 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
417 _this.ftdbcellrenderer = this;
418 this.el = new Gtk.CellRendererText();
422 // set gobject values
425 // user defined functions
428 public class Xcls_ftdbmodel : Object
430 public Gtk.ListStore el;
431 private Xcls_PopoverFileDetails _this;
437 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
440 _this.ftdbmodel = this;
441 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
445 // set gobject values
448 // user defined functions
449 public void loadData (string cur) {
454 /// el.append(out iter);
457 // el.set_value(iter, 0, "");
458 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
463 el.set_value(iter, 0, "bjs");
464 el.set_value(iter, 1, "User Interface File (bjs)");
465 _this.filetype.el.set_active_iter(iter);
469 el.set_value(iter, 0, "vala");
470 el.set_value(iter, 1, "Vala");
472 _this.filetype.el.set_active_iter(iter);
479 el.set_value(iter, 0, "js");
480 el.set_value(iter, 1, "Javascript");
483 _this.filetype.el.set_active_iter(iter);
488 el.set_value(iter, 0, "css");
489 el.set_value(iter, 1, "CSS");
492 _this.filetype.el.set_active_iter(iter);
499 public class Xcls_Label9 : Object
502 private Xcls_PopoverFileDetails _this;
508 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
511 this.el = new Gtk.Label( "Component Name" );
515 // set gobject values
516 this.el.justify = Gtk.Justification.RIGHT;
517 this.el.xalign = 0.900000f;
520 // user defined functions
523 public class Xcls_name : Object
526 private Xcls_PopoverFileDetails _this;
532 public Xcls_name(Xcls_PopoverFileDetails _owner )
536 this.el = new Gtk.Entry();
540 // set gobject values
541 this.el.visible = true;
544 // user defined functions
547 public class Xcls_Label11 : Object
550 private Xcls_PopoverFileDetails _this;
556 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
559 this.el = new Gtk.Label( "Title" );
563 // set gobject values
564 this.el.justify = Gtk.Justification.RIGHT;
565 this.el.xalign = 0.900000f;
566 this.el.visible = true;
569 // user defined functions
572 public class Xcls_title : Object
575 private Xcls_PopoverFileDetails _this;
581 public Xcls_title(Xcls_PopoverFileDetails _owner )
585 this.el = new Gtk.Entry();
589 // set gobject values
590 this.el.visible = true;
593 // user defined functions
596 public class Xcls_Label13 : Object
599 private Xcls_PopoverFileDetails _this;
605 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
608 this.el = new Gtk.Label( "Region" );
612 // set gobject values
613 this.el.justify = Gtk.Justification.RIGHT;
614 this.el.xalign = 0.900000f;
615 this.el.tooltip_text = "center, north, south, east, west";
616 this.el.visible = true;
619 // user defined functions
622 public class Xcls_region : Object
625 private Xcls_PopoverFileDetails _this;
631 public Xcls_region(Xcls_PopoverFileDetails _owner )
635 this.el = new Gtk.Entry();
639 // set gobject values
640 this.el.visible = true;
643 // user defined functions
646 public class Xcls_Label15 : Object
649 private Xcls_PopoverFileDetails _this;
655 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
658 this.el = new Gtk.Label( "Parent Name" );
662 // set gobject values
663 this.el.justify = Gtk.Justification.RIGHT;
664 this.el.xalign = 0.900000f;
665 this.el.visible = true;
668 // user defined functions
671 public class Xcls_parent : Object
674 private Xcls_PopoverFileDetails _this;
680 public Xcls_parent(Xcls_PopoverFileDetails _owner )
684 this.el = new Gtk.Entry();
688 // set gobject values
689 this.el.visible = true;
692 // user defined functions
695 public class Xcls_Label17 : Object
698 private Xcls_PopoverFileDetails _this;
704 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
707 this.el = new Gtk.Label( "Permission Name" );
711 // set gobject values
712 this.el.justify = Gtk.Justification.RIGHT;
713 this.el.xalign = 0.900000f;
714 this.el.visible = true;
717 // user defined functions
720 public class Xcls_permname : Object
723 private Xcls_PopoverFileDetails _this;
729 public Xcls_permname(Xcls_PopoverFileDetails _owner )
732 _this.permname = this;
733 this.el = new Gtk.Entry();
737 // set gobject values
738 this.el.visible = true;
741 // user defined functions
744 public class Xcls_Label19 : Object
747 private Xcls_PopoverFileDetails _this;
753 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
756 this.el = new Gtk.Label( "Order (for tabs)" );
760 // set gobject values
761 this.el.justify = Gtk.Justification.RIGHT;
762 this.el.xalign = 0.900000f;
763 this.el.visible = true;
766 // user defined functions
769 public class Xcls_modOrder : Object
772 private Xcls_PopoverFileDetails _this;
778 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
781 _this.modOrder = this;
782 this.el = new Gtk.Entry();
786 // set gobject values
787 this.el.visible = true;
790 // user defined functions
793 public class Xcls_Label21 : Object
796 private Xcls_PopoverFileDetails _this;
802 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
805 this.el = new Gtk.Label( "Module to build (Vala only)" );
809 // set gobject values
810 this.el.justify = Gtk.Justification.RIGHT;
811 this.el.xalign = 0.900000f;
812 this.el.visible = true;
815 // user defined functions
818 public class Xcls_build_module : Object
820 public Gtk.ComboBox el;
821 private Xcls_PopoverFileDetails _this;
827 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
830 _this.build_module = this;
831 this.el = new Gtk.ComboBox();
835 // set gobject values
836 var child_0 = new Xcls_dbcellrenderer( _this );
838 this.el.pack_start ( child_0.el , true );
839 var child_1 = new Xcls_dbmodel( _this );
841 this.el.set_model ( child_1.el );
845 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
848 // user defined functions
850 public class Xcls_dbcellrenderer : Object
852 public Gtk.CellRendererText el;
853 private Xcls_PopoverFileDetails _this;
859 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
862 _this.dbcellrenderer = this;
863 this.el = new Gtk.CellRendererText();
867 // set gobject values
870 // user defined functions
873 public class Xcls_dbmodel : Object
875 public Gtk.ListStore el;
876 private Xcls_PopoverFileDetails _this;
882 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
885 _this.dbmodel = this;
886 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
890 // set gobject values
893 // user defined functions
894 public void loadData (Gee.ArrayList<string> data, string cur) {
899 /// el.append(out iter);
902 // el.set_value(iter, 0, "");
903 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
908 el.set_value(iter, 0, "");
909 el.set_value(iter, 1, "-- select a module --");
910 _this.build_module.el.set_active_iter(iter);
912 for (var i = 0; i < data.size;i++) {
917 el.set_value(iter, 0, data.get(i));
918 el.set_value(iter, 1, data.get(i));
920 if (data.get(i) == cur) {
921 _this.build_module.el.set_active_iter(iter);
925 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
931 public class Xcls_Label25 : Object
934 private Xcls_PopoverFileDetails _this;
940 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
943 this.el = new Gtk.Label( "Directory" );
947 // set gobject values
948 this.el.justify = Gtk.Justification.RIGHT;
949 this.el.xalign = 0.900000f;
950 this.el.visible = true;
953 // user defined functions
956 public class Xcls_dir : Object
958 public Gtk.ComboBox el;
959 private Xcls_PopoverFileDetails _this;
965 public Xcls_dir(Xcls_PopoverFileDetails _owner )
969 this.el = new Gtk.ComboBox();
973 // set gobject values
974 var child_0 = new Xcls_dircellrenderer( _this );
976 this.el.pack_start ( child_0.el , true );
977 var child_1 = new Xcls_dirmodel( _this );
979 this.el.set_model ( child_1.el );
983 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
986 // user defined functions
988 public class Xcls_dircellrenderer : Object
990 public Gtk.CellRendererText el;
991 private Xcls_PopoverFileDetails _this;
997 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
1000 _this.dircellrenderer = this;
1001 this.el = new Gtk.CellRendererText();
1005 // set gobject values
1008 // user defined functions
1011 public class Xcls_dirmodel : Object
1013 public Gtk.ListStore el;
1014 private Xcls_PopoverFileDetails _this;
1020 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1023 _this.dirmodel = this;
1024 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1028 // set gobject values
1031 // user defined functions
1032 public void loadData (Gee.ArrayList<string> data, string cur) {
1037 /// el.append(out iter);
1040 // el.set_value(iter, 0, "");
1041 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1043 el.append(out iter);
1046 el.set_value(iter, 0, "");
1047 el.set_value(iter, 1, "-- select a module --");
1048 _this.build_module.el.set_active_iter(iter);
1050 for (var i = 0; i < data.size;i++) {
1053 el.append(out iter);
1055 el.set_value(iter, 0, data.get(i));
1056 el.set_value(iter, 1, data.get(i));
1058 if (data.get(i) == cur) {
1059 _this.build_module.el.set_active_iter(iter);
1063 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1070 public class Xcls_HButtonBox29 : Object
1072 public Gtk.HButtonBox el;
1073 private Xcls_PopoverFileDetails _this;
1079 public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
1082 this.el = new Gtk.HButtonBox();
1086 // set gobject values
1087 this.el.margin_right = 4;
1088 this.el.margin_left = 4;
1089 this.el.margin_bottom = 4;
1090 var child_0 = new Xcls_Button30( _this );
1092 this.el.add ( child_0.el );
1093 var child_1 = new Xcls_save_btn( _this );
1095 this.el.add ( child_1.el );
1098 // user defined functions
1100 public class Xcls_Button30 : Object
1102 public Gtk.Button el;
1103 private Xcls_PopoverFileDetails _this;
1109 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1112 this.el = new Gtk.Button();
1116 // set gobject values
1117 this.el.label = "Cancel";
1120 this.el.clicked.connect( () => {
1127 // user defined functions
1130 public class Xcls_save_btn : Object
1132 public Gtk.Button el;
1133 private Xcls_PopoverFileDetails _this;
1139 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1142 _this.save_btn = this;
1143 this.el = new Gtk.Button();
1147 // set gobject values
1148 this.el.label = "Save";
1151 this.el.clicked.connect( ( ) => {
1156 if (_this.name.el.get_text().length < 1) {
1157 StandardErrorDialog.show(
1158 _this.mainwindow.el,
1159 "You have to set Component name "
1164 // what does this do?
1166 var isNew = _this.file.name.length > 0 ? false : true;
1168 if (!isNew && this.file.name != _this.name.el.get_text()) {
1169 Xcls_StandardErrorDialog.singleton().show(
1171 "Sorry changing names does not work yet. "
1180 // FIXME - this may be more complicated...
1181 //for (var i in this.def) {
1182 // this.file[i] = this.get(i).el.get_text();
1187 _this.updateFileFromEntry();
1188 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1189 Xcls_StandardErrorDialog.singleton().show(
1190 _this.mainwindow.el,
1191 "The name you used already exists "
1203 // ---------------- NEW FILES...
1205 var fn = _this.name.el.get_text();
1206 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1208 var targetfile = dir + "/" + fn;
1210 // strip the file type off the end..
1213 if (!_this.filetype.el.get_active_iter(out iter)) {
1214 // should not happen...
1215 // so we are jut going to return without
1216 StandardErrorDialog.show(
1217 _this.mainwindow.el,
1218 "You must select a file type. "
1222 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1223 var ext = ((string)ftypename);
1225 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1226 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1228 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1229 Xcls_StandardErrorDialog.singleton().show(
1230 _this.mainwindow.el,
1231 "That file already exists"
1236 var f = JsRender.JsRender.factory(
1237 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1239 targetfile + "." + ext);
1245 _this.updateFileFromEntry();
1246 _this.file.loaded = true;
1249 _this.file.project.addFile(_this.file);
1257 // hopefull this will work with bjs files..
1259 _this.success(_this.project, _this.file);
1264 // user defined functions