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;
23 public signal void success (Project.Project pr, JsRender.JsRender file);
24 public Project.Project project;
25 public JsRender.JsRender file;
28 public Xcls_DialogNewComponent()
31 this.el = new Gtk.Dialog();
37 this.el.title = "New Component";
38 this.el.default_height = 200;
39 this.el.default_width = 500;
40 this.el.deletable = true;
42 var child_0 = new Xcls_VBox2( _this );
44 this.el.get_content_area().add ( child_0.el );
45 var child_1 = new Xcls_Button16( _this );
47 this.el.add_action_widget ( child_1.el , 0 );
48 var child_2 = new Xcls_Button17( _this );
50 this.el.add_action_widget ( child_2.el , 1 );
53 this.el.delete_event.connect( (self, event) => {
58 this.el.response.connect( (self, response_id) => {
60 if (response_id < 1) { // cancel!
65 if (_this.name.el.get_text().length < 1) {
66 StandardErrorDialog.show(
68 "You have to set Component name "
75 var isNew = _this.file.name.length > 0 ? false : true;
77 if (!isNew && this.file.name != _this.name.el.get_text()) {
78 Xcls_StandardErrorDialog.singleton().show(
80 "Sorry changing names does not work yet. "
89 // FIXME - this may be more complicated...
90 //for (var i in this.def) {
91 // this.file[i] = this.get(i).el.get_text();
96 this.updateFileFromEntry();
97 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
98 Xcls_StandardErrorDialog.singleton().show(
100 "The name you used already exists "
111 var fn = this.name.el.get_text();
112 var dir = _this.project.firstPath();
114 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
115 Xcls_StandardErrorDialog.singleton().show(
117 "That file already exists"
122 var f = JsRender.JsRender.factory(
123 _this.file.project.xtype,
125 dir + "/" + fn + ".bjs");
131 this.updateFileFromEntry();
133 _this.file.project.addFile(_this.file);
141 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
143 //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
144 //for (var i in this.file) {
145 // nf[i] = this.file[i];
147 _this.success(_this.project, _this.file);
150 -- fixme -- needs to be a signal..
151 if (DialogNewComponent.success != null) {
152 DialogNewComponent.success(_this.project, nf);
156 this.el.show.connect( (self) => {
162 // user defined functions
163 public void updateFileFromEntry () {
165 _this.file.title = _this.title.el.get_text();
166 _this.file.region = _this.region.el.get_text();
167 _this.file.parent = _this.parent.el.get_text();
168 _this.file.permname = _this.permname.el.get_text();
169 _this.file.modOrder = _this.modOrder.el.get_text();
171 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
172 _this.file.renameTo(_this.name.el.get_text());
176 public void show (JsRender.JsRender c)
178 this.project = c.project;
184 _this.name.el.set_text(c.name);
185 _this.title.el.set_text(c.title);
186 _this.parent.el.set_text(c.parent);
187 _this.region.el.set_text(c.region);
188 _this.modOrder.el.set_text(c.modOrder);
189 _this.permname.el.set_text(c.permname);
191 if (c.path.length > 0) {
192 this.el.set_title("Edit File Details - " + c.name);
194 this.el.set_title("Create New File");
198 //console.log('show all');
201 //this.success = c.success;
205 public class Xcls_VBox2 : Object
208 private Xcls_DialogNewComponent _this;
214 public Xcls_VBox2(Xcls_DialogNewComponent _owner )
217 this.el = new Gtk.VBox( true, 0 );
221 // set gobject values
222 var child_0 = new Xcls_Table3( _this );
224 this.el.pack_start ( child_0.el , false,false,0 );
227 // user defined functions
229 public class Xcls_Table3 : Object
232 private Xcls_DialogNewComponent _this;
238 public Xcls_Table3(Xcls_DialogNewComponent _owner )
241 this.el = new Gtk.Table( 3, 2, true );
245 // set gobject values
246 var child_0 = new Xcls_Label4( _this );
248 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
249 var child_1 = new Xcls_name( _this );
251 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
252 var child_2 = new Xcls_Label6( _this );
254 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
255 var child_3 = new Xcls_title( _this );
257 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
258 var child_4 = new Xcls_Label8( _this );
260 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
261 var child_5 = new Xcls_region( _this );
263 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
264 var child_6 = new Xcls_Label10( _this );
266 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
267 var child_7 = new Xcls_parent( _this );
269 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
270 var child_8 = new Xcls_Label12( _this );
272 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
273 var child_9 = new Xcls_permname( _this );
275 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
276 var child_10 = new Xcls_Label14( _this );
278 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
279 var child_11 = new Xcls_modOrder( _this );
281 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
284 // user defined functions
286 public class Xcls_Label4 : Object
289 private Xcls_DialogNewComponent _this;
295 public Xcls_Label4(Xcls_DialogNewComponent _owner )
298 this.el = new Gtk.Label( "Component Name" );
302 // set gobject values
303 this.el.justify = Gtk.Justification.RIGHT;
304 this.el.xalign = 0.900000f;
307 // user defined functions
309 public class Xcls_name : Object
312 private Xcls_DialogNewComponent _this;
318 public Xcls_name(Xcls_DialogNewComponent _owner )
322 this.el = new Gtk.Entry();
326 // set gobject values
327 this.el.visible = true;
330 // user defined functions
332 public class Xcls_Label6 : Object
335 private Xcls_DialogNewComponent _this;
341 public Xcls_Label6(Xcls_DialogNewComponent _owner )
344 this.el = new Gtk.Label( "Title" );
348 // set gobject values
349 this.el.justify = Gtk.Justification.RIGHT;
350 this.el.xalign = 0.900000f;
351 this.el.visible = true;
354 // user defined functions
356 public class Xcls_title : Object
359 private Xcls_DialogNewComponent _this;
365 public Xcls_title(Xcls_DialogNewComponent _owner )
369 this.el = new Gtk.Entry();
373 // set gobject values
374 this.el.visible = true;
377 // user defined functions
379 public class Xcls_Label8 : Object
382 private Xcls_DialogNewComponent _this;
388 public Xcls_Label8(Xcls_DialogNewComponent _owner )
391 this.el = new Gtk.Label( "Region" );
395 // set gobject values
396 this.el.justify = Gtk.Justification.RIGHT;
397 this.el.xalign = 0.900000f;
398 this.el.tooltip_text = "center, north, south, east, west";
399 this.el.visible = true;
402 // user defined functions
404 public class Xcls_region : Object
407 private Xcls_DialogNewComponent _this;
413 public Xcls_region(Xcls_DialogNewComponent _owner )
417 this.el = new Gtk.Entry();
421 // set gobject values
422 this.el.visible = true;
425 // user defined functions
427 public class Xcls_Label10 : Object
430 private Xcls_DialogNewComponent _this;
436 public Xcls_Label10(Xcls_DialogNewComponent _owner )
439 this.el = new Gtk.Label( "Parent Name" );
443 // set gobject values
444 this.el.justify = Gtk.Justification.RIGHT;
445 this.el.xalign = 0.900000f;
446 this.el.visible = true;
449 // user defined functions
451 public class Xcls_parent : Object
454 private Xcls_DialogNewComponent _this;
460 public Xcls_parent(Xcls_DialogNewComponent _owner )
464 this.el = new Gtk.Entry();
468 // set gobject values
469 this.el.visible = true;
472 // user defined functions
474 public class Xcls_Label12 : Object
477 private Xcls_DialogNewComponent _this;
483 public Xcls_Label12(Xcls_DialogNewComponent _owner )
486 this.el = new Gtk.Label( "Permission Name" );
490 // set gobject values
491 this.el.justify = Gtk.Justification.RIGHT;
492 this.el.xalign = 0.900000f;
493 this.el.visible = true;
496 // user defined functions
498 public class Xcls_permname : Object
501 private Xcls_DialogNewComponent _this;
507 public Xcls_permname(Xcls_DialogNewComponent _owner )
510 _this.permname = this;
511 this.el = new Gtk.Entry();
515 // set gobject values
516 this.el.visible = true;
519 // user defined functions
521 public class Xcls_Label14 : Object
524 private Xcls_DialogNewComponent _this;
530 public Xcls_Label14(Xcls_DialogNewComponent _owner )
533 this.el = new Gtk.Label( "Order (for tabs)" );
537 // set gobject values
538 this.el.justify = Gtk.Justification.RIGHT;
539 this.el.xalign = 0.900000f;
540 this.el.visible = true;
543 // user defined functions
545 public class Xcls_modOrder : Object
548 private Xcls_DialogNewComponent _this;
554 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
557 _this.modOrder = this;
558 this.el = new Gtk.Entry();
562 // set gobject values
563 this.el.visible = true;
566 // user defined functions
568 public class Xcls_Button16 : Object
570 public Gtk.Button el;
571 private Xcls_DialogNewComponent _this;
577 public Xcls_Button16(Xcls_DialogNewComponent _owner )
580 this.el = new Gtk.Button();
584 // set gobject values
585 this.el.label = "Cancel";
588 // user defined functions
590 public class Xcls_Button17 : Object
592 public Gtk.Button el;
593 private Xcls_DialogNewComponent _this;
599 public Xcls_Button17(Xcls_DialogNewComponent _owner )
602 this.el = new Gtk.Button();
606 // set gobject values
607 this.el.label = "OK";
610 // user defined functions