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!
67 if (_this.name.el.get_text().length < 1) {
68 StandardErrorDialog.show(
70 "You have to set Component name "
77 var isNew = _this.file.name.length > 0 ? false : true;
79 if (!isNew && this.file.name != _this.name.el.get_text()) {
80 Xcls_StandardErrorDialog.singleton().show(
82 "Sorry changing names does not work yet. "
91 // FIXME - this may be more complicated...
92 //for (var i in this.def) {
93 // this.file[i] = this.get(i).el.get_text();
98 this.updateFileFromEntry();
99 } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
100 Xcls_StandardErrorDialog.singleton().show(
102 "The name you used already exists "
113 var fn = this.name.el.get_text();
114 var dir = _this.project.firstPath();
116 if (GLib.FileUtils.test(dir + "/" + fn + ".bjs", GLib.FileTest.EXISTS)) {
117 Xcls_StandardErrorDialog.singleton().show(
119 "That file already exists"
124 var f = JsRender.JsRender.factory(
125 _this.file.project.xtype,
127 dir + "/" + fn + ".bjs");
133 this.updateFileFromEntry();
135 _this.file.project.addFile(_this.file);
143 //var tmpl = this.project.loadFileOnly(DialogNewComponent.get('template').getValue());
145 //var nf = _this.project.create(dir + "/" + _this.file.name + ".bjs");
146 //for (var i in this.file) {
147 // nf[i] = this.file[i];
149 _this.success(_this.project, _this.file);
152 -- fixme -- needs to be a signal..
153 if (DialogNewComponent.success != null) {
154 DialogNewComponent.success(_this.project, nf);
158 this.el.show.connect( (self) => {
164 // user defined functions
165 public void updateFileFromEntry () {
167 _this.file.title = _this.title.el.get_text();
168 _this.file.region = _this.region.el.get_text();
169 _this.file.parent = _this.parent.el.get_text();
170 _this.file.permname = _this.permname.el.get_text();
171 _this.file.modOrder = _this.modOrder.el.get_text();
173 if (_this.file.name.length > 0 && _this.file.name != _this.name.el.get_text()) {
174 _this.file.renameTo(_this.name.el.get_text());
178 public void show (JsRender.JsRender c)
180 this.project = c.project;
186 _this.name.el.set_text(c.name);
187 _this.title.el.set_text(c.title);
188 _this.parent.el.set_text(c.parent);
189 _this.region.el.set_text(c.region);
190 _this.modOrder.el.set_text(c.modOrder);
191 _this.permname.el.set_text(c.permname);
193 if (c.path.length > 0) {
194 this.el.set_title("Edit File Details - " + c.name);
196 this.el.set_title("Create New File");
200 //console.log('show all');
203 //this.success = c.success;
207 public class Xcls_VBox2 : Object
210 private Xcls_DialogNewComponent _this;
216 public Xcls_VBox2(Xcls_DialogNewComponent _owner )
219 this.el = new Gtk.VBox( true, 0 );
223 // set gobject values
224 var child_0 = new Xcls_Table3( _this );
226 this.el.pack_start ( child_0.el , false,false,0 );
229 // user defined functions
231 public class Xcls_Table3 : Object
234 private Xcls_DialogNewComponent _this;
240 public Xcls_Table3(Xcls_DialogNewComponent _owner )
243 this.el = new Gtk.Table( 3, 2, true );
247 // set gobject values
248 var child_0 = new Xcls_Label4( _this );
250 this.el.attach_defaults ( child_0.el , 0,1,0,1 );
251 var child_1 = new Xcls_name( _this );
253 this.el.attach_defaults ( child_1.el , 1,2,0,1 );
254 var child_2 = new Xcls_Label6( _this );
256 this.el.attach_defaults ( child_2.el , 0,1,1,2 );
257 var child_3 = new Xcls_title( _this );
259 this.el.attach_defaults ( child_3.el , 1,2,1,2 );
260 var child_4 = new Xcls_Label8( _this );
262 this.el.attach_defaults ( child_4.el , 0,1,2,3 );
263 var child_5 = new Xcls_region( _this );
265 this.el.attach_defaults ( child_5.el , 1,2,2,3 );
266 var child_6 = new Xcls_Label10( _this );
268 this.el.attach_defaults ( child_6.el , 0,1,3,4 );
269 var child_7 = new Xcls_parent( _this );
271 this.el.attach_defaults ( child_7.el , 1,2,3,4 );
272 var child_8 = new Xcls_Label12( _this );
274 this.el.attach_defaults ( child_8.el , 0,1,4,5 );
275 var child_9 = new Xcls_permname( _this );
277 this.el.attach_defaults ( child_9.el , 1,2,4,5 );
278 var child_10 = new Xcls_Label14( _this );
280 this.el.attach_defaults ( child_10.el , 0,1,5,6 );
281 var child_11 = new Xcls_modOrder( _this );
283 this.el.attach_defaults ( child_11.el , 1,2,5,6 );
286 // user defined functions
288 public class Xcls_Label4 : Object
291 private Xcls_DialogNewComponent _this;
297 public Xcls_Label4(Xcls_DialogNewComponent _owner )
300 this.el = new Gtk.Label( "Component Name" );
304 // set gobject values
305 this.el.justify = Gtk.Justification.RIGHT;
306 this.el.xalign = 0.900000f;
309 // user defined functions
311 public class Xcls_name : Object
314 private Xcls_DialogNewComponent _this;
320 public Xcls_name(Xcls_DialogNewComponent _owner )
324 this.el = new Gtk.Entry();
328 // set gobject values
329 this.el.visible = true;
332 // user defined functions
334 public class Xcls_Label6 : Object
337 private Xcls_DialogNewComponent _this;
343 public Xcls_Label6(Xcls_DialogNewComponent _owner )
346 this.el = new Gtk.Label( "Title" );
350 // set gobject values
351 this.el.justify = Gtk.Justification.RIGHT;
352 this.el.xalign = 0.900000f;
353 this.el.visible = true;
356 // user defined functions
358 public class Xcls_title : Object
361 private Xcls_DialogNewComponent _this;
367 public Xcls_title(Xcls_DialogNewComponent _owner )
371 this.el = new Gtk.Entry();
375 // set gobject values
376 this.el.visible = true;
379 // user defined functions
381 public class Xcls_Label8 : Object
384 private Xcls_DialogNewComponent _this;
390 public Xcls_Label8(Xcls_DialogNewComponent _owner )
393 this.el = new Gtk.Label( "Region" );
397 // set gobject values
398 this.el.justify = Gtk.Justification.RIGHT;
399 this.el.xalign = 0.900000f;
400 this.el.tooltip_text = "center, north, south, east, west";
401 this.el.visible = true;
404 // user defined functions
406 public class Xcls_region : Object
409 private Xcls_DialogNewComponent _this;
415 public Xcls_region(Xcls_DialogNewComponent _owner )
419 this.el = new Gtk.Entry();
423 // set gobject values
424 this.el.visible = true;
427 // user defined functions
429 public class Xcls_Label10 : Object
432 private Xcls_DialogNewComponent _this;
438 public Xcls_Label10(Xcls_DialogNewComponent _owner )
441 this.el = new Gtk.Label( "Parent Name" );
445 // set gobject values
446 this.el.justify = Gtk.Justification.RIGHT;
447 this.el.xalign = 0.900000f;
448 this.el.visible = true;
451 // user defined functions
453 public class Xcls_parent : Object
456 private Xcls_DialogNewComponent _this;
462 public Xcls_parent(Xcls_DialogNewComponent _owner )
466 this.el = new Gtk.Entry();
470 // set gobject values
471 this.el.visible = true;
474 // user defined functions
476 public class Xcls_Label12 : Object
479 private Xcls_DialogNewComponent _this;
485 public Xcls_Label12(Xcls_DialogNewComponent _owner )
488 this.el = new Gtk.Label( "Permission Name" );
492 // set gobject values
493 this.el.justify = Gtk.Justification.RIGHT;
494 this.el.xalign = 0.900000f;
495 this.el.visible = true;
498 // user defined functions
500 public class Xcls_permname : Object
503 private Xcls_DialogNewComponent _this;
509 public Xcls_permname(Xcls_DialogNewComponent _owner )
512 _this.permname = this;
513 this.el = new Gtk.Entry();
517 // set gobject values
518 this.el.visible = true;
521 // user defined functions
523 public class Xcls_Label14 : Object
526 private Xcls_DialogNewComponent _this;
532 public Xcls_Label14(Xcls_DialogNewComponent _owner )
535 this.el = new Gtk.Label( "Order (for tabs)" );
539 // set gobject values
540 this.el.justify = Gtk.Justification.RIGHT;
541 this.el.xalign = 0.900000f;
542 this.el.visible = true;
545 // user defined functions
547 public class Xcls_modOrder : Object
550 private Xcls_DialogNewComponent _this;
556 public Xcls_modOrder(Xcls_DialogNewComponent _owner )
559 _this.modOrder = this;
560 this.el = new Gtk.Entry();
564 // set gobject values
565 this.el.visible = true;
568 // user defined functions
570 public class Xcls_Button16 : Object
572 public Gtk.Button el;
573 private Xcls_DialogNewComponent _this;
579 public Xcls_Button16(Xcls_DialogNewComponent _owner )
582 this.el = new Gtk.Button();
586 // set gobject values
587 this.el.label = "Cancel";
590 // user defined functions
592 public class Xcls_Button17 : Object
594 public Gtk.Button el;
595 private Xcls_DialogNewComponent _this;
601 public Xcls_Button17(Xcls_DialogNewComponent _owner )
604 this.el = new Gtk.Button();
608 // set gobject values
609 this.el.label = "OK";
612 // user defined functions