diff options
Diffstat (limited to 'plugins')
19 files changed, 415 insertions, 63 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.classpath b/plugins/org.eclipse.emf.cdo.examples.server/.classpath index 64c5e31b7a..16057af74c 100644 --- a/plugins/org.eclipse.emf.cdo.examples.server/.classpath +++ b/plugins/org.eclipse.emf.cdo.examples.server/.classpath @@ -3,5 +3,6 @@ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> + <classpathentry kind="src" path="src-gen/"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.jetproperties b/plugins/org.eclipse.emf.cdo.examples.server/.jetproperties new file mode 100644 index 0000000000..7be3f57ef1 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/.jetproperties @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<jet-settings> + <template-container>templates</template-container> <source-container>src-gen</source-container> +</jet-settings> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/.project b/plugins/org.eclipse.emf.cdo.examples.server/.project index b39adbdc1e..e29e7622e8 100644 --- a/plugins/org.eclipse.emf.cdo.examples.server/.project +++ b/plugins/org.eclipse.emf.cdo.examples.server/.project @@ -6,6 +6,11 @@ </projects> <buildSpec> <buildCommand> + <name>org.eclipse.emf.codegen.JETBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> <name>org.eclipse.jdt.core.javabuilder</name> <arguments> </arguments> @@ -22,6 +27,7 @@ </buildCommand> </buildSpec> <natures> + <nature>org.eclipse.emf.codegen.jet.IJETNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.pde.PluginNature</nature> </natures> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF index be29631c35..99d872e744 100644 --- a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/MANIFEST.MF @@ -12,6 +12,15 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo.server.net4j;bundle-version="[3.0.0,4.0.0)", org.eclipse.net4j.db.h2;bundle-version="[3.0.0,4.0.0)", org.eclipse.net4j.jvm;bundle-version="[3.0.0,4.0.0)", - org.eclipse.net4j.tcp;bundle-version="[3.0.0,4.0.0)" + org.eclipse.net4j.tcp;bundle-version="[3.0.0,4.0.0)", + org.apache.commons.logging;bundle-version="[1.0.0,2.0.0)", + org.eclipse.equinox.http.registry;bundle-version="[1.0.0,2.0.0)", + org.eclipse.equinox.http.servlet;bundle-version="[1.0.0,2.0.0)", + org.eclipse.equinox.http.jetty;bundle-version="[2.0.0,4.0.0)" Export-Package: org.eclipse.emf.cdo.examples.server;version="3.0.0" -Import-Package: org.h2.jdbcx;version="[1.1.0,1.2.0)" +Import-Package: org.h2.jdbcx;version="[1.1.0,1.2.0)", + javax.servlet;version="[2.5.0,2.6.0)", + javax.servlet.http;version="[2.5.0,2.6.0)", + org.apache.commons.lang;version="[2.3.0,3.0.0)" +Bundle-Activator: org.eclipse.emf.cdo.examples.server.OM$Activator +Bundle-ActivationPolicy: lazy diff --git a/plugins/org.eclipse.emf.cdo.examples.server/build.properties b/plugins/org.eclipse.emf.cdo.examples.server/build.properties index f4677dcb35..21cf4a5c2c 100644 --- a/plugins/org.eclipse.emf.cdo.examples.server/build.properties +++ b/plugins/org.eclipse.emf.cdo.examples.server/build.properties @@ -15,9 +15,11 @@ bin.includes = .,\ about.html,\ copyright.txt,\ plugin.xml,\ - demo-server.product + demo-server.product,\ + demo-server.css jars.compile.order = . -source.. = src/ +source.. = src/,\ + src-gen/ output.. = bin/ src.includes = about.html,\ copyright.txt diff --git a/plugins/org.eclipse.emf.cdo.examples.server/demo-server.css b/plugins/org.eclipse.emf.cdo.examples.server/demo-server.css new file mode 100644 index 0000000000..9a6ede452e --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/demo-server.css @@ -0,0 +1,17 @@ +body { + background: #1c2a7e; + color: #e2e6ff; + font-family: Arial, sans-serif; +} + +h1,h2,h3,h4 { + margin-bottom: 2px; +} + +h2 { + margin-top: 16px; +} + +h2,h4 { + color: #b7eaef; +} diff --git a/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml b/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml index e70a7e8d4c..5ad426b50f 100644 --- a/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.examples.server/plugin.xml @@ -25,4 +25,20 @@ Eike Stepper - initial API and implementation </product> </extension> + <extension + point="org.eclipse.equinox.http.registry.servlets"> + <servlet + alias="/demo" + class="org.eclipse.emf.cdo.examples.server.DemoServlet" + load-on-startup="true"/> + </extension> + + <extension + point="org.eclipse.equinox.http.registry.resources"> + <resource + alias="/demo.css" + base-name="/demo.css"> + </resource> + </extension> + </plugin> diff --git a/plugins/org.gastro.server.web/templates/MenuCardTemplate.java b/plugins/org.eclipse.emf.cdo.examples.server/src-gen/templates/ConfigOverview.java index fe177342ee..0875b2270b 100644 --- a/plugins/org.gastro.server.web/templates/MenuCardTemplate.java +++ b/plugins/org.eclipse.emf.cdo.examples.server/src-gen/templates/ConfigOverview.java @@ -1,23 +1,22 @@ package templates; -import org.gastro.inventory.*; -import org.gastro.server.internal.web.*; +import org.eclipse.emf.cdo.examples.server.*; -public class MenuCardTemplate +public class ConfigOverview { protected static String nl; - public static synchronized MenuCardTemplate create(String lineSeparator) + public static synchronized ConfigOverview create(String lineSeparator) { nl = lineSeparator; - MenuCardTemplate result = new MenuCardTemplate(); + ConfigOverview result = new ConfigOverview(); nl = null; return result; } public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; - protected final String TEXT_1 = "\t"; + protected final String TEXT_1 = ""; protected final String TEXT_2 = NL + NL + "<html>" + NL + " <header>" + NL + "\t <title>" + NL + "\t\t\t"; - protected final String TEXT_3 = NL + "\t </title>" + NL + "\t\t<link media=\"screen\" href=\"gastro.css\" type=\"text/css\" rel=\"stylesheet\">" + NL + "\t<header>" + NL + "<body>" + NL + "<h1>"; + protected final String TEXT_3 = NL + "\t </title>" + NL + "\t\t<link media=\"screen\" href=\"gastro.css\" type=\"text/css\" rel=\"stylesheet\">" + NL + "\t<header>" + NL + "<body>" + NL + "" + NL + "<h1>"; protected final String TEXT_4 = "</h1>" + NL + "<table border=\"0\" width=\"400\">"; protected final String TEXT_5 = NL + "\t<tr><td colspan=\"3\"><h2>"; protected final String TEXT_6 = "</h2></td></tr>" + NL + "\t<tr><td colspan=\"3\"><h4>"; @@ -26,7 +25,7 @@ public class MenuCardTemplate protected final String TEXT_9 = "</h3></td></tr>" + NL + "\t\t<tr><td> </td><td>"; protected final String TEXT_10 = "</td>" + NL + "\t\t\t\t\t<td align=\"right\" valign=\"bottom\" width=\"80\">"; protected final String TEXT_11 = " </td></tr>" + NL + "\t"; - protected final String TEXT_12 = NL + "</table>" + NL + "</body>" + NL + "</html>"; + protected final String TEXT_12 = NL + "</table>" + NL + "" + NL + "</body>" + NL + "</html>"; protected final String TEXT_13 = NL; public String generate(Object argument) diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src-gen/templates/RequestForm.java b/plugins/org.eclipse.emf.cdo.examples.server/src-gen/templates/RequestForm.java new file mode 100644 index 0000000000..2b0f1e8137 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/src-gen/templates/RequestForm.java @@ -0,0 +1,61 @@ +package templates; + +import org.eclipse.emf.cdo.examples.server.*; + +public class RequestForm +{ + protected static String nl; + public static synchronized RequestForm create(String lineSeparator) + { + nl = lineSeparator; + RequestForm result = new RequestForm(); + nl = null; + return result; + } + + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = ""; + protected final String TEXT_2 = NL + NL + "<html>" + NL + " <header>" + NL + "\t <title>" + NL + "\t\t\t"; + protected final String TEXT_3 = NL + "\t </title>" + NL + "\t\t<link media=\"screen\" href=\"gastro.css\" type=\"text/css\" rel=\"stylesheet\">" + NL + "\t<header>" + NL + "<body>" + NL + "" + NL + "<h1>"; + protected final String TEXT_4 = "</h1>" + NL + "<table border=\"0\" width=\"400\">"; + protected final String TEXT_5 = NL + "\t<tr><td colspan=\"3\"><h2>"; + protected final String TEXT_6 = "</h2></td></tr>" + NL + "\t<tr><td colspan=\"3\"><h4>"; + protected final String TEXT_7 = "</h4></td></tr>" + NL + "\t"; + protected final String TEXT_8 = NL + "\t\t<tr><td> </td><td colspan=\"2\"><h3>"; + protected final String TEXT_9 = "</h3></td></tr>" + NL + "\t\t<tr><td> </td><td>"; + protected final String TEXT_10 = "</td>" + NL + "\t\t\t\t\t<td align=\"right\" valign=\"bottom\" width=\"80\">"; + protected final String TEXT_11 = " </td></tr>" + NL + "\t"; + protected final String TEXT_12 = NL + "</table>" + NL + "" + NL + "</body>" + NL + "</html>"; + protected final String TEXT_13 = NL; + + public String generate(Object argument) + { + final StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(TEXT_1); + MenuCard menuCard = (MenuCard)argument; + stringBuffer.append(TEXT_2); + stringBuffer.append(GastroServlet.html(menuCard.getTitle())); + stringBuffer.append(TEXT_3); + stringBuffer.append(GastroServlet.html(menuCard.getTitle())); + stringBuffer.append(TEXT_4); + for (Section section : menuCard.getSections()) { + stringBuffer.append(TEXT_5); + stringBuffer.append(GastroServlet.html(section.getTitle())); + stringBuffer.append(TEXT_6); + stringBuffer.append(GastroServlet.html(section.getText())); + stringBuffer.append(TEXT_7); + for (Offering offering : section.getOfferings()) { + stringBuffer.append(TEXT_8); + stringBuffer.append(GastroServlet.html(offering.getName())); + stringBuffer.append(TEXT_9); + stringBuffer.append(GastroServlet.html(offering.getDescription())); + stringBuffer.append(TEXT_10); + stringBuffer.append(GastroServlet.html(offering.getPrice())); + stringBuffer.append(TEXT_11); + } + } + stringBuffer.append(TEXT_12); + stringBuffer.append(TEXT_13); + return stringBuffer.toString(); + } +} diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/AbstractTemplateServlet.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/AbstractTemplateServlet.java new file mode 100644 index 0000000000..3684dedf62 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/AbstractTemplateServlet.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * + * Initial Publication: + * Eclipse Magazin - http://www.eclipse-magazin.de + */ +package org.eclipse.emf.cdo.examples.server; + +import org.eclipse.net4j.util.io.IOUtil; + +import org.apache.commons.lang.StringEscapeUtils; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.text.NumberFormat; + +/** + * @author Eike Stepper + */ +public abstract class AbstractTemplateServlet extends HttpServlet +{ + private static final long serialVersionUID = 1L; + + private Object template; + + private Method method; + + public AbstractTemplateServlet(Class<?> templateClass) throws InstantiationException, IllegalAccessException, + SecurityException, NoSuchMethodException + { + method = templateClass.getMethod("generate", Object.class); + template = templateClass.newInstance(); + } + + @Override + public final void init() throws ServletException + { + System.out.println("INIT " + getClass().getSimpleName()); + doInit(); + super.init(); + } + + @Override + public final void destroy() + { + System.out.println("DESTROY " + getClass().getSimpleName()); + doDestroy(); + super.destroy(); + } + + @Override + protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + doPost(req, resp); + } + + @Override + protected final void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + PrintWriter writer = resp.getWriter(); + + try + { + Object argument = getTemplateArgument(req); + String html = (String)method.invoke(template, argument); + writer.print(html); + } + catch (IllegalArgumentException ex) + { + throw new ServletException(ex); + } + catch (IllegalAccessException ex) + { + throw new ServletException(ex); + } + catch (InvocationTargetException ex) + { + throw new ServletException(ex); + } + finally + { + IOUtil.close(writer); + } + } + + protected void doInit() + { + } + + protected void doDestroy() + { + } + + protected abstract Object getTemplateArgument(HttpServletRequest req); + + public static String html(String value) + { + return StringEscapeUtils.escapeHtml(value); + } + + public static String html(double value) + { + return html(NumberFormat.getCurrencyInstance().format(value)); + } +} diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/ConfigOverviewServlet.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/ConfigOverviewServlet.java new file mode 100644 index 0000000000..62a5d970e6 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/ConfigOverviewServlet.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * + * Initial Publication: + * Eclipse Magazin - http://www.eclipse-magazin.de + */ +package org.eclipse.emf.cdo.examples.server; + +import templates.ConfigOverview; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author Eike Stepper + */ +public class ConfigOverviewServlet extends AbstractTemplateServlet +{ + private static final long serialVersionUID = 1L; + + public ConfigOverviewServlet() throws InstantiationException, IllegalAccessException, SecurityException, + NoSuchMethodException + { + super(ConfigOverview.class); + } + + @Override + protected Object getTemplateArgument(HttpServletRequest req) + { + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/RequestFormServlet.java b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/RequestFormServlet.java new file mode 100644 index 0000000000..3da6c0aa19 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/src/org/eclipse/emf/cdo/examples/server/RequestFormServlet.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Eike Stepper - initial API and implementation + * + * Initial Publication: + * Eclipse Magazin - http://www.eclipse-magazin.de + */ +package org.eclipse.emf.cdo.examples.server; + +import templates.RequestForm; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author Eike Stepper + */ +public class RequestFormServlet extends AbstractTemplateServlet +{ + private static final long serialVersionUID = 1L; + + public RequestFormServlet() throws InstantiationException, IllegalAccessException, SecurityException, + NoSuchMethodException + { + super(RequestForm.class); + } + + @Override + protected Object getTemplateArgument(HttpServletRequest req) + { + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.examples.server/templates/configOverview.htmljet b/plugins/org.eclipse.emf.cdo.examples.server/templates/configOverview.htmljet new file mode 100644 index 0000000000..7180b6efc0 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/templates/configOverview.htmljet @@ -0,0 +1,31 @@ +<%@ jet + class="ConfigOverview" + package="templates" + imports="org.eclipse.emf.cdo.examples.server.*" %> + +<% MenuCard menuCard = (MenuCard)argument; %> + +<html> + <header> + <title> + <%=GastroServlet.html(menuCard.getTitle())%> + </title> + <link media="screen" href="gastro.css" type="text/css" rel="stylesheet"> + <header> +<body> + +<h1><%=GastroServlet.html(menuCard.getTitle())%></h1> +<table border="0" width="400"> +<%for (Section section : menuCard.getSections()) {%> + <tr><td colspan="3"><h2><%=GastroServlet.html(section.getTitle())%></h2></td></tr> + <tr><td colspan="3"><h4><%=GastroServlet.html(section.getText())%></h4></td></tr> + <%for (Offering offering : section.getOfferings()) {%> + <tr><td> </td><td colspan="2"><h3><%=GastroServlet.html(offering.getName())%></h3></td></tr> + <tr><td> </td><td><%=GastroServlet.html(offering.getDescription())%></td> + <td align="right" valign="bottom" width="80"><%=GastroServlet.html(offering.getPrice())%> </td></tr> + <%}%> +<%}%> +</table> + +</body> +</html> diff --git a/plugins/org.eclipse.emf.cdo.examples.server/templates/requestForm.htmljet b/plugins/org.eclipse.emf.cdo.examples.server/templates/requestForm.htmljet new file mode 100644 index 0000000000..52c0e87609 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.examples.server/templates/requestForm.htmljet @@ -0,0 +1,31 @@ +<%@ jet + class="RequestForm" + package="templates" + imports="org.eclipse.emf.cdo.examples.server.*" %> + +<% MenuCard menuCard = (MenuCard)argument; %> + +<html> + <header> + <title> + <%=GastroServlet.html(menuCard.getTitle())%> + </title> + <link media="screen" href="gastro.css" type="text/css" rel="stylesheet"> + <header> +<body> + +<h1><%=GastroServlet.html(menuCard.getTitle())%></h1> +<table border="0" width="400"> +<%for (Section section : menuCard.getSections()) {%> + <tr><td colspan="3"><h2><%=GastroServlet.html(section.getTitle())%></h2></td></tr> + <tr><td colspan="3"><h4><%=GastroServlet.html(section.getText())%></h4></td></tr> + <%for (Offering offering : section.getOfferings()) {%> + <tr><td> </td><td colspan="2"><h3><%=GastroServlet.html(offering.getName())%></h3></td></tr> + <tr><td> </td><td><%=GastroServlet.html(offering.getDescription())%></td> + <td align="right" valign="bottom" width="80"><%=GastroServlet.html(offering.getPrice())%> </td></tr> + <%}%> +<%}%> +</table> + +</body> +</html> diff --git a/plugins/org.gastro.server.web/.jetproperties b/plugins/org.gastro.server.web/.jetproperties index cf694b2171..7be3f57ef1 100644 --- a/plugins/org.gastro.server.web/.jetproperties +++ b/plugins/org.gastro.server.web/.jetproperties @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="UTF-8"?> +<?xml version="1.0" encoding="UTF-8" standalone="no"?> <jet-settings> - <template-container>templates</template-container> <source-container></source-container> + <template-container>templates</template-container> <source-container>src-gen</source-container> </jet-settings> diff --git a/plugins/org.gastro.server.web/CommonsLang.README b/plugins/org.gastro.server.web/CommonsLang.README deleted file mode 100644 index a41ebafcb4..0000000000 --- a/plugins/org.gastro.server.web/CommonsLang.README +++ /dev/null @@ -1,3 +0,0 @@ -Das commons.lang jar ist eigentlich ein Bundle und sollte auch als solches in die Target Platform installiert werden! - Für das Packaging dieser Example Anwendung war ein eingebettetes jar jedoch einfacher. -
\ No newline at end of file diff --git a/plugins/org.gastro.server.web/plugin.xml b/plugins/org.gastro.server.web/plugin.xml index f5a31fd2e2..1baa393cd4 100644 --- a/plugins/org.gastro.server.web/plugin.xml +++ b/plugins/org.gastro.server.web/plugin.xml @@ -20,6 +20,7 @@ class="org.gastro.server.internal.web.GastroServlet" load-on-startup="true"/> </extension> + <extension point="org.eclipse.equinox.http.registry.resources"> <resource diff --git a/plugins/org.gastro.server.web/src-gen/templates/MenuCardTemplate.java b/plugins/org.gastro.server.web/src-gen/templates/MenuCardTemplate.java index b8d9796cb4..1ddb695ad9 100644 --- a/plugins/org.gastro.server.web/src-gen/templates/MenuCardTemplate.java +++ b/plugins/org.gastro.server.web/src-gen/templates/MenuCardTemplate.java @@ -1,14 +1,11 @@ package templates; -import org.gastro.inventory.MenuCard; -import org.gastro.inventory.Offering; -import org.gastro.inventory.Section; -import org.gastro.server.internal.web.GastroServlet; +import org.gastro.inventory.*; +import org.gastro.server.internal.web.*; public class MenuCardTemplate { protected static String nl; - public static synchronized MenuCardTemplate create(String lineSeparator) { nl = lineSeparator; @@ -17,63 +14,46 @@ public class MenuCardTemplate return result; } - public final String NL = nl == null ? System.getProperties().getProperty("line.separator") : nl; - - protected final String TEXT_1 = "\t"; - + public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl; + protected final String TEXT_1 = ""; protected final String TEXT_2 = NL + NL + "<html>" + NL + " <header>" + NL + "\t <title>" + NL + "\t\t\t"; - - protected final String TEXT_3 = NL + "\t </title>" + NL - + "\t\t<link media=\"screen\" href=\"gastro.css\" type=\"text/css\" rel=\"stylesheet\">" + NL + "\t<header>" + NL - + "<body>" + NL + "<h1>"; - + protected final String TEXT_3 = NL + "\t </title>" + NL + "\t\t<link media=\"screen\" href=\"gastro.css\" type=\"text/css\" rel=\"stylesheet\">" + NL + "\t<header>" + NL + "<body>" + NL + "" + NL + "<h1>"; protected final String TEXT_4 = "</h1>" + NL + "<table border=\"0\" width=\"400\">"; - protected final String TEXT_5 = NL + "\t<tr><td colspan=\"3\"><h2>"; - protected final String TEXT_6 = "</h2></td></tr>" + NL + "\t<tr><td colspan=\"3\"><h4>"; - protected final String TEXT_7 = "</h4></td></tr>" + NL + "\t"; - protected final String TEXT_8 = NL + "\t\t<tr><td> </td><td colspan=\"2\"><h3>"; - protected final String TEXT_9 = "</h3></td></tr>" + NL + "\t\t<tr><td> </td><td>"; - protected final String TEXT_10 = "</td>" + NL + "\t\t\t\t\t<td align=\"right\" valign=\"bottom\" width=\"80\">"; - protected final String TEXT_11 = " </td></tr>" + NL + "\t"; - - protected final String TEXT_12 = NL + "</table>" + NL + "</body>" + NL + "</html>"; - + protected final String TEXT_12 = NL + "</table>" + NL + "" + NL + "</body>" + NL + "</html>"; protected final String TEXT_13 = NL; public String generate(Object argument) { final StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append(TEXT_1); - MenuCard menuCard = (MenuCard)argument; + MenuCard menuCard = (MenuCard)argument; stringBuffer.append(TEXT_2); stringBuffer.append(GastroServlet.html(menuCard.getTitle())); stringBuffer.append(TEXT_3); stringBuffer.append(GastroServlet.html(menuCard.getTitle())); stringBuffer.append(TEXT_4); - for (Section section : menuCard.getSections()) - { - stringBuffer.append(TEXT_5); - stringBuffer.append(GastroServlet.html(section.getTitle())); - stringBuffer.append(TEXT_6); - stringBuffer.append(GastroServlet.html(section.getText())); - stringBuffer.append(TEXT_7); - for (Offering offering : section.getOfferings()) - { - stringBuffer.append(TEXT_8); - stringBuffer.append(GastroServlet.html(offering.getName())); - stringBuffer.append(TEXT_9); - stringBuffer.append(GastroServlet.html(offering.getDescription())); - stringBuffer.append(TEXT_10); - stringBuffer.append(GastroServlet.html(offering.getPrice())); - stringBuffer.append(TEXT_11); - } + for (Section section : menuCard.getSections()) { + stringBuffer.append(TEXT_5); + stringBuffer.append(GastroServlet.html(section.getTitle())); + stringBuffer.append(TEXT_6); + stringBuffer.append(GastroServlet.html(section.getText())); + stringBuffer.append(TEXT_7); + for (Offering offering : section.getOfferings()) { + stringBuffer.append(TEXT_8); + stringBuffer.append(GastroServlet.html(offering.getName())); + stringBuffer.append(TEXT_9); + stringBuffer.append(GastroServlet.html(offering.getDescription())); + stringBuffer.append(TEXT_10); + stringBuffer.append(GastroServlet.html(offering.getPrice())); + stringBuffer.append(TEXT_11); + } } stringBuffer.append(TEXT_12); stringBuffer.append(TEXT_13); diff --git a/plugins/org.gastro.server.web/templates/menucard.htmljet b/plugins/org.gastro.server.web/templates/menucard.htmljet index ebc37834c0..2e85d7e0ab 100644 --- a/plugins/org.gastro.server.web/templates/menucard.htmljet +++ b/plugins/org.gastro.server.web/templates/menucard.htmljet @@ -1,8 +1,8 @@ -<%@ jet - class="MenuCardTemplate" - package="templates" +<%@ jet + class="MenuCardTemplate" + package="templates" imports="org.gastro.inventory.* org.gastro.server.internal.web.*" %> - + <% MenuCard menuCard = (MenuCard)argument; %> <html> @@ -13,6 +13,7 @@ <link media="screen" href="gastro.css" type="text/css" rel="stylesheet"> <header> <body> + <h1><%=GastroServlet.html(menuCard.getTitle())%></h1> <table border="0" width="400"> <%for (Section section : menuCard.getSections()) {%> @@ -25,5 +26,6 @@ <%}%> <%}%> </table> + </body> </html> |