class Roo : JsRender
{
- string region;
+
bool disabled;
- Gee.HashMap<string,string> namedStrings;
+
- public Roo(Project.Project project, string path) {
+ public Roo(Project.Roo project, string path)
+ {
base( project, path);
+
this.xtype = "Roo";
this.language = "js";
"emptyTitle",
"dialogTitle",
"modalTitle",
+ "boxLabel"
};
for (var i=0;i<dsp.length;i++) {
this.permname = this.jsonHasOrEmpty(obj, "permname");
this.title = this.jsonHasOrEmpty(obj, "title");
this.modOrder = this.jsonHasOrEmpty(obj, "modOrder");
-
+ if (obj.has_member("gen_extended")) { // should check type really..
+ this.gen_extended = obj.get_boolean_member("gen_extended");
+ }
var bjs_version_str = this.jsonHasOrEmpty(obj, "bjs-version");
bjs_version_str = bjs_version_str == "" ? "1" : bjs_version_str;
}
-
- public override void save()
- {
-
- GLib.debug("--- JsRender.Roo.save");
- GLib.debug("save() - reset transStrings\n");
- this.transStrings = new Gee.HashMap<string,string>();
- this.namedStrings = new Gee.HashMap<string,string>();
- this.findTransStrings(this.tree);
-
- this.saveBJS();
+ public override string targetName()
+ {
+ string js;
+ try {
+ Regex regex = new Regex("\\.(bjs|js)$");
- // no tree..
- if (this.tree == null) {
- return;
+ js = regex.replace(this.path,this.path.length , 0 , ".js");
+ return js;
+ } catch (RegexError e) {
+ this.name = "???";
+ print("count not make filename from path");
+ return this.name + ".js";
+ }
+
}
- // now write the js file..
- string js;
- try {
- Regex regex = new Regex("\\.(bjs|js)$");
+ public override void save()
+ {
+
+ GLib.debug("--- JsRender.Roo.save");
+ GLib.debug("save() - reset transStrings\n");
+ this.transStrings = new Gee.HashMap<string,string>();
+ this.namedStrings = new Gee.HashMap<string,string>();
+ this.findTransStrings(this.tree);
+
+ this.saveBJS();
- js = regex.replace(this.path,this.path.length , 0 , ".js");
- } catch (RegexError e) {
- this.name = "???";
- print("count not make filename from path");
- return;
- }
+ // no tree..
+ if (this.tree == null) {
+ return;
+ }
+ // now write the js file..
+ var js = this.targetName();
+
- //var d = new Date();
- var js_src = this.toSource();
- //print("TO SOURCE in " + ((new Date()) - d) + "ms");
- try {
- this.writeFile(js, js_src);
- } catch (FileError e ) {
- print("Save failed\n");
+ //var d = new Date();
+ var js_src = this.toSource();
+ //print("TO SOURCE in " + ((new Date()) - d) + "ms");
+ try {
+ this.writeFile(js, js_src);
+ } catch (GLib.Error e ) {
+ print("Save failed\n");
+ }
+ // for bootstrap - we can write the HTML to the templates directory..
+
+ //var top = this.guessName(this.items[0]);
+ //print ("TOP = " + top)
+
+
+
+
}
- // for bootstrap - we can write the HTML to the templates directory..
-
- //var top = this.guessName(this.items[0]);
- //print ("TOP = " + top)
-
-
-
-
- }
-
+ public Project.Roo roo_project {
+ set {}
+ get {
+ return (Project.Roo) this.project;
+ }
+ }
+
public override void saveHTML ( string html )
{
- GLib.debug ("SAVEHTML %s\n", this.project.runhtml);
- if (this.project.runhtml == "") {
+ GLib.debug ("SAVEHTML %s\n", this.roo_project.runhtml);
+ if (this.roo_project.runhtml == "") {
return;
}
print("SAVE HTML (%d) -- %s\n",html.length, targetdir + "/" + bn);
try {
this.writeFile(targetdir + "/" + bn , html);
- } catch (FileError e ) {
+ } catch (GLib.Error e ) {
print("SaveHtml failed\n");
}
{
if (node.props.has_key("* xinclude")) {
- ret.add(node.props.get("* xinclude"));
+ ret.add(node.props.get("* xinclude").val);
}
- for (var i =0; i < node.items.size; i++) {
- this.findxincludes(node.items.get(i), ret);
+ var items = node.readItems();
+ for (var i =0; i < items.size; i++) {
+ this.findxincludes(items.get(i), ret);
}
return ret;
// string XXX - with type
// $ XXX - with flag (no type)
// $ string XXX - with flag
- string kname;
- string ktype;
- string kflag;
- node.normalize_key(iter.get_key(), out kname, out kflag, out ktype);
- if (kflag == "$") {
+
+
+ var prop = iter.get_value();
+ var kname = prop.name;
+ var ktype = prop.rtype;
+
+
+ if (prop.ptype == NodePropType.RAW) {
continue;
}
// skip cms-id nodes...
if (kname == "html" && node.has("cms-id")) {
continue;
}
- var str = iter.get_value();
+ var str = prop.val;
if (kname == "name") {
name_prefix = str;
}
var chksum = GLib.Checksum.compute_for_string (ChecksumType.MD5, str.strip());
if (this.doubleStringProps.index_of(kname) > -1) {
- GLib.debug("flag=%s type=%s name=%s : %s\n", kflag,ktype,kname,str);
+ //GLib.debug("flag=%s type=%s name=%s : %s\n", prop.ptype.to_string(),ktype,kname,str);
this.transStrings.set(str, chksum);
named.set("_" + kname, chksum);
continue;
}
if (ktype.down() == "string" && kname[0] == '_') {
- GLib.debug("flag=%s type=%s name=%s : %s\n", kflag,ktype,kname,str);
+ GLib.debug("flag=%s type=%s name=%s : %s\n", prop.ptype.to_string(),ktype,kname,str);
this.transStrings.set(str, chksum);
named.set(kname, chksum);
continue;
}
}
-
+ var items = node.readItems();
// iterate children..
- for (var i =0; i < node.items.size; i++) {
- this.findTransStrings(node.items.get(i) );
+ for (var i =0; i < items.size; i++) {
+ this.findTransStrings(items.get(i) );
}
}
string[] kvs = {};
+
+ var hash = new Gee.HashMap<string,string>();
var iter = this.transStrings.map_iterator();
while (iter.next()) {
+ hash.set(iter.get_value(), iter.get_key());
kvs += (" '" + iter.get_value() + "' :" +
this.tree.quoteString(iter.get_key())
);
}
- return " _strings : {\n" + string.joinv(",\n", kvs) + "\n" +
- " },";
-
-
-
- }
-
+ var ret = " _strings : {\n" + string.joinv(",\n", kvs) + "\n },";
+
+
+ string[] ns = {};
+ var niter = this.namedStrings.map_iterator();
+ while (niter.next()) {
+ var otext = hash.get(niter.get_value());
+ var com = " /* " + (otext.replace("*/", "* - /") + " */ ");
+
+
+ ns += (" '" + niter.get_key() + "' : '" + niter.get_value() + "'" + com);
+ }
+ if (ns.length > 0 ) {
+ ret += "\n _named_strings : {\n" + string.joinv(",\n", ns) + "\n },";
+ }
+ return ret;
+ }
+
+
/**
* javascript used in Webkit preview
*/
if (xinc.size > 0 ) {
for(var i = 0; i < xinc.size; i++) {
print("check xinclude: %s\n", xinc.get(i));
- var sf = this.project.getByName(xinc.get(i));
+ var sf = this.project.getByRelPath(xinc.get(i));
if (sf == null) {
print("Failed to find file by name?\n");
continue;
}
-
- sf.loadItems();
- sf.findTransStrings(sf.tree);
- var xinc_str = sf.toSource();
-
- //string xinc_str;
- //FileUtils.get_contents(js, out xinc_str);
- prefix_data += "\n" + xinc_str + "\n";
+ try {
+ sf.loadItems();
+ sf.findTransStrings(sf.tree);
+ var xinc_str = sf.toSource();
+
+ //string xinc_str;
+ //FileUtils.get_contents(js, out xinc_str);
+ prefix_data += "\n" + xinc_str + "\n";
+ } catch (GLib.Error e) {}
}
if (top.contains("Modal")) {
return prefix_data + this.toSourceModal(true);
}
-
+ if (top.contains("Popover")) {
+ return prefix_data + this.toSourceModal(true);
+ }
return prefix_data + this.toSourceLayout(true);
if (top.contains("Modal")) {
return this.toSourceModal(false);
}
+
+ if (top.contains("Popover")) {
+ return this.toSourceModal(false);
+ }
+
return this.toSourceLayout(false);
/*
if (this.tree == null) {
return "";
}
- var x = new NodeToJs(this.tree, this.doubleStringProps, pad, null);
- x.renderer = this;
- x.cur_line = prefix.split("\n").length;
-
+
+ var x = new NodeToJs( this, this.tree, pad , null, this.doubleStringProps);
+ x.addMultiLine(prefix, false);
var ret = x.munge();
- //var nret = x.ret;
-
- // output both files.. so we can diff them...
- //this.writeFile("/tmp/old.js", ret);
- //this.writeFile("/tmp/new.js", nret);
- return prefix + ret + suffix;
+ return ret + suffix;
}
"",
" this.callback = cb;",
" this.data = data;",
- " this.dialog.show(this.data._el);",
+ " this.dialog.show.apply(this.dialog, Array.prototype.slice.call(arguments).slice(2));",
" if (this.form) {",
" this.form.reset();",
" this.form.setValues(data);",
"",
" this.callback = cb;",
" this.data = data;",
- " this.dialog.show(this.data._el);",
+ " this.dialog.show.apply(this.dialog, Array.prototype.slice.call(arguments).slice(2));",
" if (this.form) {",
" this.form.reset();",
" this.form.setValues(data);",
}
- public new string? guessName (Node? ar) // turns the object into full name.
- {
- // eg. xns: Roo, xtype: XXX -> Roo.xxx
- if (ar == null) {
- return null;
- }
-
- string[] ret = {} ;
- ret += (ar.get("|xns").length < 1 ? "Roo": ar.get("|xns"));
-
-
- if ( ar.get("xtype").length < 1) {
- return null;
- }
-
- var xtype = ar.get("xtype");
-
- if (xtype[0] == '*') { // prefixes????
- xtype = xtype.substring(1);
- }
- if (! Regex.match_simple("^Roo", xtype)) {
-
- // already starts with roo...
- ret = {};
- }
- ret += xtype;
- var str = string.joinv(".", ret);
-
- return str;
- //
- //Palete.Palete.factory("Roo").guessName(str);
-
-
-
- }
- string getHelpUrl(string cls)
- {
- return "http://www.roojs.com/roojs1/docs/symbols/" + cls + ".html";
- }
-
+ public override string toGlade()
+ {
+ return "Roo files do not convert to glade";
+ }
+ public override string language_id()
+ {
+ return "javascript";
+ }
}
}