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_build_module build_module;
30 public Xcls_dbcellrenderer dbcellrenderer;
31 public Xcls_dbmodel dbmodel;
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_Label29( _this );
205 this.el.attach ( child_2.el , 0,7,1,1 );
206 var child_3 = new Xcls_HButtonBox30( _this );
208 this.el.pack_end ( child_3.el , false,true,0 );
211 // user defined functions
213 public class Xcls_HeaderBar3 : Object
215 public Gtk.HeaderBar el;
216 private Xcls_PopoverFileDetails _this;
222 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
225 this.el = new Gtk.HeaderBar();
229 // set gobject values
230 this.el.title = "Add / Edit File";
233 // user defined functions
236 public class Xcls_grid : Object
239 private Xcls_PopoverFileDetails _this;
245 public Xcls_grid(Xcls_PopoverFileDetails _owner )
249 this.el = new Gtk.Grid();
253 // set gobject values
254 this.el.margin_right = 4;
255 this.el.margin_left = 4;
256 this.el.row_spacing = 2;
257 var child_0 = new Xcls_filetypelbl( _this );
259 this.el.attach ( child_0.el , 0,0,1,1 );
260 var child_1 = new Xcls_filetype( _this );
262 this.el.attach ( child_1.el , 1,0,1,1 );
263 var child_2 = new Xcls_Label9( _this );
265 this.el.attach ( child_2.el , 0,1,1,1 );
266 var child_3 = new Xcls_name( _this );
268 this.el.attach ( child_3.el , 1,1,1,1 );
269 var child_4 = new Xcls_Label11( _this );
271 this.el.attach ( child_4.el , 0,2,1,1 );
272 var child_5 = new Xcls_title( _this );
274 this.el.attach ( child_5.el , 1,2,1,1 );
275 var child_6 = new Xcls_Label13( _this );
277 this.el.attach ( child_6.el , 0,3,1,1 );
278 var child_7 = new Xcls_region( _this );
280 this.el.attach ( child_7.el , 1,3,1,1 );
281 var child_8 = new Xcls_Label15( _this );
283 this.el.attach ( child_8.el , 0,4,1,1 );
284 var child_9 = new Xcls_parent( _this );
286 this.el.attach ( child_9.el , 1,4,1,1 );
287 var child_10 = new Xcls_Label17( _this );
289 this.el.attach ( child_10.el , 0,5,1,1 );
290 var child_11 = new Xcls_permname( _this );
292 this.el.attach ( child_11.el , 1,5,1,1 );
293 var child_12 = new Xcls_Label19( _this );
295 this.el.attach ( child_12.el , 0,6,1,1 );
296 var child_13 = new Xcls_modOrder( _this );
298 this.el.attach ( child_13.el , 1,6,1,1 );
299 var child_14 = new Xcls_Label21( _this );
301 this.el.attach ( child_14.el , 0,7,1,1 );
302 var child_15 = new Xcls_build_module( _this );
304 this.el.attach ( child_15.el , 1,7,1,1 );
305 var child_16 = new Xcls_Label25( _this );
307 this.el.attach ( child_16.el , 0,8 );
308 var child_17 = new Xcls_build_module( _this );
310 this.el.attach ( child_17.el , 1,8 );
313 // user defined functions
315 public class Xcls_filetypelbl : Object
318 private Xcls_PopoverFileDetails _this;
324 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
327 _this.filetypelbl = this;
328 this.el = new Gtk.Label( "File type" );
332 // set gobject values
333 this.el.justify = Gtk.Justification.RIGHT;
334 this.el.xalign = 0.900000f;
337 // user defined functions
340 public class Xcls_filetype : Object
342 public Gtk.ComboBox el;
343 private Xcls_PopoverFileDetails _this;
349 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
352 _this.filetype = this;
353 this.el = new Gtk.ComboBox();
357 // set gobject values
358 var child_0 = new Xcls_ftdbcellrenderer( _this );
360 this.el.pack_start ( child_0.el , true );
361 var child_1 = new Xcls_ftdbmodel( _this );
363 this.el.set_model ( child_1.el );
367 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
370 this.el.changed.connect( () => {
373 if (this.el.get_active_iter(out iter)) {
375 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
376 is_bjs = ((string)vfname) == "bjs";
379 for (var i = 2; i < 8;i++) {
380 var el = _this.grid.el.get_child_at(0,i);
386 el = _this.grid.el.get_child_at(1,i);
400 // user defined functions
402 public class Xcls_ftdbcellrenderer : Object
404 public Gtk.CellRendererText el;
405 private Xcls_PopoverFileDetails _this;
411 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
414 _this.ftdbcellrenderer = this;
415 this.el = new Gtk.CellRendererText();
419 // set gobject values
422 // user defined functions
425 public class Xcls_ftdbmodel : Object
427 public Gtk.ListStore el;
428 private Xcls_PopoverFileDetails _this;
434 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
437 _this.ftdbmodel = this;
438 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
442 // set gobject values
445 // user defined functions
446 public void loadData (string cur) {
451 /// el.append(out iter);
454 // el.set_value(iter, 0, "");
455 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
460 el.set_value(iter, 0, "bjs");
461 el.set_value(iter, 1, "User Interface File (bjs)");
462 _this.filetype.el.set_active_iter(iter);
466 el.set_value(iter, 0, "vala");
467 el.set_value(iter, 1, "Vala");
469 _this.filetype.el.set_active_iter(iter);
476 el.set_value(iter, 0, "js");
477 el.set_value(iter, 1, "Javascript");
480 _this.filetype.el.set_active_iter(iter);
485 el.set_value(iter, 0, "css");
486 el.set_value(iter, 1, "CSS");
489 _this.filetype.el.set_active_iter(iter);
496 public class Xcls_Label9 : Object
499 private Xcls_PopoverFileDetails _this;
505 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
508 this.el = new Gtk.Label( "Component Name" );
512 // set gobject values
513 this.el.justify = Gtk.Justification.RIGHT;
514 this.el.xalign = 0.900000f;
517 // user defined functions
520 public class Xcls_name : Object
523 private Xcls_PopoverFileDetails _this;
529 public Xcls_name(Xcls_PopoverFileDetails _owner )
533 this.el = new Gtk.Entry();
537 // set gobject values
538 this.el.visible = true;
541 // user defined functions
544 public class Xcls_Label11 : Object
547 private Xcls_PopoverFileDetails _this;
553 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
556 this.el = new Gtk.Label( "Title" );
560 // set gobject values
561 this.el.justify = Gtk.Justification.RIGHT;
562 this.el.xalign = 0.900000f;
563 this.el.visible = true;
566 // user defined functions
569 public class Xcls_title : Object
572 private Xcls_PopoverFileDetails _this;
578 public Xcls_title(Xcls_PopoverFileDetails _owner )
582 this.el = new Gtk.Entry();
586 // set gobject values
587 this.el.visible = true;
590 // user defined functions
593 public class Xcls_Label13 : Object
596 private Xcls_PopoverFileDetails _this;
602 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
605 this.el = new Gtk.Label( "Region" );
609 // set gobject values
610 this.el.justify = Gtk.Justification.RIGHT;
611 this.el.xalign = 0.900000f;
612 this.el.tooltip_text = "center, north, south, east, west";
613 this.el.visible = true;
616 // user defined functions
619 public class Xcls_region : Object
622 private Xcls_PopoverFileDetails _this;
628 public Xcls_region(Xcls_PopoverFileDetails _owner )
632 this.el = new Gtk.Entry();
636 // set gobject values
637 this.el.visible = true;
640 // user defined functions
643 public class Xcls_Label15 : Object
646 private Xcls_PopoverFileDetails _this;
652 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
655 this.el = new Gtk.Label( "Parent Name" );
659 // set gobject values
660 this.el.justify = Gtk.Justification.RIGHT;
661 this.el.xalign = 0.900000f;
662 this.el.visible = true;
665 // user defined functions
668 public class Xcls_parent : Object
671 private Xcls_PopoverFileDetails _this;
677 public Xcls_parent(Xcls_PopoverFileDetails _owner )
681 this.el = new Gtk.Entry();
685 // set gobject values
686 this.el.visible = true;
689 // user defined functions
692 public class Xcls_Label17 : Object
695 private Xcls_PopoverFileDetails _this;
701 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
704 this.el = new Gtk.Label( "Permission Name" );
708 // set gobject values
709 this.el.justify = Gtk.Justification.RIGHT;
710 this.el.xalign = 0.900000f;
711 this.el.visible = true;
714 // user defined functions
717 public class Xcls_permname : Object
720 private Xcls_PopoverFileDetails _this;
726 public Xcls_permname(Xcls_PopoverFileDetails _owner )
729 _this.permname = this;
730 this.el = new Gtk.Entry();
734 // set gobject values
735 this.el.visible = true;
738 // user defined functions
741 public class Xcls_Label19 : Object
744 private Xcls_PopoverFileDetails _this;
750 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
753 this.el = new Gtk.Label( "Order (for tabs)" );
757 // set gobject values
758 this.el.justify = Gtk.Justification.RIGHT;
759 this.el.xalign = 0.900000f;
760 this.el.visible = true;
763 // user defined functions
766 public class Xcls_modOrder : Object
769 private Xcls_PopoverFileDetails _this;
775 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
778 _this.modOrder = this;
779 this.el = new Gtk.Entry();
783 // set gobject values
784 this.el.visible = true;
787 // user defined functions
790 public class Xcls_Label21 : Object
793 private Xcls_PopoverFileDetails _this;
799 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
802 this.el = new Gtk.Label( "Module to build (Vala only)" );
806 // set gobject values
807 this.el.justify = Gtk.Justification.RIGHT;
808 this.el.xalign = 0.900000f;
809 this.el.visible = true;
812 // user defined functions
815 public class Xcls_build_module : Object
817 public Gtk.ComboBox el;
818 private Xcls_PopoverFileDetails _this;
824 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
827 _this.build_module = this;
828 this.el = new Gtk.ComboBox();
832 // set gobject values
833 var child_0 = new Xcls_dbcellrenderer( _this );
835 this.el.pack_start ( child_0.el , true );
836 var child_1 = new Xcls_dbmodel( _this );
838 this.el.set_model ( child_1.el );
842 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
845 // user defined functions
847 public class Xcls_dbcellrenderer : Object
849 public Gtk.CellRendererText el;
850 private Xcls_PopoverFileDetails _this;
856 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
859 _this.dbcellrenderer = this;
860 this.el = new Gtk.CellRendererText();
864 // set gobject values
867 // user defined functions
870 public class Xcls_dbmodel : Object
872 public Gtk.ListStore el;
873 private Xcls_PopoverFileDetails _this;
879 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
882 _this.dbmodel = this;
883 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
887 // set gobject values
890 // user defined functions
891 public void loadData (Gee.ArrayList<string> data, string cur) {
896 /// el.append(out iter);
899 // el.set_value(iter, 0, "");
900 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
905 el.set_value(iter, 0, "");
906 el.set_value(iter, 1, "-- select a module --");
907 _this.build_module.el.set_active_iter(iter);
909 for (var i = 0; i < data.size;i++) {
914 el.set_value(iter, 0, data.get(i));
915 el.set_value(iter, 1, data.get(i));
917 if (data.get(i) == cur) {
918 _this.build_module.el.set_active_iter(iter);
922 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
928 public class Xcls_Label25 : Object
931 private Xcls_PopoverFileDetails _this;
937 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
940 this.el = new Gtk.Label( "Directory" );
944 // set gobject values
945 this.el.justify = Gtk.Justification.RIGHT;
946 this.el.xalign = 0.900000f;
947 this.el.visible = true;
950 // user defined functions
953 public class Xcls_build_module : Object
955 public Gtk.ComboBox el;
956 private Xcls_PopoverFileDetails _this;
962 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
965 _this.build_module = this;
966 this.el = new Gtk.ComboBox();
970 // set gobject values
971 var child_0 = new Xcls_dbcellrenderer( _this );
973 this.el.pack_start ( child_0.el , true );
974 var child_1 = new Xcls_dbmodel( _this );
976 this.el.set_model ( child_1.el );
980 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
983 // user defined functions
985 public class Xcls_dbcellrenderer : Object
987 public Gtk.CellRendererText el;
988 private Xcls_PopoverFileDetails _this;
994 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
997 _this.dbcellrenderer = this;
998 this.el = new Gtk.CellRendererText();
1002 // set gobject values
1005 // user defined functions
1008 public class Xcls_dbmodel : Object
1010 public Gtk.ListStore el;
1011 private Xcls_PopoverFileDetails _this;
1017 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
1020 _this.dbmodel = this;
1021 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1025 // set gobject values
1028 // user defined functions
1029 public void loadData (Gee.ArrayList<string> data, string cur) {
1034 /// el.append(out iter);
1037 // el.set_value(iter, 0, "");
1038 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1040 el.append(out iter);
1043 el.set_value(iter, 0, "");
1044 el.set_value(iter, 1, "-- select a module --");
1045 _this.build_module.el.set_active_iter(iter);
1047 for (var i = 0; i < data.size;i++) {
1050 el.append(out iter);
1052 el.set_value(iter, 0, data.get(i));
1053 el.set_value(iter, 1, data.get(i));
1055 if (data.get(i) == cur) {
1056 _this.build_module.el.set_active_iter(iter);
1060 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1067 public class Xcls_Label29 : Object
1069 public Gtk.Label el;
1070 private Xcls_PopoverFileDetails _this;
1076 public Xcls_Label29(Xcls_PopoverFileDetails _owner )
1079 this.el = new Gtk.Label( "Module to build (Vala only)" );
1083 // set gobject values
1084 this.el.justify = Gtk.Justification.RIGHT;
1085 this.el.xalign = 0.900000f;
1086 this.el.visible = true;
1089 // user defined functions
1092 public class Xcls_HButtonBox30 : Object
1094 public Gtk.HButtonBox el;
1095 private Xcls_PopoverFileDetails _this;
1101 public Xcls_HButtonBox30(Xcls_PopoverFileDetails _owner )
1104 this.el = new Gtk.HButtonBox();
1108 // set gobject values
1109 this.el.margin_right = 4;
1110 this.el.margin_left = 4;
1111 this.el.margin_bottom = 4;
1112 var child_0 = new Xcls_Button31( _this );
1114 this.el.add ( child_0.el );
1115 var child_1 = new Xcls_save_btn( _this );
1117 this.el.add ( child_1.el );
1120 // user defined functions
1122 public class Xcls_Button31 : Object
1124 public Gtk.Button el;
1125 private Xcls_PopoverFileDetails _this;
1131 public Xcls_Button31(Xcls_PopoverFileDetails _owner )
1134 this.el = new Gtk.Button();
1138 // set gobject values
1139 this.el.label = "Cancel";
1142 this.el.clicked.connect( () => {
1149 // user defined functions
1152 public class Xcls_save_btn : Object
1154 public Gtk.Button el;
1155 private Xcls_PopoverFileDetails _this;
1161 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1164 _this.save_btn = this;
1165 this.el = new Gtk.Button();
1169 // set gobject values
1170 this.el.label = "Save";
1173 this.el.clicked.connect( ( ) => {
1178 if (_this.name.el.get_text().length < 1) {
1179 StandardErrorDialog.show(
1180 _this.mainwindow.el,
1181 "You have to set Component name "
1186 // what does this do?
1188 var isNew = _this.file.name.length > 0 ? false : true;
1190 if (!isNew && this.file.name != _this.name.el.get_text()) {
1191 Xcls_StandardErrorDialog.singleton().show(
1193 "Sorry changing names does not work yet. "
1202 // FIXME - this may be more complicated...
1203 //for (var i in this.def) {
1204 // this.file[i] = this.get(i).el.get_text();
1209 _this.updateFileFromEntry();
1210 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1211 Xcls_StandardErrorDialog.singleton().show(
1212 _this.mainwindow.el,
1213 "The name you used already exists "
1225 // ---------------- NEW FILES...
1227 var fn = _this.name.el.get_text();
1228 var dir = _this.project.firstPath(); // fixme.. should be based on a pulldown?
1230 var targetfile = dir + "/" + fn;
1232 // strip the file type off the end..
1235 if (!_this.filetype.el.get_active_iter(out iter)) {
1236 // should not happen...
1237 // so we are jut going to return without
1238 StandardErrorDialog.show(
1239 _this.mainwindow.el,
1240 "You must select a file type. "
1244 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1245 var ext = ((string)ftypename);
1247 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1248 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1250 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1251 Xcls_StandardErrorDialog.singleton().show(
1252 _this.mainwindow.el,
1253 "That file already exists"
1258 var f = JsRender.JsRender.factory(
1259 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1261 targetfile + "." + ext);
1267 _this.updateFileFromEntry();
1268 _this.file.loaded = true;
1271 _this.file.project.addFile(_this.file);
1279 // hopefull this will work with bjs files..
1281 _this.success(_this.project, _this.file);
1286 // user defined functions