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);
121 var ar = new Gee.ArrayList<string>();
122 _this.dbmodel.loadData(ar,"");
123 // load the modules... if relivant..
124 if (this.project.xtype == "Gtk") {
125 var p = (Project.Gtk)c.project;
126 var cg = p.compilegroups;
128 var iter = cg.map_iterator();
130 var key = iter.get_key();
131 if (key == "_default_") {
136 _this.dbmodel.loadData(ar, c.build_module);
142 //console.log('show all');
143 this.el.set_modal(true);
144 this.el.set_relative_to(btn);
146 this.el.set_position(Gtk.PositionType.RIGHT);
149 print("SHOWALL - POPIP\n");
151 this.name.el.grab_focus();
155 if (c.path.length > 0) {
156 this.save_btn.el.set_label("Save");
157 _this.filetype.el.hide();
158 _this.filetypelbl.el.hide();
159 _this.filetype.showhide(true); // as we only work on bjs files currently
161 this.save_btn.el.set_label("Create");
162 _this.ftdbmodel.loadData("bjs"); // fixme - need to determine type..
163 _this.filetype.el.show();
164 _this.filetypelbl.el.show();
168 //this.success = c.success;
172 public class Xcls_Box2 : Object
175 private Xcls_PopoverFileDetails _this;
181 public Xcls_Box2(Xcls_PopoverFileDetails _owner )
184 this.el = new Gtk.Box( Gtk.Orientation.VERTICAL, 0 );
188 // set gobject values
189 this.el.homogeneous = false;
190 var child_0 = new Xcls_HeaderBar3( _this );
192 this.el.pack_start ( child_0.el , false,true,0 );
193 var child_1 = new Xcls_grid( _this );
195 this.el.pack_start ( child_1.el , false,false,4 );
196 var child_2 = new Xcls_HButtonBox29( _this );
198 this.el.pack_end ( child_2.el , false,true,0 );
201 // user defined functions
203 public class Xcls_HeaderBar3 : Object
205 public Gtk.HeaderBar el;
206 private Xcls_PopoverFileDetails _this;
212 public Xcls_HeaderBar3(Xcls_PopoverFileDetails _owner )
215 this.el = new Gtk.HeaderBar();
219 // set gobject values
220 this.el.title = "Add / Edit File";
223 // user defined functions
226 public class Xcls_grid : Object
229 private Xcls_PopoverFileDetails _this;
235 public Xcls_grid(Xcls_PopoverFileDetails _owner )
239 this.el = new Gtk.Grid();
243 // set gobject values
244 this.el.margin_right = 4;
245 this.el.margin_left = 4;
246 this.el.row_spacing = 2;
247 var child_0 = new Xcls_filetypelbl( _this );
249 this.el.attach ( child_0.el , 0,0,1,1 );
250 var child_1 = new Xcls_filetype( _this );
252 this.el.attach ( child_1.el , 1,0,1,1 );
253 var child_2 = new Xcls_Label9( _this );
255 this.el.attach ( child_2.el , 0,1,1,1 );
256 var child_3 = new Xcls_name( _this );
258 this.el.attach ( child_3.el , 1,1,1,1 );
259 var child_4 = new Xcls_Label11( _this );
261 this.el.attach ( child_4.el , 0,2,1,1 );
262 var child_5 = new Xcls_title( _this );
264 this.el.attach ( child_5.el , 1,2,1,1 );
265 var child_6 = new Xcls_Label13( _this );
267 this.el.attach ( child_6.el , 0,3,1,1 );
268 var child_7 = new Xcls_region( _this );
270 this.el.attach ( child_7.el , 1,3,1,1 );
271 var child_8 = new Xcls_Label15( _this );
273 this.el.attach ( child_8.el , 0,4,1,1 );
274 var child_9 = new Xcls_parent( _this );
276 this.el.attach ( child_9.el , 1,4,1,1 );
277 var child_10 = new Xcls_Label17( _this );
279 this.el.attach ( child_10.el , 0,5,1,1 );
280 var child_11 = new Xcls_permname( _this );
282 this.el.attach ( child_11.el , 1,5,1,1 );
283 var child_12 = new Xcls_Label19( _this );
285 this.el.attach ( child_12.el , 0,6,1,1 );
286 var child_13 = new Xcls_modOrder( _this );
288 this.el.attach ( child_13.el , 1,6,1,1 );
289 var child_14 = new Xcls_Label21( _this );
291 this.el.attach ( child_14.el , 0,7,1,1 );
292 var child_15 = new Xcls_build_module( _this );
294 this.el.attach ( child_15.el , 1,7,1,1 );
295 var child_16 = new Xcls_Label25( _this );
297 this.el.attach ( child_16.el , 0,8,1,1 );
298 var child_17 = new Xcls_dir( _this );
300 this.el.attach ( child_17.el , 1,8,1,1 );
303 // user defined functions
305 public class Xcls_filetypelbl : Object
308 private Xcls_PopoverFileDetails _this;
314 public Xcls_filetypelbl(Xcls_PopoverFileDetails _owner )
317 _this.filetypelbl = this;
318 this.el = new Gtk.Label( "File type" );
322 // set gobject values
323 this.el.justify = Gtk.Justification.RIGHT;
324 this.el.xalign = 0.900000f;
327 // user defined functions
330 public class Xcls_filetype : Object
332 public Gtk.ComboBox el;
333 private Xcls_PopoverFileDetails _this;
339 public Xcls_filetype(Xcls_PopoverFileDetails _owner )
342 _this.filetype = this;
343 this.el = new Gtk.ComboBox();
347 // set gobject values
348 var child_0 = new Xcls_ftdbcellrenderer( _this );
350 this.el.pack_start ( child_0.el , true );
351 var child_1 = new Xcls_ftdbmodel( _this );
353 this.el.set_model ( child_1.el );
357 this.el.add_attribute(_this.ftdbcellrenderer.el , "markup", 1 );
360 this.el.changed.connect( () => {
363 if (this.el.get_active_iter(out iter)) {
365 _this.ftdbmodel.el.get_value (iter, 0, out vfname);
366 is_bjs = ((string)vfname) == "bjs";
370 // directory is only available for non-bjs
371 this.showhide(is_bjs);
377 // user defined functions
378 public void showhide (bool is_bjs) {
381 if (_this.project.xtype != "Roo") {
385 for (var i = 2; i < 9;i++) {
386 var el = _this.grid.el.get_child_at(0,i);
388 var showhide= is_bjs;
390 showhide = !showhide;
398 el = _this.grid.el.get_child_at(1,i);
405 // load up the directories
406 //??? why can we not create bjs files in other directories??
407 //if (!is_bjs && _this.file.path.length < 1) {
409 _this.dirmodel.loadData();
417 public class Xcls_ftdbcellrenderer : Object
419 public Gtk.CellRendererText el;
420 private Xcls_PopoverFileDetails _this;
426 public Xcls_ftdbcellrenderer(Xcls_PopoverFileDetails _owner )
429 _this.ftdbcellrenderer = this;
430 this.el = new Gtk.CellRendererText();
434 // set gobject values
437 // user defined functions
440 public class Xcls_ftdbmodel : Object
442 public Gtk.ListStore el;
443 private Xcls_PopoverFileDetails _this;
449 public Xcls_ftdbmodel(Xcls_PopoverFileDetails _owner )
452 _this.ftdbmodel = this;
453 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
457 // set gobject values
460 // user defined functions
461 public void loadData (string cur) {
466 /// el.append(out iter);
469 // el.set_value(iter, 0, "");
470 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
475 el.set_value(iter, 0, "bjs");
476 el.set_value(iter, 1, "User Interface File (bjs)");
477 _this.filetype.el.set_active_iter(iter);
481 el.set_value(iter, 0, "vala");
482 el.set_value(iter, 1, "Vala");
484 _this.filetype.el.set_active_iter(iter);
491 el.set_value(iter, 0, "js");
492 el.set_value(iter, 1, "Javascript");
495 _this.filetype.el.set_active_iter(iter);
500 el.set_value(iter, 0, "css");
501 el.set_value(iter, 1, "CSS");
504 _this.filetype.el.set_active_iter(iter);
511 public class Xcls_Label9 : Object
514 private Xcls_PopoverFileDetails _this;
520 public Xcls_Label9(Xcls_PopoverFileDetails _owner )
523 this.el = new Gtk.Label( "Component Name" );
527 // set gobject values
528 this.el.justify = Gtk.Justification.RIGHT;
529 this.el.xalign = 0.900000f;
532 // user defined functions
535 public class Xcls_name : Object
538 private Xcls_PopoverFileDetails _this;
544 public Xcls_name(Xcls_PopoverFileDetails _owner )
548 this.el = new Gtk.Entry();
552 // set gobject values
553 this.el.visible = true;
556 // user defined functions
559 public class Xcls_Label11 : Object
562 private Xcls_PopoverFileDetails _this;
568 public Xcls_Label11(Xcls_PopoverFileDetails _owner )
571 this.el = new Gtk.Label( "Title" );
575 // set gobject values
576 this.el.justify = Gtk.Justification.RIGHT;
577 this.el.xalign = 0.900000f;
578 this.el.visible = true;
581 // user defined functions
584 public class Xcls_title : Object
587 private Xcls_PopoverFileDetails _this;
593 public Xcls_title(Xcls_PopoverFileDetails _owner )
597 this.el = new Gtk.Entry();
601 // set gobject values
602 this.el.visible = true;
605 // user defined functions
608 public class Xcls_Label13 : Object
611 private Xcls_PopoverFileDetails _this;
617 public Xcls_Label13(Xcls_PopoverFileDetails _owner )
620 this.el = new Gtk.Label( "Region" );
624 // set gobject values
625 this.el.justify = Gtk.Justification.RIGHT;
626 this.el.xalign = 0.900000f;
627 this.el.tooltip_text = "center, north, south, east, west";
628 this.el.visible = true;
631 // user defined functions
634 public class Xcls_region : Object
637 private Xcls_PopoverFileDetails _this;
643 public Xcls_region(Xcls_PopoverFileDetails _owner )
647 this.el = new Gtk.Entry();
651 // set gobject values
652 this.el.visible = true;
655 // user defined functions
658 public class Xcls_Label15 : Object
661 private Xcls_PopoverFileDetails _this;
667 public Xcls_Label15(Xcls_PopoverFileDetails _owner )
670 this.el = new Gtk.Label( "Parent Name" );
674 // set gobject values
675 this.el.justify = Gtk.Justification.RIGHT;
676 this.el.xalign = 0.900000f;
677 this.el.visible = true;
680 // user defined functions
683 public class Xcls_parent : Object
686 private Xcls_PopoverFileDetails _this;
692 public Xcls_parent(Xcls_PopoverFileDetails _owner )
696 this.el = new Gtk.Entry();
700 // set gobject values
701 this.el.visible = true;
704 // user defined functions
707 public class Xcls_Label17 : Object
710 private Xcls_PopoverFileDetails _this;
716 public Xcls_Label17(Xcls_PopoverFileDetails _owner )
719 this.el = new Gtk.Label( "Permission Name" );
723 // set gobject values
724 this.el.justify = Gtk.Justification.RIGHT;
725 this.el.xalign = 0.900000f;
726 this.el.visible = true;
729 // user defined functions
732 public class Xcls_permname : Object
735 private Xcls_PopoverFileDetails _this;
741 public Xcls_permname(Xcls_PopoverFileDetails _owner )
744 _this.permname = this;
745 this.el = new Gtk.Entry();
749 // set gobject values
750 this.el.visible = true;
753 // user defined functions
756 public class Xcls_Label19 : Object
759 private Xcls_PopoverFileDetails _this;
765 public Xcls_Label19(Xcls_PopoverFileDetails _owner )
768 this.el = new Gtk.Label( "Order (for tabs)" );
772 // set gobject values
773 this.el.justify = Gtk.Justification.RIGHT;
774 this.el.xalign = 0.900000f;
775 this.el.visible = true;
778 // user defined functions
781 public class Xcls_modOrder : Object
784 private Xcls_PopoverFileDetails _this;
790 public Xcls_modOrder(Xcls_PopoverFileDetails _owner )
793 _this.modOrder = this;
794 this.el = new Gtk.Entry();
798 // set gobject values
799 this.el.visible = true;
802 // user defined functions
805 public class Xcls_Label21 : Object
808 private Xcls_PopoverFileDetails _this;
814 public Xcls_Label21(Xcls_PopoverFileDetails _owner )
817 this.el = new Gtk.Label( "Module to build (Vala only)" );
821 // set gobject values
822 this.el.justify = Gtk.Justification.RIGHT;
823 this.el.xalign = 0.900000f;
824 this.el.visible = true;
827 // user defined functions
830 public class Xcls_build_module : Object
832 public Gtk.ComboBox el;
833 private Xcls_PopoverFileDetails _this;
839 public Xcls_build_module(Xcls_PopoverFileDetails _owner )
842 _this.build_module = this;
843 this.el = new Gtk.ComboBox();
847 // set gobject values
848 var child_0 = new Xcls_dbcellrenderer( _this );
850 this.el.pack_start ( child_0.el , true );
851 var child_1 = new Xcls_dbmodel( _this );
853 this.el.set_model ( child_1.el );
857 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
860 // user defined functions
862 public class Xcls_dbcellrenderer : Object
864 public Gtk.CellRendererText el;
865 private Xcls_PopoverFileDetails _this;
871 public Xcls_dbcellrenderer(Xcls_PopoverFileDetails _owner )
874 _this.dbcellrenderer = this;
875 this.el = new Gtk.CellRendererText();
879 // set gobject values
882 // user defined functions
885 public class Xcls_dbmodel : Object
887 public Gtk.ListStore el;
888 private Xcls_PopoverFileDetails _this;
894 public Xcls_dbmodel(Xcls_PopoverFileDetails _owner )
897 _this.dbmodel = this;
898 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
902 // set gobject values
905 // user defined functions
906 public void loadData (Gee.ArrayList<string> data, string cur) {
911 /// el.append(out iter);
914 // el.set_value(iter, 0, "");
915 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
920 el.set_value(iter, 0, "");
921 el.set_value(iter, 1, "-- select a module --");
922 _this.build_module.el.set_active_iter(iter);
924 for (var i = 0; i < data.size;i++) {
929 el.set_value(iter, 0, data.get(i));
930 el.set_value(iter, 1, data.get(i));
932 if (data.get(i) == cur) {
933 _this.build_module.el.set_active_iter(iter);
937 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
943 public class Xcls_Label25 : Object
946 private Xcls_PopoverFileDetails _this;
952 public Xcls_Label25(Xcls_PopoverFileDetails _owner )
955 this.el = new Gtk.Label( "Directory" );
959 // set gobject values
960 this.el.justify = Gtk.Justification.RIGHT;
961 this.el.xalign = 0.900000f;
962 this.el.visible = true;
965 // user defined functions
968 public class Xcls_dir : Object
970 public Gtk.ComboBox el;
971 private Xcls_PopoverFileDetails _this;
977 public Xcls_dir(Xcls_PopoverFileDetails _owner )
981 this.el = new Gtk.ComboBox();
985 // set gobject values
986 var child_0 = new Xcls_dircellrenderer( _this );
988 this.el.pack_start ( child_0.el , true );
989 var child_1 = new Xcls_dirmodel( _this );
991 this.el.set_model ( child_1.el );
995 this.el.add_attribute(_this.dircellrenderer.el , "markup", 1 );
998 // user defined functions
1000 public class Xcls_dircellrenderer : Object
1002 public Gtk.CellRendererText el;
1003 private Xcls_PopoverFileDetails _this;
1009 public Xcls_dircellrenderer(Xcls_PopoverFileDetails _owner )
1012 _this.dircellrenderer = this;
1013 this.el = new Gtk.CellRendererText();
1017 // set gobject values
1020 // user defined functions
1023 public class Xcls_dirmodel : Object
1025 public Gtk.ListStore el;
1026 private Xcls_PopoverFileDetails _this;
1032 public Xcls_dirmodel(Xcls_PopoverFileDetails _owner )
1035 _this.dirmodel = this;
1036 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
1040 // set gobject values
1043 // user defined functions
1044 public void loadData () {
1050 if (!(_this.project is Project.Gtk)) {
1053 var sd = ((Project.Gtk)_this.project).sourcedirs();
1058 /// el.append(out iter);
1061 // el.set_value(iter, 0, "");
1062 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
1064 // el.append(out iter);
1067 // el.set_value(iter, 0, "");
1068 // el.set_value(iter, 1, "-- select a directoyr --");
1069 //_this.build_module.el.set_active_iter(iter);
1071 for (var i = 0; i < sd.length;i++) {
1074 el.append(out iter);
1076 el.set_value(iter, 0, sd[i]);
1077 el.set_value(iter, 1, sd[i]);
1079 //if (data.get(i) == cur) {
1080 // _this.build_module.el.set_active_iter(iter);
1084 // this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
1091 public class Xcls_HButtonBox29 : Object
1093 public Gtk.HButtonBox el;
1094 private Xcls_PopoverFileDetails _this;
1100 public Xcls_HButtonBox29(Xcls_PopoverFileDetails _owner )
1103 this.el = new Gtk.HButtonBox();
1107 // set gobject values
1108 this.el.margin_right = 4;
1109 this.el.margin_left = 4;
1110 this.el.margin_bottom = 4;
1111 var child_0 = new Xcls_Button30( _this );
1113 this.el.add ( child_0.el );
1114 var child_1 = new Xcls_save_btn( _this );
1116 this.el.add ( child_1.el );
1119 // user defined functions
1121 public class Xcls_Button30 : Object
1123 public Gtk.Button el;
1124 private Xcls_PopoverFileDetails _this;
1130 public Xcls_Button30(Xcls_PopoverFileDetails _owner )
1133 this.el = new Gtk.Button();
1137 // set gobject values
1138 this.el.label = "Cancel";
1141 this.el.clicked.connect( () => {
1148 // user defined functions
1151 public class Xcls_save_btn : Object
1153 public Gtk.Button el;
1154 private Xcls_PopoverFileDetails _this;
1160 public Xcls_save_btn(Xcls_PopoverFileDetails _owner )
1163 _this.save_btn = this;
1164 this.el = new Gtk.Button();
1168 // set gobject values
1169 this.el.label = "Save";
1172 this.el.clicked.connect( ( ) => {
1177 if (_this.name.el.get_text().length < 1) {
1178 StandardErrorDialog.show(
1179 _this.mainwindow.el,
1180 "You have to set Component name "
1185 // what does this do?
1187 var isNew = _this.file.name.length > 0 ? false : true;
1189 if (!isNew && this.file.name != _this.name.el.get_text()) {
1190 Xcls_StandardErrorDialog.singleton().show(
1192 "Sorry changing names does not work yet. "
1201 // FIXME - this may be more complicated...
1202 //for (var i in this.def) {
1203 // this.file[i] = this.get(i).el.get_text();
1208 _this.updateFileFromEntry();
1209 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
1210 Xcls_StandardErrorDialog.singleton().show(
1211 _this.mainwindow.el,
1212 "The name you used already exists "
1224 // ---------------- NEW FILES...
1227 if (!_this.filetype.el.get_active_iter(out iter)) {
1228 // should not happen...
1229 // so we are jut going to return without
1230 StandardErrorDialog.show(
1231 _this.mainwindow.el,
1232 "You must select a file type. "
1239 var fn = _this.name.el.get_text();
1242 _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
1243 var ext = ((string)ftypename);
1244 var dir = _this.project.firstPath();
1247 if (!_this.dir.el.get_active_iter(out iter)) {
1248 // should not happen...
1249 // so we are jut going to return without
1250 StandardErrorDialog.show(
1251 _this.mainwindow.el,
1252 "You must select a directory "
1257 _this.dirmodel.el.get_value (iter, 0, out vdir);
1261 var targetfile = dir + "/" + fn;
1263 // strip the file type off the end..
1266 var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
1267 targetfile = rx.replace(targetfile, targetfile.length, 0, "");
1269 if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
1270 Xcls_StandardErrorDialog.singleton().show(
1271 _this.mainwindow.el,
1272 "That file already exists"
1277 var f = JsRender.JsRender.factory(
1278 ext == "bjs" ? _this.file.project.xtype : "PlainFile",
1280 targetfile + "." + ext);
1286 _this.updateFileFromEntry();
1287 _this.file.loaded = true;
1290 _this.file.project.addFile(_this.file);
1298 // hopefull this will work with bjs files..
1300 _this.success(_this.project, _this.file);
1305 // user defined functions