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_modOrder modOrder;
24 public signal void success (Project.Project pr, JsRender.JsRender file);
25 public Project.Project project;
26 public JsRender.JsRender file;
29 public Xcls_DialogNewComponent()
32 this.el = new Gtk.Dialog();
38 this.el.title = "New Component";
39 this.el.default_height = 200;
40 this.el.default_width = 500;
41 this.el.deletable = true;
43 var child_0 = new Xcls_VBox2( _this );
45 this.el.get_content_area().add ( child_0.el );
46 var child_1 = new Xcls_Button19( _this );
48 this.el.add_action_widget ( child_1.el , 0 );
49 var child_2 = new Xcls_Button20( _this );
51 this.el.add_action_widget ( child_2.el , 1 );
54 this.el.delete_event.connect( (self, event) => {
59 this.el.response.connect( (self, response_id) => {
61 if (response_id < 1) { // cancel!
68 if (_this.name.el.get_text().length < 1) {
69 StandardErrorDialog.show(
71 "You have to set Component name "
78 var isNew = _this.file.name.length > 0 ? false : true;
80 if (!isNew && this.file.name != _this.name.el.get_text()) {
81 Xcls_StandardErrorDialog.singleton().show(
83 "Sorry changing names does not work yet. "
92 // FIXME - this may be more complicated...
93 //for (var i in this.def) {
94 // this.file[i] = this.get(i).el.get_text();
99 this.updateFileFromEntry();
100 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
101 Xcls_StandardErrorDialog.singleton().show(
103 "The name you used already exists "
114 var fn = this.name.el.get_text();
115 var dir = _this.project.firstPath();
117 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
118 Xcls_StandardErrorDialog.singleton().show(
120 "That file already exists"
125 var f = JsRender.JsRender.factory(
126 _this.file.project.xtype,
128 dir + "/" + fn + ".bjs");
134 this.updateFileFromEntry();
136 _this.file.project.addFile(_this.file);
144 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
146 //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
147 //for (var i in this.file) {
148 // nf[i] = this.file[i];
150 _this.success(_this.project, _this.file);
153 -- fixme -- needs to be a signal..
154 if (DialogNewComponent.success != null) {
155 DialogNewComponent.success(_this.project, nf);
159 this.el.show.connect( (self) => {
165 // user defined functions
166 public void updateFileFromEntry () {
168 _this.file.title = _this.title.el.get_text();
169 _this.file.region = _this.region.el.get_text();
170 _this.file.parent = _this.parent.el.get_text();
171 _this.file.permname = _this.permname.el.get_text();
172 _this.file.modOrder = _this.modOrder.el.get_text();
174 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
175 _this.file.renameTo(_this.name.el.get_text());
179 public void show (JsRender.JsRender c)
181 this.project = c.project;
187 _this.name.el.set_text(c.name);
188 _this.title.el.set_text(c.title);
189 _this.parent.el.set_text(c.parent);
190 _this.region.el.set_text(c.region);
191 _this.modOrder.el.set_text(c.modOrder);
192 _this.permname.el.set_text(c.permname);
194 if (c.path.length > 0) {
195 this.el.set_title("Edit File Details - " + c.name);
197 this.el.set_title("Create New File");
201 //console.log('show all');
204 //this.success = c.success;
208 public class Xcls_VBox2 : Object
211 private Xcls_DialogNewComponent _this;
217 public Xcls_VBox2(Xcls_DialogNewComponent _owner )
220 this.el = new Gtk.VBox( true, 0 );
224 // set gobject values
225 var child_0 = new Xcls_Table3( _this );
227 this.el.pack_start ( child_0.el , false,false,0 );
230 // user defined functions
232 public class Xcls_Table3 : Object
235 private Xcls_DialogNewComponent _this;
241 public Xcls_Table3(Xcls_DialogNewComponent _owner )
244 this.el = new Gtk.Table( 3, 2, true );
248 // set gobject values
249 var child_0 = new Xcls_Label4( _this );
251 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
252 var child_1 = new Xcls_name( _this );
254 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
255 var child_2 = new Xcls_Label6( _this );
257 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
258 var child_3 = new Xcls_title( _this );
260 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
261 var child_4 = new Xcls_Label8( _this );
263 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
264 var child_5 = new Xcls_region( _this );
266 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
267 var child_6 = new Xcls_Label10( _this );
269 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
270 var child_7 = new Xcls_parent( _this );
272 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
273 var child_8 = new Xcls_Label12( _this );
275 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
276 var child_9 = new Xcls_permname( _this );
278 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
279 var child_10 = new Xcls_Label14( _this );
281 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
282 var child_11 = new Xcls_modOrder( _this );
284 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
285 var child_12 = new Xcls_Label16( _this );
287 this.el.attach_defaults ( child_12.el , 0,1,6,7 );
288 var child_13 = new Xcls_ComboBox17( _this );
290 this.el.attach_defaults ( child_13.el , 1,2,6,7 );
291 var child_14 = new Xcls_modOrder( _this );
293 this.el.attach_defaults ( child_14.el , 1,2,5,6 );
296 // user defined functions
298 public class Xcls_Label4 : Object
301 private Xcls_DialogNewComponent _this;
307 public Xcls_Label4(Xcls_DialogNewComponent _owner )
310 this.el = new Gtk.Label( "Component Name" );
314 // set gobject values
315 this.el.justify = Gtk.Justification.RIGHT;
316 this.el.xalign = 0.900000f;
319 // user defined functions
321 public class Xcls_name : Object
324 private Xcls_DialogNewComponent _this;
330 public Xcls_name(Xcls_DialogNewComponent _owner )
334 this.el = new Gtk.Entry();
338 // set gobject values
339 this.el.visible = true;
342 // user defined functions
344 public class Xcls_Label6 : Object
347 private Xcls_DialogNewComponent _this;
353 public Xcls_Label6(Xcls_DialogNewComponent _owner )
356 this.el = new Gtk.Label( "Title" );
360 // set gobject values
361 this.el.justify = Gtk.Justification.RIGHT;
362 this.el.xalign = 0.900000f;
363 this.el.visible = true;
366 // user defined functions
368 public class Xcls_title : Object
371 private Xcls_DialogNewComponent _this;
377 public Xcls_title(Xcls_DialogNewComponent _owner )
381 this.el = new Gtk.Entry();
385 // set gobject values
386 this.el.visible = true;
389 // user defined functions
391 public class Xcls_Label8 : Object
394 private Xcls_DialogNewComponent _this;
400 public Xcls_Label8(Xcls_DialogNewComponent _owner )
403 this.el = new Gtk.Label( "Region" );
407 // set gobject values
408 this.el.justify = Gtk.Justification.RIGHT;
409 this.el.xalign = 0.900000f;
410 this.el.tooltip_text = "center, north, south, east, west";
411 this.el.visible = true;
414 // user defined functions
416 public class Xcls_region : Object
419 private Xcls_DialogNewComponent _this;
425 public Xcls_region(Xcls_DialogNewComponent _owner )
429 this.el = new Gtk.Entry();
433 // set gobject values
434 this.el.visible = true;
437 // user defined functions
439 public class Xcls_Label10 : Object
442 private Xcls_DialogNewComponent _this;
448 public Xcls_Label10(Xcls_DialogNewComponent _owner )
451 this.el = new Gtk.Label( "Parent Name" );
455 // set gobject values
456 this.el.justify = Gtk.Justification.RIGHT;
457 this.el.xalign = 0.900000f;
458 this.el.visible = true;
461 // user defined functions
463 public class Xcls_parent : Object
466 private Xcls_DialogNewComponent _this;
472 public Xcls_parent(Xcls_DialogNewComponent _owner )
476 this.el = new Gtk.Entry();
480 // set gobject values
481 this.el.visible = true;
484 // user defined functions
486 public class Xcls_Label12 : Object
489 private Xcls_DialogNewComponent _this;
495 public Xcls_Label12(Xcls_DialogNewComponent _owner )
498 this.el = new Gtk.Label( "Permission Name" );
502 // set gobject values
503 this.el.justify = Gtk.Justification.RIGHT;
504 this.el.xalign = 0.900000f;
505 this.el.visible = true;
508 // user defined functions
510 public class Xcls_permname : Object
513 private Xcls_DialogNewComponent _this;
519 public Xcls_permname(Xcls_DialogNewComponent _owner )
522 _this.permname = this;
523 this.el = new Gtk.Entry();
527 // set gobject values
528 this.el.visible = true;
531 // user defined functions
533 public class Xcls_Label14 : Object
536 private Xcls_DialogNewComponent _this;
542 public Xcls_Label14(Xcls_DialogNewComponent _owner )
545 this.el = new Gtk.Label( "Order (for tabs)" );
549 // set gobject values
550 this.el.justify = Gtk.Justification.RIGHT;
551 this.el.xalign = 0.900000f;
552 this.el.visible = true;
555 // user defined functions
557 public class Xcls_modOrder : Object
560 private Xcls_DialogNewComponent _this;
566 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
569 _this.modOrder = this;
570 this.el = new Gtk.Entry();
574 // set gobject values
575 this.el.visible = true;
578 // user defined functions
580 public class Xcls_Label16 : Object
583 private Xcls_DialogNewComponent _this;
589 public Xcls_Label16(Xcls_DialogNewComponent _owner )
592 this.el = new Gtk.Label( "Module to build (Vala only)" );
596 // set gobject values
597 this.el.justify = Gtk.Justification.RIGHT;
598 this.el.xalign = 0.900000f;
599 this.el.visible = true;
602 // user defined functions
604 public class Xcls_ComboBox17 : Object
606 public Gtk.ComboBox el;
607 private Xcls_DialogNewComponent _this;
613 public Xcls_ComboBox17(Xcls_DialogNewComponent _owner )
616 this.el = new Gtk.ComboBox();
620 // set gobject values
623 // user defined functions
625 public class Xcls_modOrder : Object
628 private Xcls_DialogNewComponent _this;
634 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
637 _this.modOrder = this;
638 this.el = new Gtk.Entry();
642 // set gobject values
643 this.el.visible = true;
646 // user defined functions
648 public class Xcls_Button19 : Object
650 public Gtk.Button el;
651 private Xcls_DialogNewComponent _this;
657 public Xcls_Button19(Xcls_DialogNewComponent _owner )
660 this.el = new Gtk.Button();
664 // set gobject values
665 this.el.label = "Cancel";
668 // user defined functions
670 public class Xcls_Button20 : Object
672 public Gtk.Button el;
673 private Xcls_DialogNewComponent _this;
679 public Xcls_Button20(Xcls_DialogNewComponent _owner )
682 this.el = new Gtk.Button();
686 // set gobject values
687 this.el.label = "OK";
690 // user defined functions