{ "build_module" : "builder", "gen_extended" : false, "items" : [ { "# JsRender.Node data" : "", "# Project.Project project" : "", "$ modal" : true, "$ xns" : "Gtk", "@ void complete" : "(string result)", "default_height" : 200, "default_width" : 400, "items" : [ { "$ xns" : "Gtk", "* pack" : " get_content_area().append", "Gtk.Orientation orientation" : "Gtk.Orientation.HORIZONTAL", "items" : [ { "$ xns" : "Gtk", "* pack" : "append", "label" : "Name", "xtype" : "Label" }, { "$ xns" : "Gtk", "* pack" : "append", "id" : "name", "xtype" : "Entry" } ], "xtype" : "Box" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,0", "label" : "Cancel", "xtype" : "Button" }, { "$ xns" : "Gtk", "* pack" : "add_action_widget,1", "label" : "OK", "xtype" : "Button" } ], "listeners" : { "response" : [ "(response_id) => {", " \tif (response_id < 1) {", " this.el.hide();", " this.complete(\"\");", " }", " ", " var name = _this.name.el.get_text();", " if (name.length < 1) {", " Xcls_StandardErrorDialog.singleton().show(", " _this.el,", " \"You must give the template a name. \"", " );", " return;", " }", " if (!Regex.match_simple (\"^[A-Za-z][A-Za-z0-9.]+$\", name) )", " {", " Xcls_StandardErrorDialog.singleton().show(", " _this.el.transient_for,", " \"Template Name must contain only letters dots\"", " );", " return;;", " }", " ", " var targetfile = project.path + \"/templates/\" + name + \".bjs\";", " ", " ", " if (GLib.FileUtils.test(targetfile, GLib.FileTest.EXISTS)) {", "\t Xcls_StandardErrorDialog.singleton().show(", "\t _this.el.transient_for,", "\t \"That file already exists\"", "\t ); ", "\t return;", "\t}", "\tJsRender.JsRender f;", " try {", "\t f = JsRender.JsRender.factory(", "\t\t\t project.xtype , ", "\t\t\tproject, ", "\t\t\ttargetfile);", "\t} catch (JsRender.Error e) {", "\t\tXcls_StandardErrorDialog.singleton().show(", "\t _this.el.transient_for,", "\t \"Error creating file\"", "\t ); ", "\t\treturn;", "\t}", " ", "", " f.tree = _this.data.deepClone();", " f.save();", " project.addFile(f);", " // now we save it..", " this.el.hide();", " this.complete(name);", " ", "", "}", "" ] }, "xtype" : "Dialog", "| void showIt" : [ " (Gtk.Window parent, Project.Project project, JsRender.Node data) {", " ", " ", " this.el.set_transient_for(parent);", " this.el.modal = true;", " ", " this.data = data;", " this.project = project;", " this.name.el.set_text(\"\");", " this.el.show();", "", " ", " ", "}", "" ] } ], "name" : "DialogSaveModule" }