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 = "";
181 if (_this.build_module.el.get_active_iter (out iter)) {
183 this.dbmodel.el.get_value (iter, 0, out vfname);
184 if (((string)vfname).length > 0) {
185 _this.file.build_module = (string)vfname;
194 public void show (JsRender.JsRender c)
196 this.project = c.project;
202 _this.name.el.set_text(c.name);
203 _this.title.el.set_text(c.title);
204 _this.parent.el.set_text(c.parent);
205 _this.region.el.set_text(c.region);
206 _this.modOrder.el.set_text(c.modOrder);
207 _this.permname.el.set_text(c.permname);
209 if (c.path.length > 0) {
210 this.el.set_title("Edit File Details - " + c.name);
212 this.el.set_title("Create New File");
215 var ar = new Gee.ArrayList<string>();
216 _this.dbmodel.loadData(ar);
217 // load the modules... if relivant..
218 if (this.project.xtype == "Gtk") {
219 var p = (Project.Gtk)c.project;
220 var cg = p.compilegroups;
222 var iter = cg.map_iterator();
224 var key = iter.get_key();
225 if (key == "_default_") {
230 _this.dbmodel.loadData(ar);
236 //console.log('show all');
239 //this.success = c.success;
243 public class Xcls_VBox2 : Object
246 private Xcls_DialogNewComponent _this;
252 public Xcls_VBox2(Xcls_DialogNewComponent _owner )
255 this.el = new Gtk.VBox( true, 0 );
259 // set gobject values
260 var child_0 = new Xcls_Table3( _this );
262 this.el.pack_start ( child_0.el , false,false,0 );
265 // user defined functions
267 public class Xcls_Table3 : Object
270 private Xcls_DialogNewComponent _this;
276 public Xcls_Table3(Xcls_DialogNewComponent _owner )
279 this.el = new Gtk.Table( 3, 2, true );
283 // set gobject values
284 var child_0 = new Xcls_Label4( _this );
286 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
287 var child_1 = new Xcls_name( _this );
289 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
290 var child_2 = new Xcls_Label6( _this );
292 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
293 var child_3 = new Xcls_title( _this );
295 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
296 var child_4 = new Xcls_Label8( _this );
298 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
299 var child_5 = new Xcls_region( _this );
301 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
302 var child_6 = new Xcls_Label10( _this );
304 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
305 var child_7 = new Xcls_parent( _this );
307 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
308 var child_8 = new Xcls_Label12( _this );
310 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
311 var child_9 = new Xcls_permname( _this );
313 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
314 var child_10 = new Xcls_Label14( _this );
316 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
317 var child_11 = new Xcls_modOrder( _this );
319 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
320 var child_12 = new Xcls_Label16( _this );
322 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
323 var child_13 = new Xcls_build_module( _this );
325 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
328 // user defined functions
330 public class Xcls_Label4 : Object
333 private Xcls_DialogNewComponent _this;
339 public Xcls_Label4(Xcls_DialogNewComponent _owner )
342 this.el = new Gtk.Label( "Component Name" );
346 // set gobject values
347 this.el.justify = Gtk.Justification.RIGHT;
348 this.el.xalign = 0.900000f;
351 // user defined functions
353 public class Xcls_name : Object
356 private Xcls_DialogNewComponent _this;
362 public Xcls_name(Xcls_DialogNewComponent _owner )
366 this.el = new Gtk.Entry();
370 // set gobject values
371 this.el.visible = true;
374 // user defined functions
376 public class Xcls_Label6 : Object
379 private Xcls_DialogNewComponent _this;
385 public Xcls_Label6(Xcls_DialogNewComponent _owner )
388 this.el = new Gtk.Label( "Title" );
392 // set gobject values
393 this.el.justify = Gtk.Justification.RIGHT;
394 this.el.xalign = 0.900000f;
395 this.el.visible = true;
398 // user defined functions
400 public class Xcls_title : Object
403 private Xcls_DialogNewComponent _this;
409 public Xcls_title(Xcls_DialogNewComponent _owner )
413 this.el = new Gtk.Entry();
417 // set gobject values
418 this.el.visible = true;
421 // user defined functions
423 public class Xcls_Label8 : Object
426 private Xcls_DialogNewComponent _this;
432 public Xcls_Label8(Xcls_DialogNewComponent _owner )
435 this.el = new Gtk.Label( "Region" );
439 // set gobject values
440 this.el.justify = Gtk.Justification.RIGHT;
441 this.el.xalign = 0.900000f;
442 this.el.tooltip_text = "center, north, south, east, west";
443 this.el.visible = true;
446 // user defined functions
448 public class Xcls_region : Object
451 private Xcls_DialogNewComponent _this;
457 public Xcls_region(Xcls_DialogNewComponent _owner )
461 this.el = new Gtk.Entry();
465 // set gobject values
466 this.el.visible = true;
469 // user defined functions
471 public class Xcls_Label10 : Object
474 private Xcls_DialogNewComponent _this;
480 public Xcls_Label10(Xcls_DialogNewComponent _owner )
483 this.el = new Gtk.Label( "Parent Name" );
487 // set gobject values
488 this.el.justify = Gtk.Justification.RIGHT;
489 this.el.xalign = 0.900000f;
490 this.el.visible = true;
493 // user defined functions
495 public class Xcls_parent : Object
498 private Xcls_DialogNewComponent _this;
504 public Xcls_parent(Xcls_DialogNewComponent _owner )
508 this.el = new Gtk.Entry();
512 // set gobject values
513 this.el.visible = true;
516 // user defined functions
518 public class Xcls_Label12 : Object
521 private Xcls_DialogNewComponent _this;
527 public Xcls_Label12(Xcls_DialogNewComponent _owner )
530 this.el = new Gtk.Label( "Permission Name" );
534 // set gobject values
535 this.el.justify = Gtk.Justification.RIGHT;
536 this.el.xalign = 0.900000f;
537 this.el.visible = true;
540 // user defined functions
542 public class Xcls_permname : Object
545 private Xcls_DialogNewComponent _this;
551 public Xcls_permname(Xcls_DialogNewComponent _owner )
554 _this.permname = this;
555 this.el = new Gtk.Entry();
559 // set gobject values
560 this.el.visible = true;
563 // user defined functions
565 public class Xcls_Label14 : Object
568 private Xcls_DialogNewComponent _this;
574 public Xcls_Label14(Xcls_DialogNewComponent _owner )
577 this.el = new Gtk.Label( "Order (for tabs)" );
581 // set gobject values
582 this.el.justify = Gtk.Justification.RIGHT;
583 this.el.xalign = 0.900000f;
584 this.el.visible = true;
587 // user defined functions
589 public class Xcls_modOrder : Object
592 private Xcls_DialogNewComponent _this;
598 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
601 _this.modOrder = this;
602 this.el = new Gtk.Entry();
606 // set gobject values
607 this.el.visible = true;
610 // user defined functions
612 public class Xcls_Label16 : Object
615 private Xcls_DialogNewComponent _this;
621 public Xcls_Label16(Xcls_DialogNewComponent _owner )
624 this.el = new Gtk.Label( "Module to build (Vala only)" );
628 // set gobject values
629 this.el.justify = Gtk.Justification.RIGHT;
630 this.el.xalign = 0.900000f;
631 this.el.visible = true;
634 // user defined functions
636 public class Xcls_build_module : Object
638 public Gtk.ComboBox el;
639 private Xcls_DialogNewComponent _this;
645 public Xcls_build_module(Xcls_DialogNewComponent _owner )
648 _this.build_module = this;
649 this.el = new Gtk.ComboBox();
653 // set gobject values
654 var child_0 = new Xcls_dbcellrenderer( _this );
656 this.el.pack_start ( child_0.el , true );
657 var child_1 = new Xcls_dbmodel( _this );
659 this.el.set_model ( child_1.el );
663 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
666 // user defined functions
668 public class Xcls_dbcellrenderer : Object
670 public Gtk.CellRendererText el;
671 private Xcls_DialogNewComponent _this;
677 public Xcls_dbcellrenderer(Xcls_DialogNewComponent _owner )
680 _this.dbcellrenderer = this;
681 this.el = new Gtk.CellRendererText();
685 // set gobject values
688 // user defined functions
690 public class Xcls_dbmodel : Object
692 public Gtk.ListStore el;
693 private Xcls_DialogNewComponent _this;
699 public Xcls_dbmodel(Xcls_DialogNewComponent _owner )
702 _this.dbmodel = this;
703 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
707 // set gobject values
710 // user defined functions
711 public void loadData (Gee.ArrayList<string> data) {
716 /// el.append(out iter);
719 // el.set_value(iter, 0, "");
720 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
725 el.set_value(iter, 0, "");
726 el.set_value(iter, 1, "-- select a module --");
729 for (var i = 0; i < data.size;i++) {
734 el.set_value(iter, 0, data.get(i));
735 el.set_value(iter, 1, data.get(i));
738 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
742 public class Xcls_Button20 : Object
744 public Gtk.Button el;
745 private Xcls_DialogNewComponent _this;
751 public Xcls_Button20(Xcls_DialogNewComponent _owner )
754 this.el = new Gtk.Button();
758 // set gobject values
759 this.el.label = "Cancel";
762 // user defined functions
764 public class Xcls_Button21 : Object
766 public Gtk.Button el;
767 private Xcls_DialogNewComponent _this;
773 public Xcls_Button21(Xcls_DialogNewComponent _owner )
776 this.el = new Gtk.Button();
780 // set gobject values
781 this.el.label = "OK";
784 // user defined functions