diff --git a/.bzrignore b/.bzrignore index 604c3a0c823320ce049f48e192fe40ec27837977..1f4b69e43697855d989e1c8b7dcab25771dc0cd2 100644 --- a/.bzrignore +++ b/.bzrignore @@ -13,3 +13,4 @@ examples/configForm/configForm.ast examples/configForm/configForm.jjt javadoc SchemaCompile.jar +examples/configForm/config-sheet.html diff --git a/examples/configForm/HTMLGen.jrag b/examples/configForm/HTMLGen.jrag index 8b41abab759da5747ca991581546b05e752d7018..fcea9ca0412aefc5f1cf26e17df4cda4d059df00 100644 --- a/examples/configForm/HTMLGen.jrag +++ b/examples/configForm/HTMLGen.jrag @@ -24,7 +24,7 @@ aspect HTMLGen { } public void configuration_sheet.genHTML(int ind, PrintStream pStream) { - pStream.println(ind(ind)+"<?xml version=\"1.0\" encoding=\"UTF-8\"?><"); + pStream.println(ind(ind)+"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); pStream.println(ind(ind)+"<html>"); ind++; pStream.println(ind(ind)+"<head>"); @@ -33,22 +33,143 @@ aspect HTMLGen { pStream.println(ind(ind)+"<body>"); ind++; pStream.println(ind(ind)+"<center>"); - pStream.println(ind(ind+1)+"<h1>"+name()+"/h1>"); + pStream.println(ind(ind+1)+"<h1>"+name()+"</h1>"); pStream.println(ind(ind)+"</center>"); pStream.println(ind(ind)+"<table border=\"1\" valign=\"top\">"); ind++; pStream.println(ind(ind)+"<tr bgcolor=\"lightgray\">"); + ind++; + pStream.println(ind(ind)+"<th>"); + pStream.println(ind(ind+1)+"<h2>Specifications</h2>"); + pStream.println(ind(ind)+"</th>"); + pStream.println(ind(ind)+"<th>"); + pStream.println(ind(ind+1)+"<h2>Processes</h2>"); + pStream.println(ind(ind)+"</th>"); + ind--; + pStream.println(ind(ind)+"</tr>"); + pStream.println(ind(ind)+"<tr>"); + ind++; + pStream.println(ind(ind)+"<td bgcolor=\"lightblue\">"); + getSpecifications().genHTML(ind,pStream); + pStream.println(ind(ind)+"</td>"); + pStream.println(ind(ind)+"<td bgcolor=\"yellow\">"); + getTasks().genHTML(ind,pStream); + pStream.println(ind(ind)+"</td>"); + ind--; pStream.println(ind(ind)+"</tr>"); ind--; pStream.println(ind(ind)+"</table>"); ind--; pStream.println(ind(ind)+"</body>"); - super.genHTML(ind,pStream); ind--; pStream.println(ind(ind)+"</html>"); } - - + + public void specifications.genHTML(int ind, PrintStream pStream) { + pStream.println(ind(ind)+"<form action=\"specifications\" method=\"get\" "); + pStream.println("enctype=\"application/x-www-form-urlencoded\">"); + ind++; + for (int i=0; i<getNumElement(); i++) { + getElement(i).genHTML(ind,pStream); + } + pStream.println(ind(ind)+"<hr/>"); + pStream.println(ind(ind)+"<input type=\"reset\" value=\"Cancel\"/>"); + pStream.println(ind(ind)+"<input type=\"submit\" value=\"Submit\"/>"); + ind--; + pStream.println(ind(ind)+"</form>"); + } + + public void spec.genHTML(int ind, PrintStream pStream) { + pStream.println(ind(ind)+"<h2>"+name()+"</h2>"); + pStream.println(ind(ind)+"<table>"); + super.genHTML(ind+1,pStream); + pStream.println(ind(ind)+"</table>"); + } + + public void option.genHTML(int ind, PrintStream pStream) { + pStream.println(ind(ind)+"<tr>"); + for (int i=0; i<getNumElement(); i++) { + Element e = getElement(i); + if (e instanceof param && ((param) e).hasValue()) { + e.genHTML(ind,pStream); + } + } + for (int i=0; i<getNumElement(); i++) { + Element e = getElement(i); + if (e instanceof img) { + e.genHTML(ind,pStream); + } + } + for (int i=0; i<getNumElement(); i++) { + Element e = getElement(i); + if (e instanceof param && !((param) e).hasValue()) { + e.genHTML(ind,pStream); + } + } + pStream.println(ind(ind)+"</tr>"); + } + + public void param.genHTML(int ind, PrintStream pStream) { + if (hasValue()) { + pStream.println(ind(ind)+"<td>"); + pStream.println(ind(ind+1)+"<input type=\"radio\" name=\""+name()+ + "\" value=\""+value()+"\"/>"); + pStream.println(ind(ind)+"</td>"); + pStream.println(ind(ind)+"<td>"); + pStream.println(ind(ind+1)+text()); + pStream.println(ind(ind)+"</td>"); + } else { + pStream.println(ind(ind)+"<td>"); + pStream.println(ind(ind+1)+text()); + pStream.println(ind(ind)+"</td>"); + pStream.println(ind(ind)+"<td>"); + pStream.println(ind(ind+1)+"<input type=\"text\" name=\""+name()+ + "\" size=\"2\"/>"); + pStream.println(ind(ind)+"</td>"); + } + } + + public void img.genHTML(int ind, PrintStream pStream) { + pStream.println(ind(ind)+"<td>"); + pStream.println(ind(ind+1)+"<img src=\""+src()+"\"/>"); + pStream.println(ind(ind)+"</td>"); + } + + public void task.genHTML(int ind, PrintStream pStream) { + pStream.println(ind(ind)+"<form action=\""+name()+ + "method=\"get\" enctype=\"application/x-www-form-urlencoded\">"); + ind++; + pStream.println(ind(ind)+"<h2>"+name()+"</h2>"); + pStream.println(ind(ind)+"<table>"); + ind++; + super.genHTML(ind,pStream); + pStream.println(ind(ind)+"<tr><td/><td><input type=\"submit\" value=\"Execute\"/></td></tr>"); + ind--; + pStream.println(ind(ind)+"</table>"); + ind--; + pStream.println(ind(ind)+"</form>"); + } + +} + +aspect Navigation { //Should preferably be automatically generated instead + public ComplexElement configuration_sheet.getSpecifications() { + for (int i=0; i<getNumElement(); i++) { + if (getElement(i) instanceof specifications) { + return (specifications) getElement(i); + } + } + return null; + } + + public ComplexElement configuration_sheet.getTasks() { + for (int i=0; i<getNumElement(); i++) { + if (getElement(i) instanceof tasks) { + return (tasks) getElement(i); + } + } + return null; + } } aspect Misc { @@ -65,6 +186,42 @@ aspect Misc { return super.name(); } + syn lazy String param.value() { + for (int i=0; i<getNumAttribute(); i++) { + if (getAttribute(i) instanceof value) { + return getAttribute(i).value().replace("\""," ").trim(); + } + } + return ""; + } + + syn lazy String param.text() { + for (int i=0; i<getNumAttribute(); i++) { + if (getAttribute(i) instanceof text) { + return getAttribute(i).value().replace("\""," ").trim(); + } + } + return ""; + } + + syn lazy String img.src() { + for (int i=0; i<getNumAttribute(); i++) { + if (getAttribute(i) instanceof src) { + return getAttribute(i).value().replace("\""," ").trim(); + } + } + return ""; + } + + syn lazy boolean param.hasValue() { + for (int i=0; i<getNumAttribute(); i++) { + if (getAttribute(i) instanceof value) { + return true; + } + } + return false; + } + syn lazy String Attribute.value() { return getAttrValue().getLITERAL(); } diff --git a/examples/configForm/img/hole_four.jpg b/examples/configForm/img/hole_four.jpg new file mode 100644 index 0000000000000000000000000000000000000000..ed8c55ce8475681b01939c2ace7b62ace05a41f7 Binary files /dev/null and b/examples/configForm/img/hole_four.jpg differ diff --git a/examples/configForm/img/hole_one.jpg b/examples/configForm/img/hole_one.jpg new file mode 100644 index 0000000000000000000000000000000000000000..fd31be7f2d450e6d57d84eaa49bfcc4d7ac9aeee Binary files /dev/null and b/examples/configForm/img/hole_one.jpg differ diff --git a/examples/configForm/img/hole_two.jpg b/examples/configForm/img/hole_two.jpg new file mode 100644 index 0000000000000000000000000000000000000000..306430827f2bdf2b155870a0b2b6e80014b0bc9e Binary files /dev/null and b/examples/configForm/img/hole_two.jpg differ diff --git a/examples/configForm/img/pattern_one.jpg b/examples/configForm/img/pattern_one.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f9bf26e445a9830e969fd14219f1d6c376a91919 Binary files /dev/null and b/examples/configForm/img/pattern_one.jpg differ diff --git a/examples/configForm/img/pattern_two.jpg b/examples/configForm/img/pattern_two.jpg new file mode 100644 index 0000000000000000000000000000000000000000..f9bf26e445a9830e969fd14219f1d6c376a91919 Binary files /dev/null and b/examples/configForm/img/pattern_two.jpg differ diff --git a/examples/configForm/img/shape_cut.jpg b/examples/configForm/img/shape_cut.jpg new file mode 100644 index 0000000000000000000000000000000000000000..6c3af10027be9fdefba6fe9a65e074034ca76e02 Binary files /dev/null and b/examples/configForm/img/shape_cut.jpg differ diff --git a/examples/configForm/img/shape_sharp.jpg b/examples/configForm/img/shape_sharp.jpg new file mode 100644 index 0000000000000000000000000000000000000000..1eab88b3a965094aff47a1f28ecd7c4115edafd4 Binary files /dev/null and b/examples/configForm/img/shape_sharp.jpg differ diff --git a/examples/configForm/img/shape_soft.jpg b/examples/configForm/img/shape_soft.jpg new file mode 100644 index 0000000000000000000000000000000000000000..da54844ccee81b9d7d9da25f3b52468c8fbfee5d Binary files /dev/null and b/examples/configForm/img/shape_soft.jpg differ diff --git a/examples/configForm/img/text_area.jpg b/examples/configForm/img/text_area.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a0f4f30c3fe48a5d1581c52b2cf847be5258a93d Binary files /dev/null and b/examples/configForm/img/text_area.jpg differ