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);
383 el = _this.grid.el.get_child_at(1,i);
397 // user defined functions
399 public class Xcls_ftdbcellrenderer : Object
401 public Gtk.CellRendererText el;
402 private Xcls_PopoverFileDetails _this;
408 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
411 _this.ftdbcellrenderer = this;
412 this.el = new Gtk.CellRendererText();
416 // set gobject values
419 // user defined functions
422 public class Xcls_ftdbmodel : Object
424 public Gtk.ListStore el;
425 private Xcls_PopoverFileDetails _this;
431 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
434 _this.ftdbmodel = this;
435 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
439 // set gobject values
442 // user defined functions
443 public void loadData (string cur) {
448 /// el.append(out iter);
451 // el.set_value(iter, 0, "");
452 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
457 el.set_value(iter, 0, "bjs");
458 el.set_value(iter, 1, "User Interface File (bjs)");
459 _this.filetype.el.set_active_iter(iter);
463 el.set_value(iter, 0, "vala");
464 el.set_value(iter, 1, "Vala");
466 _this.filetype.el.set_active_iter(iter);
473 el.set_value(iter, 0, "js");
474 el.set_value(iter, 1, "Javascript");
477 _this.filetype.el.set_active_iter(iter);
482 el.set_value(iter, 0, "css");
483 el.set_value(iter, 1, "CSS");
486 _this.filetype.el.set_active_iter(iter);
493 public class Xcls_Label9 : Object
496 private Xcls_PopoverFileDetails _this;
502 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
505 this.el = new Gtk.Label( "Component Name" );
509 // set gobject values
510 this.el.justify = Gtk.Justification.RIGHT;
511 this.el.xalign = 0.900000f;
514 // user defined functions
517 public class Xcls_name : Object
520 private Xcls_PopoverFileDetails _this;
526 public Xcls_name(Xcls_PopoverFileDetails _owner )
530 this.el = new Gtk.Entry();
534 // set gobject values
535 this.el.visible = true;
538 // user defined functions
541 public class Xcls_Label11 : Object
544 private Xcls_PopoverFileDetails _this;
550 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
553 this.el = new Gtk.Label( "Title" );
557 // set gobject values
558 this.el.justify = Gtk.Justification.RIGHT;
559 this.el.xalign = 0.900000f;
560 this.el.visible = true;
563 // user defined functions
566 public class Xcls_title : Object
569 private Xcls_PopoverFileDetails _this;
575 public Xcls_title(Xcls_PopoverFileDetails _owner )
579 this.el = new Gtk.Entry();
583 // set gobject values
584 this.el.visible = true;
587 // user defined functions
590 public class Xcls_Label13 : Object
593 private Xcls_PopoverFileDetails _this;
599 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
602 this.el = new Gtk.Label( "Region" );
606 // set gobject values
607 this.el.justify = Gtk.Justification.RIGHT;
608 this.el.xalign = 0.900000f;
609 this.el.tooltip_text = "center, north, south, east, west";
610 this.el.visible = true;
613 // user defined functions
616 public class Xcls_region : Object
619 private Xcls_PopoverFileDetails _this;
625 public Xcls_region(Xcls_PopoverFileDetails _owner )
629 this.el = new Gtk.Entry();
633 // set gobject values
634 this.el.visible = true;
637 // user defined functions
640 public class Xcls_Label15 : Object
643 private Xcls_PopoverFileDetails _this;
649 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
652 this.el = new Gtk.Label( "Parent Name" );
656 // set gobject values
657 this.el.justify = Gtk.Justification.RIGHT;
658 this.el.xalign = 0.900000f;
659 this.el.visible = true;
662 // user defined functions
665 public class Xcls_parent : Object
668 private Xcls_PopoverFileDetails _this;
674 public Xcls_parent(Xcls_PopoverFileDetails _owner )
678 this.el = new Gtk.Entry();
682 // set gobject values
683 this.el.visible = true;
686 // user defined functions
689 public class Xcls_Label17 : Object
692 private Xcls_PopoverFileDetails _this;
698 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
701 this.el = new Gtk.Label( "Permission Name" );
705 // set gobject values
706 this.el.justify = Gtk.Justification.RIGHT;
707 this.el.xalign = 0.900000f;
708 this.el.visible = true;
711 // user defined functions
714 public class Xcls_permname : Object
717 private Xcls_PopoverFileDetails _this;
723 public Xcls_permname(Xcls_PopoverFileDetails _owner )
726 _this.permname = this;
727 this.el = new Gtk.Entry();
731 // set gobject values
732 this.el.visible = true;
735 // user defined functions
738 public class Xcls_Label19 : Object
741 private Xcls_PopoverFileDetails _this;
747 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
750 this.el = new Gtk.Label( "Order (for tabs)" );
754 // set gobject values
755 this.el.justify = Gtk.Justification.RIGHT;
756 this.el.xalign = 0.900000f;
757 this.el.visible = true;
760 // user defined functions
763 public class Xcls_modOrder : Object
766 private Xcls_PopoverFileDetails _this;
772 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
775 _this.modOrder = this;
776 this.el = new Gtk.Entry();
780 // set gobject values
781 this.el.visible = true;
784 // user defined functions
787 public class Xcls_Label21 : Object
790 private Xcls_PopoverFileDetails _this;
796 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
799 this.el = new Gtk.Label( "Module to build (Vala only)" );
803 // set gobject values
804 this.el.justify = Gtk.Justification.RIGHT;
805 this.el.xalign = 0.900000f;
806 this.el.visible = true;
809 // user defined functions
812 public class Xcls_build_module : Object
814 public Gtk.ComboBox el;
815 private Xcls_PopoverFileDetails _this;
821 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
824 _this.build_module = this;
825 this.el = new Gtk.ComboBox();
829 // set gobject values
830 var child_0 = new Xcls_dbcellrenderer( _this );
832 this.el.pack_start ( child_0.el , true );
833 var child_1 = new Xcls_dbmodel( _this );
835 this.el.set_model ( child_1.el );
839 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
842 // user defined functions
844 public class Xcls_dbcellrenderer : Object
846 public Gtk.CellRendererText el;
847 private Xcls_PopoverFileDetails _this;
853 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
856 _this.dbcellrenderer = this;
857 this.el = new Gtk.CellRendererText();
861 // set gobject values
864 // user defined functions
867 public class Xcls_dbmodel : Object
869 public Gtk.ListStore el;
870 private Xcls_PopoverFileDetails _this;
876 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
879 _this.dbmodel = this;
880 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
884 // set gobject values
887 // user defined functions
888 public void loadData (Gee.ArrayList<string> data, string cur) {
893 /// el.append(out iter);
896 // el.set_value(iter, 0, "");
897 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
902 el.set_value(iter, 0, "");
903 el.set_value(iter, 1, "-- select a module --");
904 _this.build_module.el.set_active_iter(iter);
906 for (var i = 0; i < data.size;i++) {
911 el.set_value(iter, 0, data.get(i));
912 el.set_value(iter, 1, data.get(i));
914 if (data.get(i) == cur) {
915 _this.build_module.el.set_active_iter(iter);
919 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
925 public class Xcls_Label25 : Object
928 private Xcls_PopoverFileDetails _this;
934 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
937 this.el = new Gtk.Label( "Directory" );
941 // set gobject values
942 this.el.justify = Gtk.Justification.RIGHT;
943 this.el.xalign = 0.900000f;
944 this.el.visible = true;
947 // user defined functions
950 public class Xcls_dir : Object
952 public Gtk.ComboBox el;
953 private Xcls_PopoverFileDetails _this;
959 public Xcls_dir(Xcls_PopoverFileDetails _owner )
963 this.el = new Gtk.ComboBox();
967 // set gobject values
968 var child_0 = new Xcls_dircellrenderer( _this );
970 this.el.pack_start ( child_0.el , true );
971 var child_1 = new Xcls_dirmodel( _this );
973 this.el.set_model ( child_1.el );
977 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
980 // user defined functions
982 public class Xcls_dircellrenderer : Object
984 public Gtk.CellRendererText el;
985 private Xcls_PopoverFileDetails _this;
991 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
994 _this.dircellrenderer = this;
995 this.el = new Gtk.CellRendererText();
999 // set gobject values
1002 // user defined functions
1005 public class Xcls_dirmodel : Object
1007 public Gtk.ListStore el;
1008 private Xcls_PopoverFileDetails _this;
1014 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1017 _this.dirmodel = this;
1018 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1022 // set gobject values
1025 // user defined functions
1026 public void loadData (Gee.ArrayList<string> data, string cur) {
1031 /// el.append(out iter);
1034 // el.set_value(iter, 0, "");
1035 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1037 el.append(out iter);
1040 el.set_value(iter, 0, "");
1041 el.set_value(iter, 1, "-- select a module --");
1042 _this.build_module.el.set_active_iter(iter);
1044 for (var i = 0; i < data.size;i++) {
1047 el.append(out iter);
1049 el.set_value(iter, 0, data.get(i));
1050 el.set_value(iter, 1, data.get(i));
1052 if (data.get(i) == cur) {
1053 _this.build_module.el.set_active_iter(iter);
1057 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1064 public class Xcls_HButtonBox29 : Object
1066 public Gtk.HButtonBox el;
1067 private Xcls_PopoverFileDetails _this;
1073 public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
1076 this.el = new Gtk.HButtonBox();
1080 // set gobject values
1081 this.el.margin_right = 4;
1082 this.el.margin_left = 4;
1083 this.el.margin_bottom = 4;
1084 var child_0 = new Xcls_Button30( _this );
1086 this.el.add ( child_0.el );
1087 var child_1 = new Xcls_save_btn( _this );
1089 this.el.add ( child_1.el );
1092 // user defined functions
1094 public class Xcls_Button30 : Object
1096 public Gtk.Button el;
1097 private Xcls_PopoverFileDetails _this;
1103 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1106 this.el = new Gtk.Button();
1110 // set gobject values
1111 this.el.label = "Cancel";
1114 this.el.clicked.connect( () => {
1121 // user defined functions
1124 public class Xcls_save_btn : Object
1126 public Gtk.Button el;
1127 private Xcls_PopoverFileDetails _this;
1133 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1136 _this.save_btn = this;
1137 this.el = new Gtk.Button();
1141 // set gobject values
1142 this.el.label = "Save";
1145 this.el.clicked.connect( ( ) => {
1150 if (_this.name.el.get_text().length < 1) {
1151 StandardErrorDialog.show(
1152 _this.mainwindow.el,
1153 "You have to set Component name "
1158 // what does this do?
1160 var isNew = _this.file.name.length > 0 ? false : true;
1162 if (!isNew && this.file.name != _this.name.el.get_text()) {
1163 Xcls_StandardErrorDialog.singleton().show(
1165 "Sorry changing names does not work yet. "
1174 // FIXME - this may be more complicated...
1175 //for (var i in this.def) {
1176 // this.file[i] = this.get(i).el.get_text();
1181 _this.updateFileFromEntry();
1182 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1183 Xcls_StandardErrorDialog.singleton().show(
1184 _this.mainwindow.el,
1185 "The name you used already exists "
1197 // ---------------- NEW FILES...
1199 var fn = _this.name.el.get_text();
1200 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1202 var targetfile = dir + "/" + fn;
1204 // strip the file type off the end..
1207 if (!_this.filetype.el.get_active_iter(out iter)) {
1208 // should not happen...
1209 // so we are jut going to return without
1210 StandardErrorDialog.show(
1211 _this.mainwindow.el,
1212 "You must select a file type. "
1216 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1217 var ext = ((string)ftypename);
1219 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1220 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1222 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1223 Xcls_StandardErrorDialog.singleton().show(
1224 _this.mainwindow.el,
1225 "That file already exists"
1230 var f = JsRender.JsRender.factory(
1231 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1233 targetfile + "." + ext);
1239 _this.updateFileFromEntry();
1240 _this.file.loaded = true;
1243 _this.file.project.addFile(_this.file);
1251 // hopefull this will work with bjs files..
1253 _this.success(_this.project, _this.file);
1258 // user defined functions