"clicked" : [
"( ) => { ",
"",
- " ",
- "",
- "",
- "\tif (_this.name.el.get_text().length < 1) {",
- "\t Xcls_StandardErrorDialog.singleton().show(",
- "\t _this.mainwindow.el,",
- "\t \"You have to set Component name \"",
- "\t );",
- "\t ",
- "\t return;",
- "\t}",
- "\t// what does this do?",
- "\t",
- "\tvar isNew = _this.file.name.length > 0 ? false : true;",
- "\t/*",
- "\tif (!isNew && this.file.name != _this.name.el.get_text()) {",
- "\t Xcls_StandardErrorDialog.singleton().show(",
- "\t this.el,",
- "\t \"Sorry changing names does not work yet. \"",
- "\t );",
- "\t ",
- "\t return;",
- "\t}",
- "\t*/",
- "\t ",
- "\t",
- " ",
- "\t// FIXME - this may be more complicated...",
- "\t//for (var i in this.def) {",
- "\t// this.file[i] = this.get(i).el.get_text();",
- "\t//}",
- "",
- "\tif (!isNew) {",
- "\t try {",
- "\t _this.updateFileFromEntry();",
- "\t } catch( JsRender.Error.RENAME_FILE_EXISTS er) {",
- "\t Xcls_StandardErrorDialog.singleton().show(",
- "\t _this.mainwindow.el,",
- "\t \"The name you used already exists \"",
- "\t );",
- "\t return;",
- "\t ",
- "\t }",
- "",
- "\t _this.done = true;",
- "\t _this.file.save();",
- "\t _this.el.hide();",
- "\t return;",
- "\t}",
- "\t",
- "\t// ---------------- NEW FILES...",
- "\tGtk.TreeIter iter;",
- "",
- "\tif (!_this.filetype.el.get_active_iter(out iter)) {",
- "\t\t// should not happen...",
- "\t\t// so we are jut going to return without ",
- "\t\tXcls_StandardErrorDialog.singleton().show(",
- "\t _this.mainwindow.el,",
- "\t \"You must select a file type. \"",
- "\t );",
- "\t return;",
- "\t\t ",
- "\t}",
- "\t",
- "\t",
- "\tvar fn = _this.name.el.get_text();",
- "\t",
- "\tValue ftypename;",
- "\t_this.ftdbmodel.el.get_value (iter, 0, out ftypename);",
- "\tvar ext = ((string)ftypename);",
- "\tvar dir = _this.project.firstPath(); ",
- "\tif (ext != \"bjs\") {",
- "\t ",
- "\t\tif (!_this.dir.el.get_active_iter(out iter)) {",
- "\t\t\t// should not happen...",
- "\t\t\t// so we are jut going to return without ",
- "\t\t\tXcls_StandardErrorDialog.singleton().show(",
- "\t\t\t _this.mainwindow.el,",
- "\t\t\t \"You must select a directory \"",
- "\t\t\t);",
- "\t\t\treturn;",
- "\t\t}",
- "\t\tValue vdir;",
- "\t\t_this.dirmodel.el.get_value (iter, 0, out vdir);",
- "\t\tdir = (string)vdir;",
- "\t}",
- "\t",
- "\tvar targetfile = dir + \"/\" + fn;",
- "\t",
- "\t// strip the file type off the end..",
- "\t",
- "\t",
- " var rx = new GLib.Regex(\"\\\\.\" + ext + \"$\",GLib.RegexCompileFlags.CASELESS);",
- " targetfile = rx.replace(targetfile, targetfile.length, 0, \"\"); ",
- " ",
- "\tif (GLib.FileUtils.test(targetfile + \".\" + ext, GLib.FileTest.EXISTS)) {",
- "\t Xcls_StandardErrorDialog.singleton().show(",
- "\t _this.mainwindow.el,",
- "\t \"That file already exists\"",
- "\t ); ",
- "\t return;",
- "\t}",
- " ",
- " var f = JsRender.JsRender.factory(",
- "\t\text == \"bjs\" ? _this.file.project.xtype : \"PlainFile\", ",
- "\t\t_this.file.project, ",
- "\t\ttargetfile + \".\" + ext);",
- "",
- "\t_this.file = f;",
- "\t",
- "",
- "\t",
- "\t_this.updateFileFromEntry();",
- "\t_this.file.loaded = true;",
- "\t_this.file.save();",
- "\tif (ext == \"bjs\") {",
- "\t\t_this.file.project.addFile(_this.file);",
- "\t}",
- "\t",
- " ",
- "\t// what about .js ?",
- " _this.done = true;",
- "\t_this.el.hide();",
- "",
- "// hopefull this will work with bjs files..",
- "\t",
- "\t_this.success(_this.project, _this.file);",
- " ",
- "}"
+ "\t _this.project.writeConfig();",
+ "\t _this.done = true;",
+ "\t _this.el.hide();",
+ " }",
+ " "
]
},
"string label" : "Save",
//listeners
this.el.clicked.connect( ( ) => {
-
-
-
- if (_this.name.el.get_text().length < 1) {
- Xcls_StandardErrorDialog.singleton().show(
- _this.mainwindow.el,
- "You have to set Component name "
- );
-
- return;
- }
- // what does this do?
-
- var isNew = _this.file.name.length > 0 ? false : true;
- /*
- if (!isNew && this.file.name != _this.name.el.get_text()) {
- Xcls_StandardErrorDialog.singleton().show(
- this.el,
- "Sorry changing names does not work yet. "
- );
-
- return;
- }
- */
-
-
-
- // FIXME - this may be more complicated...
- //for (var i in this.def) {
- // this.file[i] = this.get(i).el.get_text();
- //}
-
- if (!isNew) {
- try {
- _this.updateFileFromEntry();
- } catch( JsRender.Error.RENAME_FILE_EXISTS er) {
- Xcls_StandardErrorDialog.singleton().show(
- _this.mainwindow.el,
- "The name you used already exists "
- );
- return;
-
- }
-
- _this.done = true;
- _this.file.save();
- _this.el.hide();
- return;
- }
-
- // ---------------- NEW FILES...
- Gtk.TreeIter iter;
-
- if (!_this.filetype.el.get_active_iter(out iter)) {
- // should not happen...
- // so we are jut going to return without
- Xcls_StandardErrorDialog.singleton().show(
- _this.mainwindow.el,
- "You must select a file type. "
- );
- return;
-
- }
-
-
- var fn = _this.name.el.get_text();
-
- Value ftypename;
- _this.ftdbmodel.el.get_value (iter, 0, out ftypename);
- var ext = ((string)ftypename);
- var dir = _this.project.firstPath();
- if (ext != "bjs") {
-
- if (!_this.dir.el.get_active_iter(out iter)) {
- // should not happen...
- // so we are jut going to return without
- Xcls_StandardErrorDialog.singleton().show(
- _this.mainwindow.el,
- "You must select a directory "
- );
- return;
- }
- Value vdir;
- _this.dirmodel.el.get_value (iter, 0, out vdir);
- dir = (string)vdir;
- }
-
- var targetfile = dir + "/" + fn;
-
- // strip the file type off the end..
-
-
- var rx = new GLib.Regex("\\." + ext + "$",GLib.RegexCompileFlags.CASELESS);
- targetfile = rx.replace(targetfile, targetfile.length, 0, "");
-
- if (GLib.FileUtils.test(targetfile + "." + ext, GLib.FileTest.EXISTS)) {
- Xcls_StandardErrorDialog.singleton().show(
- _this.mainwindow.el,
- "That file already exists"
- );
- return;
- }
-
- var f = JsRender.JsRender.factory(
- ext == "bjs" ? _this.file.project.xtype : "PlainFile",
- _this.file.project,
- targetfile + "." + ext);
-
- _this.file = f;
-
-
-
- _this.updateFileFromEntry();
- _this.file.loaded = true;
- _this.file.save();
- if (ext == "bjs") {
- _this.file.project.addFile(_this.file);
- }
-
-
- // what about .js ?
- _this.done = true;
- _this.el.hide();
-
- // hopefull this will work with bjs files..
-
- _this.success(_this.project, _this.file);
-
- });
+ _this.project.writeConfig();
+ _this.done = true;
+ _this.el.hide();
+ });
}
// user defined functions