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_Button18( _this );
48 this.el.add_action_widget ( child_1.el , 0 );
49 var child_2 = new Xcls_Button19( _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_modOrder( _this );
290 this.el.attach_defaults ( child_13.el , 1,2,5,6 );
293 // user defined functions
295 public class Xcls_Label4 : Object
298 private Xcls_DialogNewComponent _this;
304 public Xcls_Label4(Xcls_DialogNewComponent _owner )
307 this.el = new Gtk.Label( "Component Name" );
311 // set gobject values
312 this.el.justify = Gtk.Justification.RIGHT;
313 this.el.xalign = 0.900000f;
316 // user defined functions
318 public class Xcls_name : Object
321 private Xcls_DialogNewComponent _this;
327 public Xcls_name(Xcls_DialogNewComponent _owner )
331 this.el = new Gtk.Entry();
335 // set gobject values
336 this.el.visible = true;
339 // user defined functions
341 public class Xcls_Label6 : Object
344 private Xcls_DialogNewComponent _this;
350 public Xcls_Label6(Xcls_DialogNewComponent _owner )
353 this.el = new Gtk.Label( "Title" );
357 // set gobject values
358 this.el.justify = Gtk.Justification.RIGHT;
359 this.el.xalign = 0.900000f;
360 this.el.visible = true;
363 // user defined functions
365 public class Xcls_title : Object
368 private Xcls_DialogNewComponent _this;
374 public Xcls_title(Xcls_DialogNewComponent _owner )
378 this.el = new Gtk.Entry();
382 // set gobject values
383 this.el.visible = true;
386 // user defined functions
388 public class Xcls_Label8 : Object
391 private Xcls_DialogNewComponent _this;
397 public Xcls_Label8(Xcls_DialogNewComponent _owner )
400 this.el = new Gtk.Label( "Region" );
404 // set gobject values
405 this.el.justify = Gtk.Justification.RIGHT;
406 this.el.xalign = 0.900000f;
407 this.el.tooltip_text = "center, north, south, east, west";
408 this.el.visible = true;
411 // user defined functions
413 public class Xcls_region : Object
416 private Xcls_DialogNewComponent _this;
422 public Xcls_region(Xcls_DialogNewComponent _owner )
426 this.el = new Gtk.Entry();
430 // set gobject values
431 this.el.visible = true;
434 // user defined functions
436 public class Xcls_Label10 : Object
439 private Xcls_DialogNewComponent _this;
445 public Xcls_Label10(Xcls_DialogNewComponent _owner )
448 this.el = new Gtk.Label( "Parent Name" );
452 // set gobject values
453 this.el.justify = Gtk.Justification.RIGHT;
454 this.el.xalign = 0.900000f;
455 this.el.visible = true;
458 // user defined functions
460 public class Xcls_parent : Object
463 private Xcls_DialogNewComponent _this;
469 public Xcls_parent(Xcls_DialogNewComponent _owner )
473 this.el = new Gtk.Entry();
477 // set gobject values
478 this.el.visible = true;
481 // user defined functions
483 public class Xcls_Label12 : Object
486 private Xcls_DialogNewComponent _this;
492 public Xcls_Label12(Xcls_DialogNewComponent _owner )
495 this.el = new Gtk.Label( "Permission Name" );
499 // set gobject values
500 this.el.justify = Gtk.Justification.RIGHT;
501 this.el.xalign = 0.900000f;
502 this.el.visible = true;
505 // user defined functions
507 public class Xcls_permname : Object
510 private Xcls_DialogNewComponent _this;
516 public Xcls_permname(Xcls_DialogNewComponent _owner )
519 _this.permname = this;
520 this.el = new Gtk.Entry();
524 // set gobject values
525 this.el.visible = true;
528 // user defined functions
530 public class Xcls_Label14 : Object
533 private Xcls_DialogNewComponent _this;
539 public Xcls_Label14(Xcls_DialogNewComponent _owner )
542 this.el = new Gtk.Label( "Order (for tabs)" );
546 // set gobject values
547 this.el.justify = Gtk.Justification.RIGHT;
548 this.el.xalign = 0.900000f;
549 this.el.visible = true;
552 // user defined functions
554 public class Xcls_modOrder : Object
557 private Xcls_DialogNewComponent _this;
563 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
566 _this.modOrder = this;
567 this.el = new Gtk.Entry();
571 // set gobject values
572 this.el.visible = true;
575 // user defined functions
577 public class Xcls_Label16 : Object
580 private Xcls_DialogNewComponent _this;
586 public Xcls_Label16(Xcls_DialogNewComponent _owner )
589 this.el = new Gtk.Label( "Module to build (Vala only)" );
593 // set gobject values
594 this.el.justify = Gtk.Justification.RIGHT;
595 this.el.xalign = 0.900000f;
596 this.el.visible = true;
599 // user defined functions
601 public class Xcls_modOrder : Object
604 private Xcls_DialogNewComponent _this;
610 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
613 _this.modOrder = this;
614 this.el = new Gtk.Entry();
618 // set gobject values
619 this.el.visible = true;
622 // user defined functions
624 public class Xcls_Button18 : Object
626 public Gtk.Button el;
627 private Xcls_DialogNewComponent _this;
633 public Xcls_Button18(Xcls_DialogNewComponent _owner )
636 this.el = new Gtk.Button();
640 // set gobject values
641 this.el.label = "Cancel";
644 // user defined functions
646 public class Xcls_Button19 : Object
648 public Gtk.Button el;
649 private Xcls_DialogNewComponent _this;
655 public Xcls_Button19(Xcls_DialogNewComponent _owner )
658 this.el = new Gtk.Button();
662 // set gobject values
663 this.el.label = "OK";
666 // user defined functions