1 static Xcls_DialogNewComponent _DialogNewComponent;
3 public class Xcls_DialogNewComponent : Object
6 private Xcls_DialogNewComponent _this;
8 public static Xcls_DialogNewComponent singleton()
10 if (_DialogNewComponent == null) {
11 _DialogNewComponent= new Xcls_DialogNewComponent();
13 return _DialogNewComponent;
15 public Xcls_name name;
16 public Xcls_title title;
17 public Xcls_region region;
18 public Xcls_parent parent;
19 public Xcls_permname permname;
20 public Xcls_modOrder modOrder;
21 public Xcls_build_module build_module;
22 public Xcls_dbcellrenderer dbcellrenderer;
23 public Xcls_dbmodel dbmodel;
26 public signal void success (Project.Project pr, JsRender.JsRender file);
27 public Project.Project project;
28 public JsRender.JsRender file;
31 public Xcls_DialogNewComponent()
34 this.el = new Gtk.Dialog();
40 this.el.title = "New Component";
41 this.el.default_height = 200;
42 this.el.default_width = 500;
43 this.el.deletable = true;
45 var child_0 = new Xcls_VBox2( _this );
47 this.el.get_content_area().add ( child_0.el );
48 var child_1 = new Xcls_Button20( _this );
50 this.el.add_action_widget ( child_1.el , 0 );
51 var child_2 = new Xcls_Button21( _this );
53 this.el.add_action_widget ( child_2.el , 1 );
56 this.el.delete_event.connect( (self, event) => {
61 this.el.response.connect( (self, response_id) => {
63 if (response_id < 1) { // cancel!
70 if (_this.name.el.get_text().length < 1) {
71 StandardErrorDialog.show(
73 "You have to set Component name "
80 var isNew = _this.file.name.length > 0 ? false : true;
82 if (!isNew && this.file.name != _this.name.el.get_text()) {
83 Xcls_StandardErrorDialog.singleton().show(
85 "Sorry changing names does not work yet. "
94 // FIXME - this may be more complicated...
95 //for (var i in this.def) {
96 // this.file[i] = this.get(i).el.get_text();
101 this.updateFileFromEntry();
102 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
103 Xcls_StandardErrorDialog.singleton().show(
105 "The name you used already exists "
116 var fn = this.name.el.get_text();
117 var dir = _this.project.firstPath();
119 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
120 Xcls_StandardErrorDialog.singleton().show(
122 "That file already exists"
127 var f = JsRender.JsRender.factory(
128 _this.file.project.xtype,
130 dir + "/" + fn + ".bjs");
136 this.updateFileFromEntry();
138 _this.file.project.addFile(_this.file);
146 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
148 //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
149 //for (var i in this.file) {
150 // nf[i] = this.file[i];
152 _this.success(_this.project, _this.file);
155 -- fixme -- needs to be a signal..
156 if (DialogNewComponent.success != null) {
157 DialogNewComponent.success(_this.project, nf);
161 this.el.show.connect( (self) => {
167 // user defined functions
168 public void updateFileFromEntry () {
170 _this.file.title = _this.title.el.get_text();
171 _this.file.region = _this.region.el.get_text();
172 _this.file.parent = _this.parent.el.get_text();
173 _this.file.permname = _this.permname.el.get_text();
174 _this.file.modOrder = _this.modOrder.el.get_text();
176 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
177 _this.file.renameTo(_this.name.el.get_text());
179 // store the module...
180 _this.file.build_module = "";
182 if (_this.build_module.el.get_active_iter (out iter)) {
184 this.dbmodel.el.get_value (iter, 0, out vfname);
185 if (((string)vfname).length > 0) {
186 _this.file.build_module = (string)vfname;
195 public void show (JsRender.JsRender c)
197 this.project = c.project;
203 _this.name.el.set_text(c.name);
204 _this.title.el.set_text(c.title);
205 _this.parent.el.set_text(c.parent);
206 _this.region.el.set_text(c.region);
207 _this.modOrder.el.set_text(c.modOrder);
208 _this.permname.el.set_text(c.permname);
210 if (c.path.length > 0) {
211 this.el.set_title("Edit File Details - " + c.name);
213 this.el.set_title("Create New File");
216 var ar = new Gee.ArrayList<string>();
217 _this.dbmodel.loadData(ar,"");
218 // load the modules... if relivant..
219 if (this.project.xtype == "Gtk") {
220 var p = (Project.Gtk)c.project;
221 var cg = p.compilegroups;
223 var iter = cg.map_iterator();
225 var key = iter.get_key();
226 if (key == "_default_") {
231 _this.dbmodel.loadData(ar, c.build_module);
237 //console.log('show all');
240 //this.success = c.success;
244 public class Xcls_VBox2 : Object
247 private Xcls_DialogNewComponent _this;
253 public Xcls_VBox2(Xcls_DialogNewComponent _owner )
256 this.el = new Gtk.VBox( true, 0 );
260 // set gobject values
261 var child_0 = new Xcls_Table3( _this );
263 this.el.pack_start ( child_0.el , false,false,0 );
266 // user defined functions
268 public class Xcls_Table3 : Object
271 private Xcls_DialogNewComponent _this;
277 public Xcls_Table3(Xcls_DialogNewComponent _owner )
280 this.el = new Gtk.Table( 3, 2, true );
284 // set gobject values
285 var child_0 = new Xcls_Label4( _this );
287 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
288 var child_1 = new Xcls_name( _this );
290 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
291 var child_2 = new Xcls_Label6( _this );
293 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
294 var child_3 = new Xcls_title( _this );
296 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
297 var child_4 = new Xcls_Label8( _this );
299 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
300 var child_5 = new Xcls_region( _this );
302 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
303 var child_6 = new Xcls_Label10( _this );
305 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
306 var child_7 = new Xcls_parent( _this );
308 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
309 var child_8 = new Xcls_Label12( _this );
311 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
312 var child_9 = new Xcls_permname( _this );
314 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
315 var child_10 = new Xcls_Label14( _this );
317 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
318 var child_11 = new Xcls_modOrder( _this );
320 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
321 var child_12 = new Xcls_Label16( _this );
323 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
324 var child_13 = new Xcls_build_module( _this );
326 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
329 // user defined functions
331 public class Xcls_Label4 : Object
334 private Xcls_DialogNewComponent _this;
340 public Xcls_Label4(Xcls_DialogNewComponent _owner )
343 this.el = new Gtk.Label( "Component Name" );
347 // set gobject values
348 this.el.justify = Gtk.Justification.RIGHT;
349 this.el.xalign = 0.900000f;
352 // user defined functions
354 public class Xcls_name : Object
357 private Xcls_DialogNewComponent _this;
363 public Xcls_name(Xcls_DialogNewComponent _owner )
367 this.el = new Gtk.Entry();
371 // set gobject values
372 this.el.visible = true;
375 // user defined functions
377 public class Xcls_Label6 : Object
380 private Xcls_DialogNewComponent _this;
386 public Xcls_Label6(Xcls_DialogNewComponent _owner )
389 this.el = new Gtk.Label( "Title" );
393 // set gobject values
394 this.el.justify = Gtk.Justification.RIGHT;
395 this.el.xalign = 0.900000f;
396 this.el.visible = true;
399 // user defined functions
401 public class Xcls_title : Object
404 private Xcls_DialogNewComponent _this;
410 public Xcls_title(Xcls_DialogNewComponent _owner )
414 this.el = new Gtk.Entry();
418 // set gobject values
419 this.el.visible = true;
422 // user defined functions
424 public class Xcls_Label8 : Object
427 private Xcls_DialogNewComponent _this;
433 public Xcls_Label8(Xcls_DialogNewComponent _owner )
436 this.el = new Gtk.Label( "Region" );
440 // set gobject values
441 this.el.justify = Gtk.Justification.RIGHT;
442 this.el.xalign = 0.900000f;
443 this.el.tooltip_text = "center, north, south, east, west";
444 this.el.visible = true;
447 // user defined functions
449 public class Xcls_region : Object
452 private Xcls_DialogNewComponent _this;
458 public Xcls_region(Xcls_DialogNewComponent _owner )
462 this.el = new Gtk.Entry();
466 // set gobject values
467 this.el.visible = true;
470 // user defined functions
472 public class Xcls_Label10 : Object
475 private Xcls_DialogNewComponent _this;
481 public Xcls_Label10(Xcls_DialogNewComponent _owner )
484 this.el = new Gtk.Label( "Parent Name" );
488 // set gobject values
489 this.el.justify = Gtk.Justification.RIGHT;
490 this.el.xalign = 0.900000f;
491 this.el.visible = true;
494 // user defined functions
496 public class Xcls_parent : Object
499 private Xcls_DialogNewComponent _this;
505 public Xcls_parent(Xcls_DialogNewComponent _owner )
509 this.el = new Gtk.Entry();
513 // set gobject values
514 this.el.visible = true;
517 // user defined functions
519 public class Xcls_Label12 : Object
522 private Xcls_DialogNewComponent _this;
528 public Xcls_Label12(Xcls_DialogNewComponent _owner )
531 this.el = new Gtk.Label( "Permission Name" );
535 // set gobject values
536 this.el.justify = Gtk.Justification.RIGHT;
537 this.el.xalign = 0.900000f;
538 this.el.visible = true;
541 // user defined functions
543 public class Xcls_permname : Object
546 private Xcls_DialogNewComponent _this;
552 public Xcls_permname(Xcls_DialogNewComponent _owner )
555 _this.permname = this;
556 this.el = new Gtk.Entry();
560 // set gobject values
561 this.el.visible = true;
564 // user defined functions
566 public class Xcls_Label14 : Object
569 private Xcls_DialogNewComponent _this;
575 public Xcls_Label14(Xcls_DialogNewComponent _owner )
578 this.el = new Gtk.Label( "Order (for tabs)" );
582 // set gobject values
583 this.el.justify = Gtk.Justification.RIGHT;
584 this.el.xalign = 0.900000f;
585 this.el.visible = true;
588 // user defined functions
590 public class Xcls_modOrder : Object
593 private Xcls_DialogNewComponent _this;
599 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
602 _this.modOrder = this;
603 this.el = new Gtk.Entry();
607 // set gobject values
608 this.el.visible = true;
611 // user defined functions
613 public class Xcls_Label16 : Object
616 private Xcls_DialogNewComponent _this;
622 public Xcls_Label16(Xcls_DialogNewComponent _owner )
625 this.el = new Gtk.Label( "Module to build (Vala only)" );
629 // set gobject values
630 this.el.justify = Gtk.Justification.RIGHT;
631 this.el.xalign = 0.900000f;
632 this.el.visible = true;
635 // user defined functions
637 public class Xcls_build_module : Object
639 public Gtk.ComboBox el;
640 private Xcls_DialogNewComponent _this;
646 public Xcls_build_module(Xcls_DialogNewComponent _owner )
649 _this.build_module = this;
650 this.el = new Gtk.ComboBox();
654 // set gobject values
655 var child_0 = new Xcls_dbcellrenderer( _this );
657 this.el.pack_start ( child_0.el , true );
658 var child_1 = new Xcls_dbmodel( _this );
660 this.el.set_model ( child_1.el );
664 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
667 // user defined functions
669 public class Xcls_dbcellrenderer : Object
671 public Gtk.CellRendererText el;
672 private Xcls_DialogNewComponent _this;
678 public Xcls_dbcellrenderer(Xcls_DialogNewComponent _owner )
681 _this.dbcellrenderer = this;
682 this.el = new Gtk.CellRendererText();
686 // set gobject values
689 // user defined functions
691 public class Xcls_dbmodel : Object
693 public Gtk.ListStore el;
694 private Xcls_DialogNewComponent _this;
700 public Xcls_dbmodel(Xcls_DialogNewComponent _owner )
703 _this.dbmodel = this;
704 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
708 // set gobject values
711 // user defined functions
712 public void loadData (Gee.ArrayList<string> data, string cur) {
717 /// el.append(out iter);
720 // el.set_value(iter, 0, "");
721 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
726 el.set_value(iter, 0, "");
727 el.set_value(iter, 1, "-- select a module --");
728 _this.build_module.el.set_active_iter(iter);
730 for (var i = 0; i < data.size;i++) {
735 el.set_value(iter, 0, data.get(i));
736 el.set_value(iter, 1, data.get(i));
738 if (data.get(i) == cur) {
739 _this.build_module.el.set_active_iter(iter);
743 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
747 public class Xcls_Button20 : Object
749 public Gtk.Button el;
750 private Xcls_DialogNewComponent _this;
756 public Xcls_Button20(Xcls_DialogNewComponent _owner )
759 this.el = new Gtk.Button();
763 // set gobject values
764 this.el.label = "Cancel";
767 // user defined functions
769 public class Xcls_Button21 : Object
771 public Gtk.Button el;
772 private Xcls_DialogNewComponent _this;
778 public Xcls_Button21(Xcls_DialogNewComponent _owner )
781 this.el = new Gtk.Button();
785 // set gobject values
786 this.el.label = "OK";
789 // user defined functions