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");
127 var ar = new Gee.ArrayList<string>();
128 _this.dbmodel.loadData(ar,"");
129 // load the modules... if relivant..
130 if (this.project.xtype == "Gtk") {
131 var p = (Project.Gtk)c.project;
132 var cg = p.compilegroups;
134 var iter = cg.map_iterator();
136 var key = iter.get_key();
137 if (key == "_default_") {
142 _this.dbmodel.loadData(ar, c.build_module);
148 //console.log('show all');
149 this.el.set_modal(true);
150 this.el.set_relative_to(btn);
152 this.el.set_position(Gtk.PositionType.RIGHT);
155 print("SHOWALL - POPIP\n");
157 this.name.el.grab_focus();
161 if (c.path.length > 0) {
162 _this.filetype.el.hide();
163 _this.filetypelbl.el.hide();
164 _this.filetype.showhide(true); // as we only work on bjs files currently
167 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
168 _this.filetype.el.show();
169 _this.filetypelbl.el.show();
173 //this.success = c.success;
177 public class Xcls_Box2 : Object
180 private Xcls_PopoverFileDetails _this;
186 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
189 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
193 // set gobject values
194 this.el.homogeneous = false;
195 var child_0 = new Xcls_HeaderBar3( _this );
197 this.el.pack_start ( child_0.el , false,true,0 );
198 var child_1 = new Xcls_grid( _this );
200 this.el.pack_start ( child_1.el , false,false,4 );
201 var child_2 = new Xcls_HButtonBox29( _this );
203 this.el.pack_end ( child_2.el , false,true,0 );
206 // user defined functions
208 public class Xcls_HeaderBar3 : Object
210 public Gtk.HeaderBar el;
211 private Xcls_PopoverFileDetails _this;
217 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
220 this.el = new Gtk.HeaderBar();
224 // set gobject values
225 this.el.title = "Add / Edit File";
228 // user defined functions
231 public class Xcls_grid : Object
234 private Xcls_PopoverFileDetails _this;
240 public Xcls_grid(Xcls_PopoverFileDetails _owner )
244 this.el = new Gtk.Grid();
248 // set gobject values
249 this.el.margin_right = 4;
250 this.el.margin_left = 4;
251 this.el.row_spacing = 2;
252 var child_0 = new Xcls_filetypelbl( _this );
254 this.el.attach ( child_0.el , 0,0,1,1 );
255 var child_1 = new Xcls_filetype( _this );
257 this.el.attach ( child_1.el , 1,0,1,1 );
258 var child_2 = new Xcls_Label9( _this );
260 this.el.attach ( child_2.el , 0,1,1,1 );
261 var child_3 = new Xcls_name( _this );
263 this.el.attach ( child_3.el , 1,1,1,1 );
264 var child_4 = new Xcls_Label11( _this );
266 this.el.attach ( child_4.el , 0,2,1,1 );
267 var child_5 = new Xcls_title( _this );
269 this.el.attach ( child_5.el , 1,2,1,1 );
270 var child_6 = new Xcls_Label13( _this );
272 this.el.attach ( child_6.el , 0,3,1,1 );
273 var child_7 = new Xcls_region( _this );
275 this.el.attach ( child_7.el , 1,3,1,1 );
276 var child_8 = new Xcls_Label15( _this );
278 this.el.attach ( child_8.el , 0,4,1,1 );
279 var child_9 = new Xcls_parent( _this );
281 this.el.attach ( child_9.el , 1,4,1,1 );
282 var child_10 = new Xcls_Label17( _this );
284 this.el.attach ( child_10.el , 0,5,1,1 );
285 var child_11 = new Xcls_permname( _this );
287 this.el.attach ( child_11.el , 1,5,1,1 );
288 var child_12 = new Xcls_Label19( _this );
290 this.el.attach ( child_12.el , 0,6,1,1 );
291 var child_13 = new Xcls_modOrder( _this );
293 this.el.attach ( child_13.el , 1,6,1,1 );
294 var child_14 = new Xcls_Label21( _this );
296 this.el.attach ( child_14.el , 0,7,1,1 );
297 var child_15 = new Xcls_build_module( _this );
299 this.el.attach ( child_15.el , 1,7,1,1 );
300 var child_16 = new Xcls_Label25( _this );
302 this.el.attach ( child_16.el , 0,8 );
303 var child_17 = new Xcls_dir( _this );
305 this.el.attach ( child_17.el , 1,8 );
308 // user defined functions
310 public class Xcls_filetypelbl : Object
313 private Xcls_PopoverFileDetails _this;
319 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
322 _this.filetypelbl = this;
323 this.el = new Gtk.Label( "File type" );
327 // set gobject values
328 this.el.justify = Gtk.Justification.RIGHT;
329 this.el.xalign = 0.900000f;
332 // user defined functions
335 public class Xcls_filetype : Object
337 public Gtk.ComboBox el;
338 private Xcls_PopoverFileDetails _this;
344 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
347 _this.filetype = this;
348 this.el = new Gtk.ComboBox();
352 // set gobject values
353 var child_0 = new Xcls_ftdbcellrenderer( _this );
355 this.el.pack_start ( child_0.el , true );
356 var child_1 = new Xcls_ftdbmodel( _this );
358 this.el.set_model ( child_1.el );
362 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
365 this.el.changed.connect( () => {
368 if (this.el.get_active_iter(out iter)) {
370 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
371 is_bjs = ((string)vfname) == "bjs";
375 // directory is only available for non-bjs
376 this.showhide(is_bjs);
382 // user defined functions
383 public void showhide (bool is_bjs) {
384 for (var i = 2; i < 9;i++) {
385 var el = _this.grid.el.get_child_at(0,i);
387 var showhide= is_bjs;
389 showhide = !showhide;
397 el = _this.grid.el.get_child_at(1,i);
406 public class Xcls_ftdbcellrenderer : Object
408 public Gtk.CellRendererText el;
409 private Xcls_PopoverFileDetails _this;
415 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
418 _this.ftdbcellrenderer = this;
419 this.el = new Gtk.CellRendererText();
423 // set gobject values
426 // user defined functions
429 public class Xcls_ftdbmodel : Object
431 public Gtk.ListStore el;
432 private Xcls_PopoverFileDetails _this;
438 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
441 _this.ftdbmodel = this;
442 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
446 // set gobject values
449 // user defined functions
450 public void loadData (string cur) {
455 /// el.append(out iter);
458 // el.set_value(iter, 0, "");
459 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
464 el.set_value(iter, 0, "bjs");
465 el.set_value(iter, 1, "User Interface File (bjs)");
466 _this.filetype.el.set_active_iter(iter);
470 el.set_value(iter, 0, "vala");
471 el.set_value(iter, 1, "Vala");
473 _this.filetype.el.set_active_iter(iter);
480 el.set_value(iter, 0, "js");
481 el.set_value(iter, 1, "Javascript");
484 _this.filetype.el.set_active_iter(iter);
489 el.set_value(iter, 0, "css");
490 el.set_value(iter, 1, "CSS");
493 _this.filetype.el.set_active_iter(iter);
500 public class Xcls_Label9 : Object
503 private Xcls_PopoverFileDetails _this;
509 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
512 this.el = new Gtk.Label( "Component Name" );
516 // set gobject values
517 this.el.justify = Gtk.Justification.RIGHT;
518 this.el.xalign = 0.900000f;
521 // user defined functions
524 public class Xcls_name : Object
527 private Xcls_PopoverFileDetails _this;
533 public Xcls_name(Xcls_PopoverFileDetails _owner )
537 this.el = new Gtk.Entry();
541 // set gobject values
542 this.el.visible = true;
545 // user defined functions
548 public class Xcls_Label11 : Object
551 private Xcls_PopoverFileDetails _this;
557 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
560 this.el = new Gtk.Label( "Title" );
564 // set gobject values
565 this.el.justify = Gtk.Justification.RIGHT;
566 this.el.xalign = 0.900000f;
567 this.el.visible = true;
570 // user defined functions
573 public class Xcls_title : Object
576 private Xcls_PopoverFileDetails _this;
582 public Xcls_title(Xcls_PopoverFileDetails _owner )
586 this.el = new Gtk.Entry();
590 // set gobject values
591 this.el.visible = true;
594 // user defined functions
597 public class Xcls_Label13 : Object
600 private Xcls_PopoverFileDetails _this;
606 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
609 this.el = new Gtk.Label( "Region" );
613 // set gobject values
614 this.el.justify = Gtk.Justification.RIGHT;
615 this.el.xalign = 0.900000f;
616 this.el.tooltip_text = "center, north, south, east, west";
617 this.el.visible = true;
620 // user defined functions
623 public class Xcls_region : Object
626 private Xcls_PopoverFileDetails _this;
632 public Xcls_region(Xcls_PopoverFileDetails _owner )
636 this.el = new Gtk.Entry();
640 // set gobject values
641 this.el.visible = true;
644 // user defined functions
647 public class Xcls_Label15 : Object
650 private Xcls_PopoverFileDetails _this;
656 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
659 this.el = new Gtk.Label( "Parent Name" );
663 // set gobject values
664 this.el.justify = Gtk.Justification.RIGHT;
665 this.el.xalign = 0.900000f;
666 this.el.visible = true;
669 // user defined functions
672 public class Xcls_parent : Object
675 private Xcls_PopoverFileDetails _this;
681 public Xcls_parent(Xcls_PopoverFileDetails _owner )
685 this.el = new Gtk.Entry();
689 // set gobject values
690 this.el.visible = true;
693 // user defined functions
696 public class Xcls_Label17 : Object
699 private Xcls_PopoverFileDetails _this;
705 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
708 this.el = new Gtk.Label( "Permission Name" );
712 // set gobject values
713 this.el.justify = Gtk.Justification.RIGHT;
714 this.el.xalign = 0.900000f;
715 this.el.visible = true;
718 // user defined functions
721 public class Xcls_permname : Object
724 private Xcls_PopoverFileDetails _this;
730 public Xcls_permname(Xcls_PopoverFileDetails _owner )
733 _this.permname = this;
734 this.el = new Gtk.Entry();
738 // set gobject values
739 this.el.visible = true;
742 // user defined functions
745 public class Xcls_Label19 : Object
748 private Xcls_PopoverFileDetails _this;
754 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
757 this.el = new Gtk.Label( "Order (for tabs)" );
761 // set gobject values
762 this.el.justify = Gtk.Justification.RIGHT;
763 this.el.xalign = 0.900000f;
764 this.el.visible = true;
767 // user defined functions
770 public class Xcls_modOrder : Object
773 private Xcls_PopoverFileDetails _this;
779 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
782 _this.modOrder = this;
783 this.el = new Gtk.Entry();
787 // set gobject values
788 this.el.visible = true;
791 // user defined functions
794 public class Xcls_Label21 : Object
797 private Xcls_PopoverFileDetails _this;
803 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
806 this.el = new Gtk.Label( "Module to build (Vala only)" );
810 // set gobject values
811 this.el.justify = Gtk.Justification.RIGHT;
812 this.el.xalign = 0.900000f;
813 this.el.visible = true;
816 // user defined functions
819 public class Xcls_build_module : Object
821 public Gtk.ComboBox el;
822 private Xcls_PopoverFileDetails _this;
828 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
831 _this.build_module = this;
832 this.el = new Gtk.ComboBox();
836 // set gobject values
837 var child_0 = new Xcls_dbcellrenderer( _this );
839 this.el.pack_start ( child_0.el , true );
840 var child_1 = new Xcls_dbmodel( _this );
842 this.el.set_model ( child_1.el );
846 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
849 // user defined functions
851 public class Xcls_dbcellrenderer : Object
853 public Gtk.CellRendererText el;
854 private Xcls_PopoverFileDetails _this;
860 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
863 _this.dbcellrenderer = this;
864 this.el = new Gtk.CellRendererText();
868 // set gobject values
871 // user defined functions
874 public class Xcls_dbmodel : Object
876 public Gtk.ListStore el;
877 private Xcls_PopoverFileDetails _this;
883 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
886 _this.dbmodel = this;
887 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
891 // set gobject values
894 // user defined functions
895 public void loadData (Gee.ArrayList<string> data, string cur) {
900 /// el.append(out iter);
903 // el.set_value(iter, 0, "");
904 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
909 el.set_value(iter, 0, "");
910 el.set_value(iter, 1, "-- select a module --");
911 _this.build_module.el.set_active_iter(iter);
913 for (var i = 0; i < data.size;i++) {
918 el.set_value(iter, 0, data.get(i));
919 el.set_value(iter, 1, data.get(i));
921 if (data.get(i) == cur) {
922 _this.build_module.el.set_active_iter(iter);
926 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
932 public class Xcls_Label25 : Object
935 private Xcls_PopoverFileDetails _this;
941 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
944 this.el = new Gtk.Label( "Directory" );
948 // set gobject values
949 this.el.justify = Gtk.Justification.RIGHT;
950 this.el.xalign = 0.900000f;
951 this.el.visible = true;
954 // user defined functions
957 public class Xcls_dir : Object
959 public Gtk.ComboBox el;
960 private Xcls_PopoverFileDetails _this;
966 public Xcls_dir(Xcls_PopoverFileDetails _owner )
970 this.el = new Gtk.ComboBox();
974 // set gobject values
975 var child_0 = new Xcls_dircellrenderer( _this );
977 this.el.pack_start ( child_0.el , true );
978 var child_1 = new Xcls_dirmodel( _this );
980 this.el.set_model ( child_1.el );
984 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
987 // user defined functions
989 public class Xcls_dircellrenderer : Object
991 public Gtk.CellRendererText el;
992 private Xcls_PopoverFileDetails _this;
998 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
1001 _this.dircellrenderer = this;
1002 this.el = new Gtk.CellRendererText();
1006 // set gobject values
1009 // user defined functions
1012 public class Xcls_dirmodel : Object
1014 public Gtk.ListStore el;
1015 private Xcls_PopoverFileDetails _this;
1021 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1024 _this.dirmodel = this;
1025 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1029 // set gobject values
1032 // user defined functions
1033 public void loadData (Gee.ArrayList<string> data, string cur) {
1038 /// el.append(out iter);
1041 // el.set_value(iter, 0, "");
1042 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1044 el.append(out iter);
1047 el.set_value(iter, 0, "");
1048 el.set_value(iter, 1, "-- select a module --");
1049 _this.build_module.el.set_active_iter(iter);
1051 for (var i = 0; i < data.size;i++) {
1054 el.append(out iter);
1056 el.set_value(iter, 0, data.get(i));
1057 el.set_value(iter, 1, data.get(i));
1059 if (data.get(i) == cur) {
1060 _this.build_module.el.set_active_iter(iter);
1064 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1071 public class Xcls_HButtonBox29 : Object
1073 public Gtk.HButtonBox el;
1074 private Xcls_PopoverFileDetails _this;
1080 public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
1083 this.el = new Gtk.HButtonBox();
1087 // set gobject values
1088 this.el.margin_right = 4;
1089 this.el.margin_left = 4;
1090 this.el.margin_bottom = 4;
1091 var child_0 = new Xcls_Button30( _this );
1093 this.el.add ( child_0.el );
1094 var child_1 = new Xcls_save_btn( _this );
1096 this.el.add ( child_1.el );
1099 // user defined functions
1101 public class Xcls_Button30 : Object
1103 public Gtk.Button el;
1104 private Xcls_PopoverFileDetails _this;
1110 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1113 this.el = new Gtk.Button();
1117 // set gobject values
1118 this.el.label = "Cancel";
1121 this.el.clicked.connect( () => {
1128 // user defined functions
1131 public class Xcls_save_btn : Object
1133 public Gtk.Button el;
1134 private Xcls_PopoverFileDetails _this;
1140 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1143 _this.save_btn = this;
1144 this.el = new Gtk.Button();
1148 // set gobject values
1149 this.el.label = "Save";
1152 this.el.clicked.connect( ( ) => {
1157 if (_this.name.el.get_text().length < 1) {
1158 StandardErrorDialog.show(
1159 _this.mainwindow.el,
1160 "You have to set Component name "
1165 // what does this do?
1167 var isNew = _this.file.name.length > 0 ? false : true;
1169 if (!isNew && this.file.name != _this.name.el.get_text()) {
1170 Xcls_StandardErrorDialog.singleton().show(
1172 "Sorry changing names does not work yet. "
1181 // FIXME - this may be more complicated...
1182 //for (var i in this.def) {
1183 // this.file[i] = this.get(i).el.get_text();
1188 _this.updateFileFromEntry();
1189 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1190 Xcls_StandardErrorDialog.singleton().show(
1191 _this.mainwindow.el,
1192 "The name you used already exists "
1204 // ---------------- NEW FILES...
1206 var fn = _this.name.el.get_text();
1207 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1209 var targetfile = dir + "/" + fn;
1211 // strip the file type off the end..
1214 if (!_this.filetype.el.get_active_iter(out iter)) {
1215 // should not happen...
1216 // so we are jut going to return without
1217 StandardErrorDialog.show(
1218 _this.mainwindow.el,
1219 "You must select a file type. "
1223 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1224 var ext = ((string)ftypename);
1226 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1227 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1229 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1230 Xcls_StandardErrorDialog.singleton().show(
1231 _this.mainwindow.el,
1232 "That file already exists"
1237 var f = JsRender.JsRender.factory(
1238 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1240 targetfile + "." + ext);
1246 _this.updateFileFromEntry();
1247 _this.file.loaded = true;
1250 _this.file.project.addFile(_this.file);
1258 // hopefull this will work with bjs files..
1260 _this.success(_this.project, _this.file);
1265 // user defined functions