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());
181 public void show (JsRender.JsRender c)
183 this.project = c.project;
189 _this.name.el.set_text(c.name);
190 _this.title.el.set_text(c.title);
191 _this.parent.el.set_text(c.parent);
192 _this.region.el.set_text(c.region);
193 _this.modOrder.el.set_text(c.modOrder);
194 _this.permname.el.set_text(c.permname);
196 if (c.path.length > 0) {
197 this.el.set_title("Edit File Details - " + c.name);
199 this.el.set_title("Create New File");
202 var ar = new Gee.ArrayList<string>();
203 _this.dbmodel.loadData(ar);
204 // load the modules... if relivant..
205 if (this.project.xtype == "Gtk") {
206 var p = (Project.Gtk)c.project;
207 var cg = p.compilegroups;
209 var iter = cg.map_iterator();
211 var key = iter.get_key();
212 if (key == "_default_") {
217 _this.dbmodel.loadData(ar);
223 //console.log('show all');
226 //this.success = c.success;
230 public class Xcls_VBox2 : Object
233 private Xcls_DialogNewComponent _this;
239 public Xcls_VBox2(Xcls_DialogNewComponent _owner )
242 this.el = new Gtk.VBox( true, 0 );
246 // set gobject values
247 var child_0 = new Xcls_Table3( _this );
249 this.el.pack_start ( child_0.el , false,false,0 );
252 // user defined functions
254 public class Xcls_Table3 : Object
257 private Xcls_DialogNewComponent _this;
263 public Xcls_Table3(Xcls_DialogNewComponent _owner )
266 this.el = new Gtk.Table( 3, 2, true );
270 // set gobject values
271 var child_0 = new Xcls_Label4( _this );
273 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
274 var child_1 = new Xcls_name( _this );
276 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
277 var child_2 = new Xcls_Label6( _this );
279 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
280 var child_3 = new Xcls_title( _this );
282 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
283 var child_4 = new Xcls_Label8( _this );
285 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
286 var child_5 = new Xcls_region( _this );
288 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
289 var child_6 = new Xcls_Label10( _this );
291 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
292 var child_7 = new Xcls_parent( _this );
294 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
295 var child_8 = new Xcls_Label12( _this );
297 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
298 var child_9 = new Xcls_permname( _this );
300 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
301 var child_10 = new Xcls_Label14( _this );
303 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
304 var child_11 = new Xcls_modOrder( _this );
306 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
307 var child_12 = new Xcls_Label16( _this );
309 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
310 var child_13 = new Xcls_build_module( _this );
312 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
315 // user defined functions
317 public class Xcls_Label4 : Object
320 private Xcls_DialogNewComponent _this;
326 public Xcls_Label4(Xcls_DialogNewComponent _owner )
329 this.el = new Gtk.Label( "Component Name" );
333 // set gobject values
334 this.el.justify = Gtk.Justification.RIGHT;
335 this.el.xalign = 0.900000f;
338 // user defined functions
340 public class Xcls_name : Object
343 private Xcls_DialogNewComponent _this;
349 public Xcls_name(Xcls_DialogNewComponent _owner )
353 this.el = new Gtk.Entry();
357 // set gobject values
358 this.el.visible = true;
361 // user defined functions
363 public class Xcls_Label6 : Object
366 private Xcls_DialogNewComponent _this;
372 public Xcls_Label6(Xcls_DialogNewComponent _owner )
375 this.el = new Gtk.Label( "Title" );
379 // set gobject values
380 this.el.justify = Gtk.Justification.RIGHT;
381 this.el.xalign = 0.900000f;
382 this.el.visible = true;
385 // user defined functions
387 public class Xcls_title : Object
390 private Xcls_DialogNewComponent _this;
396 public Xcls_title(Xcls_DialogNewComponent _owner )
400 this.el = new Gtk.Entry();
404 // set gobject values
405 this.el.visible = true;
408 // user defined functions
410 public class Xcls_Label8 : Object
413 private Xcls_DialogNewComponent _this;
419 public Xcls_Label8(Xcls_DialogNewComponent _owner )
422 this.el = new Gtk.Label( "Region" );
426 // set gobject values
427 this.el.justify = Gtk.Justification.RIGHT;
428 this.el.xalign = 0.900000f;
429 this.el.tooltip_text = "center, north, south, east, west";
430 this.el.visible = true;
433 // user defined functions
435 public class Xcls_region : Object
438 private Xcls_DialogNewComponent _this;
444 public Xcls_region(Xcls_DialogNewComponent _owner )
448 this.el = new Gtk.Entry();
452 // set gobject values
453 this.el.visible = true;
456 // user defined functions
458 public class Xcls_Label10 : Object
461 private Xcls_DialogNewComponent _this;
467 public Xcls_Label10(Xcls_DialogNewComponent _owner )
470 this.el = new Gtk.Label( "Parent Name" );
474 // set gobject values
475 this.el.justify = Gtk.Justification.RIGHT;
476 this.el.xalign = 0.900000f;
477 this.el.visible = true;
480 // user defined functions
482 public class Xcls_parent : Object
485 private Xcls_DialogNewComponent _this;
491 public Xcls_parent(Xcls_DialogNewComponent _owner )
495 this.el = new Gtk.Entry();
499 // set gobject values
500 this.el.visible = true;
503 // user defined functions
505 public class Xcls_Label12 : Object
508 private Xcls_DialogNewComponent _this;
514 public Xcls_Label12(Xcls_DialogNewComponent _owner )
517 this.el = new Gtk.Label( "Permission Name" );
521 // set gobject values
522 this.el.justify = Gtk.Justification.RIGHT;
523 this.el.xalign = 0.900000f;
524 this.el.visible = true;
527 // user defined functions
529 public class Xcls_permname : Object
532 private Xcls_DialogNewComponent _this;
538 public Xcls_permname(Xcls_DialogNewComponent _owner )
541 _this.permname = this;
542 this.el = new Gtk.Entry();
546 // set gobject values
547 this.el.visible = true;
550 // user defined functions
552 public class Xcls_Label14 : Object
555 private Xcls_DialogNewComponent _this;
561 public Xcls_Label14(Xcls_DialogNewComponent _owner )
564 this.el = new Gtk.Label( "Order (for tabs)" );
568 // set gobject values
569 this.el.justify = Gtk.Justification.RIGHT;
570 this.el.xalign = 0.900000f;
571 this.el.visible = true;
574 // user defined functions
576 public class Xcls_modOrder : Object
579 private Xcls_DialogNewComponent _this;
585 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
588 _this.modOrder = this;
589 this.el = new Gtk.Entry();
593 // set gobject values
594 this.el.visible = true;
597 // user defined functions
599 public class Xcls_Label16 : Object
602 private Xcls_DialogNewComponent _this;
608 public Xcls_Label16(Xcls_DialogNewComponent _owner )
611 this.el = new Gtk.Label( "Module to build (Vala only)" );
615 // set gobject values
616 this.el.justify = Gtk.Justification.RIGHT;
617 this.el.xalign = 0.900000f;
618 this.el.visible = true;
621 // user defined functions
623 public class Xcls_build_module : Object
625 public Gtk.ComboBox el;
626 private Xcls_DialogNewComponent _this;
632 public Xcls_build_module(Xcls_DialogNewComponent _owner )
635 _this.build_module = this;
636 this.el = new Gtk.ComboBox();
640 // set gobject values
641 var child_0 = new Xcls_dbcellrenderer( _this );
643 this.el.pack_start ( child_0.el , true );
644 var child_1 = new Xcls_dbmodel( _this );
646 this.el.set_model ( child_1.el );
650 this.el.add_attribute(_this.dbcellrenderer.el , "markup", 1 );
653 // user defined functions
655 public class Xcls_dbcellrenderer : Object
657 public Gtk.CellRendererText el;
658 private Xcls_DialogNewComponent _this;
664 public Xcls_dbcellrenderer(Xcls_DialogNewComponent _owner )
667 _this.dbcellrenderer = this;
668 this.el = new Gtk.CellRendererText();
672 // set gobject values
675 // user defined functions
677 public class Xcls_dbmodel : Object
679 public Gtk.ListStore el;
680 private Xcls_DialogNewComponent _this;
686 public Xcls_dbmodel(Xcls_DialogNewComponent _owner )
689 _this.dbmodel = this;
690 this.el = new Gtk.ListStore( 2, typeof(string),typeof(string) );
694 // set gobject values
697 // user defined functions
698 public void loadData (Gee.ArrayList<string> data) {
703 /// el.append(out iter);
706 // el.set_value(iter, 0, "");
707 // el.set_value(iter, 1, "aaa - Just add Element - aaa");
712 el.set_value(iter, 0, "");
713 el.set_value(iter, 1, "-- select a module --");
716 for (var i = 0; i < data.size;i++) {
721 el.set_value(iter, 0, data.get(i));
722 el.set_value(iter, 1, data.get(i));
725 this.el.set_sort_column_id(0, Gtk.SortType.ASCENDING);
729 public class Xcls_Button20 : Object
731 public Gtk.Button el;
732 private Xcls_DialogNewComponent _this;
738 public Xcls_Button20(Xcls_DialogNewComponent _owner )
741 this.el = new Gtk.Button();
745 // set gobject values
746 this.el.label = "Cancel";
749 // user defined functions
751 public class Xcls_Button21 : Object
753 public Gtk.Button el;
754 private Xcls_DialogNewComponent _this;
760 public Xcls_Button21(Xcls_DialogNewComponent _owner )
763 this.el = new Gtk.Button();
767 // set gobject values
768 this.el.label = "OK";
771 // user defined functions