From: Matti Tahvonen Date: Mon, 4 Jun 2007 12:53:03 +0000 (+0000) Subject: reverted to same state before 1531 X-Git-Tag: 6.7.0.beta1~6359 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=f5a4d984b3ef0a4df06123cc92db98e87a887857;p=vaadin-framework.git reverted to same state before 1531 svn changeset:1570/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java index 7e2d823fd2..38e25ba7e1 100644 --- a/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java +++ b/src/com/itmill/toolkit/terminal/web/ApplicationServlet.java @@ -82,6 +82,7 @@ import com.itmill.toolkit.terminal.ThemeResource; import com.itmill.toolkit.terminal.URIHandler; import com.itmill.toolkit.terminal.Paintable.RepaintRequestEvent; import com.itmill.toolkit.terminal.web.ThemeSource.ThemeException; +import com.itmill.toolkit.terminal.web.WebBrowser; import com.itmill.toolkit.ui.Window; /** @@ -875,34 +876,59 @@ public class ApplicationServlet extends HttpServlet implements Theme theme) throws IOException, MalformedURLException { response.setContentType("text/html"); BufferedWriter page = new BufferedWriter(new OutputStreamWriter(out)); - + page .write("\n"); - + page .write("\n" + window.getCaption() + "\n"); + page + .write("\n"); + Theme t = theme; + Vector themes = new Vector(); + themes.add(t); + while (t.getParent() != null) { + String parentName = t.getParent(); + t = themeSource.getThemeByName(parentName); + themes.add(t); + } + for (int k = themes.size() - 1; k >= 0; k--) { + t = (Theme) themes.get(k); + Collection files = t.getFileNames(terminalType, Theme.MODE_AJAX); + for (Iterator i = files.iterator(); i.hasNext();) { + String file = (String) i.next(); + if (file.endsWith(".css")) + page.write("\n"); + else if (file.endsWith(".js")) { + page.write("\n"); + } + } - page.write("\n"); - page.write(""); + } page.write("\n"); - page.write("\n"); page.write("
Loading...
\n"); - + page.write("
\n"); - - if(isDebugMode(unhandledParameters)) - page.write(""); - - page.write("\n"); - - page.write("\n"); - page.close(); - } - /** - * Writes javascript for this theme and terminal - * - * @param response - * the HTTP response to write to. - * @param terminalType - * @param theme - * @throws IOException - * if the writing failed due to input/output error. - */ - private void writeJavascript(HttpServletResponse response, - WebBrowser terminalType, Theme theme) throws IOException, MalformedURLException { - response.setContentType("text/javascript"); - BufferedWriter page = new BufferedWriter(new OutputStreamWriter(response.getOutputStream())); - getThemeResourcesWithType(".js",terminalType, theme, page); - page.close(); - } + page.write("\n"); - /** - * Writes javascript for this theme and terminal - * - * @param response - * the HTTP response to write to. - * @param terminalType - * @param theme - * @throws IOException - * if the writing failed due to input/output error. - */ - private void writeCss(HttpServletResponse response, WebBrowser terminalType, - Theme theme) throws IOException, MalformedURLException { - response.setContentType("text/css"); - BufferedWriter page = new BufferedWriter(new OutputStreamWriter(response.getOutputStream())); - getThemeResourcesWithType(".css",terminalType, theme, page); + page.write("\n"); page.close(); } - /** - * Catenates all themes required files that which ends with type into a StringBuffer. - * Used to serve browser only a single javascript or css file - * - * @param terminalType - * @param theme - * @throws IOException - * if the writing failed due to input/output error. - * @return StringBuffer containing all themes javascript - */ - private void getThemeResourcesWithType(String type, WebBrowser terminalType, - Theme theme, BufferedWriter out) throws IOException { - Vector themes = new Vector(); - themes.add(theme); - while (theme.getParent() != null) { - String parentName = theme.getParent(); - theme = themeSource.getThemeByName(parentName); - themes.add(theme); - } - - for (int k = themes.size() - 1; k >= 0; k--) { - theme = (Theme) themes.get(k); - Collection files = theme.getFileNames(terminalType, Theme.MODE_AJAX); - for (Iterator i = files.iterator(); i.hasNext();) { - String file = (String) i.next(); - if (file.endsWith(type)) { - try { - InputStreamReader in = new InputStreamReader(themeSource.getResource(theme.getName() + "/" + file)); - - char[] b = new char[DEFAULT_BUFFER_SIZE]; - int read = 0; - while((read = in.read(b, 0, DEFAULT_BUFFER_SIZE)) > 0) - out.write(b,0,read); - } catch (ThemeException e) { - e.printStackTrace(); - } - } - } - } - } - - /** * Handles the requested URI. An application can add handlers to do special * processing, when a certain URI is requested. The handlers are invoked @@ -1239,33 +1191,6 @@ public class ApplicationServlet extends HttpServlet implements // Checks if this really is a resource request if (resourceId == null || !resourceId.startsWith(RESOURCE_URI)) return false; - - if (resourceId.endsWith("compiledstyle.css") || resourceId.endsWith("compiledjavascript.js")) { - String[] parts = resourceId.split("/"); - - Theme t = themeSource.getThemeByName(parts[2]); - try { - WebBrowser wb = WebBrowserProbe.getTerminalType(request.getSession()); - if(wb == null) { - // Request is propably coming from self made html file, run browser probe - WebBrowserProbe - .handleProbeRequest(request, new HashMap()); - wb = WebBrowserProbe.getTerminalType(request.getSession()); - } - if(resourceId.endsWith("compiledstyle.css")) { - writeCss(response, wb, t); - } else { - writeJavascript(response, WebBrowserProbe.getTerminalType(request - .getSession()), t); - } - } catch (IOException e) { - e.printStackTrace(); - } - return true; - } - if(resourceId.endsWith("compiledjavascript.js")) { - return true; - } // Checks the resource type resourceId = resourceId.substring(RESOURCE_URI.length());