var spad = this.pad.substring(0, this.pad.length-indent);
if (this.node.props.has_key("* xinclude")) {
- this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {");
+ this.addLine("Roo.apply(" + this.node.props.get("* xinclude") + "._tree(), {",0 );
} else {
- this.addLine("{");
+ this.addLine("{", 0);
}
var suffix = "";
// output the items...
// work out remaining items...
- var total_nodes = this.out_props.size +
- this.out_props_array_plain.size +
- (this.out_listeners.size > 0 ? 1 : 0) +
- this.out_nodeprops.size +
- this.out_props_array.size +
- (this.out_children.size > 0 ? 1 : 0);
-
-
+
+ // output xns / xtype first..
+ if (this.out_props.has_key("xtype")) {
+ var v = this.out_props.get("xtype");
+ this.node.setLine(this.cur_line, "p","xtype");
+ this.addLine(this.pad + "xtype" + " : " + v + suffix, ',');
+ }
// plain properties.
var iter = this.orderedPropKeys().list_iterator();
while(iter.next()) {
- total_nodes--;
- suffix = total_nodes > 0 ? "," : "";
+
+
var k = iter.get();
+ if (k == "xns" || k == "xtype") {
+ continue;
+ }
+
var v = this.out_props.get(k);
+ this.node.setLine(this.cur_line, "p",k);
+ this.addLine(this.pad + k + " : " + v + suffix, ',');
+
+ this.node.setLine(this.cur_line, "e", "");
- this.addMultiLine(this.pad + k + " : " + v + suffix);
}
// listeners..
if (this.out_listeners.size > 0 ) {
- total_nodes--;
- this.addLine(this.pad + "listeners : {");
+
+ this.addLine(this.pad + "listeners : {", 0);
iter = this.orderedListenerKeys().list_iterator();
- var sz = this.out_listeners.size;
while(iter.next()) {
- sz--;
- suffix = sz > 0 ? "," : "";
+
var k = iter.get();
var v = this.out_listeners.get(k);
- this.addMultiLine(this.pad + indent_str + k + " : " + v + suffix);
+ this.node.setLine(this.cur_line, "l",k); //listener
+ this.addLine(this.pad + indent_str + k + " : " + v , ',');
+ this.node.setLine(this.cur_line, "e", "");
}
- suffix = total_nodes > 0 ? "," : "";
- this.addLine(this.pad + "}" + suffix);
+
+ this.closeLine();
+ this.addLine(this.pad + "}" ,',');
}
//------- at this point it is the end of the code relating directly to the object..
- this.node.line_end = this.cur_line;
-
+ if (this.out_props.has_key("xns")) {
+ var v = this.out_props.get("xns");
+ this.node.setLine(this.cur_line, "p","xns");
+ this.addLine(this.pad + "xns" + " : " + v + suffix, ',');
+ this.node.setLine(this.cur_line, "p","| xns");
+ this.addLine(this.pad + "'|xns' : '" + v + "'", ',');
+ this.node.setLine(this.cur_line, "e", "");
+ }
+ this.node.line_end = this.cur_line;
// * prop
var niter = this.out_nodeprops.map_iterator();
while(niter.next()) {
- total_nodes--;
- suffix = total_nodes > 0 ? "," : "";
- var l = this.pad + niter.get_key() + " : " +
- this.mungeChildNew(this.pad + indent_str, niter.get_value()) + suffix;
- this.addMultiLine(l);
+ var addstr = this.mungeChildNew(this.pad + indent_str, niter.get_value());
+ //print("add str: %s\n", addstr);
+ this.node.setLine(this.cur_line, "p",niter.get_key());
+ this.addLine(this.pad + niter.get_key() + " : " + addstr, ',');
+
+ this.node.setLine(this.cur_line, "e", "");
}
// prop arrays...
var piter = this.out_props_array.map_iterator();
while(piter.next()) {
- total_nodes--;
-
- this.addLine(this.pad + piter.get_key() + " : [");
+ this.node.setLine(this.cur_line, "p",piter.get_key());
+ this.addLine(this.pad + piter.get_key() + " : [", 0);
+
var pliter = piter.get_value().list_iterator();
while (pliter.next()) {
- suffix = pliter.has_next() ? "," : "";
- this.addMultiLine(this.pad + indent_str +
- this.mungeChildNew(this.pad + indent_str + indent_str, pliter.get()) + suffix);
+ var addstr = this.mungeChildNew(this.pad + indent_str + indent_str, pliter.get());
+ this.addLine(this.pad + indent_str + addstr, ',');
+ this.node.setLine(this.cur_line, "e", "");
}
-
- suffix = total_nodes > 0 ? "," : "";
-
- this.addLine(this.pad + "]" + suffix);
+ this.closeLine();
+ this.addLine(this.pad + "]" , ',');
}
// children..
if (this.out_children.size > 0) {
- this.addLine(this.pad + "items : [" );
+ this.addLine(this.pad + "items : [" , 0);
var cniter = this.out_children.list_iterator();
while (cniter.next()) {
suffix = cniter.has_next() ? "," : "";
- this.addMultiLine(this.pad + indent_str +
- this.mungeChildNew(this.pad + indent_str + indent_str, cniter.get()) + suffix
- );
+ var addstr = this.mungeChildNew(this.pad + indent_str + indent_str, cniter.get());
+ this.addLine(this.pad + indent_str + addstr, ',');
+ this.node.setLine(this.cur_line, "e", "");
}
-
- this.addLine(this.pad + "]");
+ this.closeLine();
+ this.addLine(this.pad + "]",',');
}
-
+ this.node.setLine(this.cur_line, "e", "");
+ this.closeLine();
if (this.node.props.has_key("* xinclude")) {
- this.ret += spad + "})";
+ this.addLine(spad + "})",0);
} else {
- this.ret += spad + "}";
+ this.addLine( spad + "}", 0);
}
this.node.sortLines();
+
+
+
return this.ret;
}
*
*/
- char last_line_end = 0;
+ char last_line_end = '!';
/**
* add a line - note we will end up with an extra line break
*/
public void addLine(string str, char line_end)
{
- this.ret += (this.line_end == 0 ? "" : this.last_line_end) + "\n";
- this.cur_line ++;
- this.ret += str ;
+ if (this.last_line_end != '!') {
+ this.ret += (this.last_line_end == 0 ? "" : this.last_line_end.to_string()) + "\n";
+ }
+ this.last_line_end = line_end;
+ this.cur_line += str.split("\n").length;
+ this.ret += str;
+
+
//this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line -1, this.node.line_start,this.node.line_end) + str + "\n";
}
+ public void closeLine() // send this before '}' or ']' to block output of ',' ...
+ {
+ this.last_line_end = 0;
+ }
- public void addMultiLine(string str= "")
+/* public void addMultiLine(str= "")
{
-
- //this.ret += "/*%d(%d-%d)*/ ".printf(this.cur_line, this.node.line_start,this.node.line_end)+ str + "\n";
+
+ //this.ret += "/ * %d(%d-%d) * / ".printf(this.cur_line, this.node.line_start,this.node.line_end)+ str + "\n";
this.ret += str + "\n";
this.cur_line += str.split("\n").length;
}
-
+ */
public string mungeChildNew(string pad , Node cnode )
{
var x = new NodeToJs(cnode, this.doubleStringProps, pad, this);
{
string left;
Regex func_regex ;
-
- if (this.node.props.has_key("$ xns")) {
- this.out_props.set("'|xns'", "'" + this.node.props.get("$ xns") + "'" );
-
- //this.els.add("'|xns' : '" + this.node.props.get("$ xns") + "'");
-
- }
-
-
+
try {
func_regex = new Regex("^\\s+|\\s+$");
} catch (RegexError e) {
//nstr = string.joinv("\n", lines);
}
this.out_props.set(left, nstr);
+
+
+
+
+
//print("==> " + str + "\n");
//this.els.add(left + " : "+ nstr);
continue;