]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixes buildhelper class package names.
authorJouni Koivuviita <jouni.koivuviita@itmill.com>
Mon, 11 May 2009 13:03:22 +0000 (13:03 +0000)
committerJouni Koivuviita <jouni.koivuviita@itmill.com>
Mon, 11 May 2009 13:03:22 +0000 (13:03 +0000)
svn changeset:7734/svn branch:6.0

build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java [deleted file]
build/buildhelpers/com/itmill/toolkit/buildhelpers/PortletConfigurationGenerator.java [deleted file]
build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java [new file with mode: 0644]
build/buildhelpers/com/vaadin/buildhelpers/PortletConfigurationGenerator.java [new file with mode: 0644]

diff --git a/build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java b/build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java
deleted file mode 100644 (file)
index 0ed54a9..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-package com.vaadin.buildhelpers;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.DataInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.Comparator;
-
-/**
- * Helper to combine css diveded into separate per component dirs into one to
- * optimize http requests.
- * 
- */
-public class CompileDefaultTheme {
-
-    private static final String THEME_DIR = "./WebContent/ITMILL/themes/";
-    private static final String BASE = "base";
-    private static final String DEFAULT = "default";
-    private static final String REINDEER = "reindeer";
-
-    /**
-     * @param args
-     * @throws IOException
-     */
-    public static void main(String[] args) throws IOException {
-        combineTheme(new String[] { BASE });
-        combineTheme(new String[] { BASE, DEFAULT });
-        combineTheme(new String[] { BASE, REINDEER });
-    }
-
-    /**
-     * 
-     * @param themeNames
-     *            All themes that should be combined together (to include
-     *            inheritance). The order is the same in which the styles are
-     *            catenated. The resulted file is placed in the last specified
-     *            theme folder.
-     * @throws IOException
-     */
-    private static void combineTheme(String[] themeNames) throws IOException {
-
-        StringBuffer combinedCss = new StringBuffer();
-
-        for (int j = 0; j < themeNames.length; j++) {
-            File f = new File(THEME_DIR + themeNames[j]);
-            combinedCss
-                    .append("/* Automatically compiled css file from subdirectories. */\n");
-
-            File[] subdir = f.listFiles();
-            Arrays.sort(subdir, new Comparator() {
-                public int compare(Object arg0, Object arg1) {
-                    return ((File) arg0).compareTo((File) arg1);
-                }
-            });
-
-            for (int i = 0; i < subdir.length; i++) {
-                File dir = subdir[i];
-                String name = dir.getName();
-                String filename = dir.getPath() + "/" + name + ".css";
-
-                File cssFile = new File(filename);
-                if (cssFile.isFile()) {
-
-                    combinedCss.append("\n");
-                    combinedCss.append("/* " + filename.replaceAll("\\\\", "/")
-                            + " */");
-                    combinedCss.append("\n");
-
-                    FileInputStream fstream = new FileInputStream(cssFile);
-                    // Get the object of DataInputStream
-                    DataInputStream in = new DataInputStream(fstream);
-                    BufferedReader br = new BufferedReader(
-                            new InputStreamReader(in));
-                    String strLine;
-                    while ((strLine = br.readLine()) != null) {
-                        // Define image url prefix
-                        String urlPrefix = "";
-                        if (j < themeNames.length - 1) {
-                            urlPrefix = "../" + themeNames[j] + "/";
-                        }
-
-                        if (strLine.indexOf("url(../") > 0) {
-                            strLine = strLine.replaceAll("url\\(../",
-                                    ("url\\(" + urlPrefix));
-
-                        } else {
-                            strLine = strLine.replaceAll("url\\(", ("url\\("
-                                    + urlPrefix + name + "/"));
-
-                        }
-                        combinedCss.append(strLine);
-                        combinedCss.append("\n");
-                    }
-                    // Close the input stream
-                    in.close();
-                }
-            }
-        }
-
-        BufferedWriter out = new BufferedWriter(new FileWriter(THEME_DIR
-                + themeNames[themeNames.length - 1] + "/styles.css"));
-        out.write(combinedCss.toString());
-        out.close();
-
-        System.out.println("Compiled CSS to " + THEME_DIR
-                + themeNames[themeNames.length - 1] + "/styles.css ("
-                + combinedCss.toString().length() + " bytes)");
-    }
-}
diff --git a/build/buildhelpers/com/itmill/toolkit/buildhelpers/PortletConfigurationGenerator.java b/build/buildhelpers/com/itmill/toolkit/buildhelpers/PortletConfigurationGenerator.java
deleted file mode 100644 (file)
index 638e85b..0000000
+++ /dev/null
@@ -1,403 +0,0 @@
-/**\r
- * \r
- */\r
-package com.vaadin.buildhelpers;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.File;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.FileReader;\r
-import java.io.IOException;\r
-import java.io.OutputStreamWriter;\r
-import java.nio.charset.Charset;\r
-import java.util.regex.Matcher;\r
-import java.util.regex.Pattern;\r
-\r
-/**\r
- * Generates portlet.xml, liferay-portlet.xml, liferay-display.xml from web.xml.\r
- * Currently uses regular expressions to avoid dependencies; does not strictly\r
- * adhere to xml rules, but should work with a 'normal' web.xml.\r
- * \r
- * To be included, the servlet-mapping must include a special comment: <!--\r
- * portlet --> If the portlet requires some special styles (i.e height): <!--\r
- * portlet style=height:400px -->\r
- * \r
- * @author marc\r
- */\r
-public class PortletConfigurationGenerator {\r
-    // can be changed for debugging:\r
-    private static final String WEB_XML_FILE = "web.xml";\r
-    private static final String PORTLET_XML_FILE = "portlet.xml";\r
-    private static final String LIFERAY_PORTLET_XML_FILE = "liferay-portlet.xml";\r
-    private static final String LIFERAY_DISPLAY_XML_FILE = "liferay-display.xml";\r
-    private static final String JBOSS_OBJECT_FILE = "itmill-object.xml";\r
-    private static final String JBOSS_INSTANCE_FILE = "portlet-instances.xml";\r
-\r
-    // "templates" follow;\r
-    private static final String PORTLET_XML_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"\r
-            + "<portlet-app\n"\r
-            + "        xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"\n"\r
-            + "        version=\"1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"\r
-            + "        xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\">\n";\r
-    private static final String PORTLET_XML_SECTION = "        <portlet>\n"\r
-            + "                <portlet-name>%PORTLETNAME%</portlet-name>\n"\r
-            + "                <display-name>IT Mill Toolkit %NAME%</display-name>\n"\r
-            + "                <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet</portlet-class>\n"\r
-            + "                <init-param>\n"\r
-            + "                        <name>application</name>\n"\r
-            + "                        <value>%URL%</value>\n"\r
-            + "                </init-param>\n"\r
-            + "                %EXTRAPARAMS%\n"\r
-            + "                <supports>\n"\r
-            + "                        <mime-type>text/html</mime-type>\n"\r
-            + "                        <portlet-mode>view</portlet-mode>\n"\r
-            + "                        <portlet-mode>edit</portlet-mode>\n"\r
-            + "                        <portlet-mode>help</portlet-mode>\n"\r
-            + "                </supports>\n"\r
-            + "                <portlet-info>\n"\r
-            + "                        <title>%NAME%</title>\n"\r
-            + "                        <short-title>%NAME%</short-title>\n"\r
-            + "                </portlet-info>\n" + "                \n"\r
-            + "                <security-role-ref>\n"\r
-            + "                        <role-name>administrator</role-name>\n"\r
-            + "                </security-role-ref>\n"\r
-            + "                <security-role-ref>\n"\r
-            + "                        <role-name>guest</role-name>\n"\r
-            + "                </security-role-ref>\n"\r
-            + "                <security-role-ref>\n"\r
-            + "                        <role-name>power-user</role-name>\n"\r
-            + "                </security-role-ref>\n"\r
-            + "                <security-role-ref>\n"\r
-            + "                        <role-name>user</role-name>\n"\r
-            + "                </security-role-ref>\n" + "        </portlet>\n";\r
-    private static final String PORTLET_XML_FOOT = "\n" + "</portlet-app>";\r
-\r
-    private static final String LIFERAY_PORTLET_XML_HEAD = "<?xml version=\"1.0\"?>\n"\r
-            + "<!DOCTYPE liferay-portlet-app PUBLIC \"-//Liferay//DTD Portlet Application 4.3.0//EN\" \"http://www.liferay.com/dtd/liferay-portlet-app_4_3_0.dtd\">\n"\r
-            + "\n" + "<liferay-portlet-app>\n" + "";\r
-    private static final String LIFERAY_PORTLET_XML_SECTION = "        <portlet>\n"\r
-            + "                <portlet-name>%PORTLETNAME%</portlet-name>\n"\r
-            + "                <instanceable>true</instanceable>       \n"\r
-            + "                <ajaxable>false</ajaxable>\n"\r
-            + "        </portlet>\n" + "";\r
-    private static final String LIFERAY_PORTLET_XML_FOOT = "    \n"\r
-            + "        <role-mapper>\n"\r
-            + "                <role-name>administrator</role-name>\n"\r
-            + "                <role-link>Administrator</role-link>\n"\r
-            + "        </role-mapper>\n" + "        <role-mapper>\n"\r
-            + "                <role-name>guest</role-name>\n"\r
-            + "                <role-link>Guest</role-link>\n"\r
-            + "        </role-mapper>\n" + "        <role-mapper>\n"\r
-            + "                <role-name>power-user</role-name>\n"\r
-            + "                <role-link>Power User</role-link>\n"\r
-            + "        </role-mapper>\n" + "        <role-mapper>\n"\r
-            + "                <role-name>user</role-name>\n"\r
-            + "                <role-link>User</role-link>\n"\r
-            + "        </role-mapper>\n" + "        \n"\r
-            + "</liferay-portlet-app>";\r
-    private static final String LIFERAY_DISPLAY_XML_HEAD = "<?xml version=\"1.0\"?>\n"\r
-            + "<!DOCTYPE display PUBLIC \"-//Liferay//DTD Display 4.0.0//EN\" \"http://www.liferay.com/dtd/liferay-display_4_0_0.dtd\">\n"\r
-            + "\n"\r
-            + "<display>\n"\r
-            + "        <category name=\"IT Mill Toolkit\">\n" + "";\r
-    private static final String LIFERAY_DISPLAY_XML_SECTION = "                <portlet id=\"%PORTLETNAME%\" />\n";\r
-    private static final String LIFERAY_DISPLAY_XML_FOOT = "\n"\r
-            + "        </category>\n" + "</display>";\r
-\r
-    private static final String JBOSS_INSTANCE_HEAD = "<?xml version=\"1.0\" standalone=\"yes\"?>\r\n"\r
-            + "<!DOCTYPE deployments PUBLIC\r\n"\r
-            + "   \"-//JBoss Portal//DTD Portlet Instances 2.6//EN\"\r\n"\r
-            + "   \"http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd\">\r\n"\r
-            + "<deployments>\r\n";\r
-    private static final String JBOSS_INSTANCE_SECTION = "   <deployment>\r\n      <instance>\r\n"\r
-            + "         <instance-id>%PORTLETNAME%Instance</instance-id>\r\n"\r
-            + "         <portlet-ref>%PORTLETNAME%</portlet-ref>\r\n"\r
-            + "      </instance>\r\n   </deployment>\r\n";\r
-    private static final String JBOSS_INSTANCE_FOOT = "</deployments>";\r
-    private static final String JBOSS_OBJECT_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"\r
-            + "<!DOCTYPE deployments PUBLIC\r\n"\r
-            + "   \"-//JBoss Portal//DTD Portal Object 2.6//EN\"\r\n"\r
-            + "   \"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd\">\r\n"\r
-            + "<deployments>\r\n";\r
-    private static final String JBOSS_OBJECT_SECTION = "   <deployment>\r\n"\r
-            + "      <parent-ref>default.default</parent-ref>\r\n"\r
-            + "      <if-exists>overwrite</if-exists>"\r
-            + "      <window>\r\n"\r
-            + "         <window-name>%PORTLETNAME%Window</window-name>\r\n"\r
-            + "         <content>\r\n"\r
-            + "                <content-type>portlet</content-type>\r\n"\r
-            + "                <content-uri>%PORTLETNAME%Instance</content-uri>\r\n"\r
-            + "         </content>\r\n"\r
-            + "         <region>center</region>\r\n"\r
-            + "         <height>1</height>\r\n"\r
-            + "      </window>\r\n   </deployment>\r\n";\r
-    private static final String JBOSS_OBJECT_FOOT = "</deployments>";\r
-\r
-    /**\r
-     * @param args\r
-     *            <path to directory with web.xml> [default widgetset to use]\r
-     */\r
-    public static void main(String[] args) {\r
-        if (args.length < 1 || !new File(args[0]).isDirectory()) {\r
-            System.err\r
-                    .println("Usage: PortletConfigurationGenerator <directory> [widgetset]");\r
-            return;\r
-        }\r
-\r
-        String widgetset = "";\r
-        if (args.length > 1) {\r
-            widgetset = args[1];\r
-        }\r
-\r
-        /*\r
-         * Read web.xml\r
-         */\r
-        File dir = new File(args[0]);\r
-        File webxmlFile = new File(dir.getAbsolutePath() + File.separatorChar\r
-                + WEB_XML_FILE);\r
-        String webXml = "";\r
-        BufferedReader in = null;\r
-        try {\r
-            in = new BufferedReader(new FileReader(webxmlFile));\r
-            String line = in.readLine();\r
-            while (line != null) {\r
-                webXml += line;\r
-                line = in.readLine();\r
-            }\r
-        } catch (FileNotFoundException e1) {\r
-            System.out.println(webxmlFile + " not found!");\r
-            return;\r
-        } catch (IOException e2) {\r
-            System.out.println("IOException while reading " + webxmlFile);\r
-            webXml = null;\r
-        }\r
-        try {\r
-            if (in != null) {\r
-                in.close();\r
-            }\r
-        } catch (IOException e1) {\r
-            System.out.println("IOException while closing " + webxmlFile);\r
-        }\r
-        if (webXml == null) {\r
-            System.out.println("Could not read web.xml!");\r
-            return;\r
-        }\r
-\r
-        /*\r
-         * Open outputs\r
-         */\r
-\r
-        // Open portlet.xml\r
-        File portletXmlFile = new File(args[0] + File.separatorChar\r
-                + PORTLET_XML_FILE);\r
-        OutputStreamWriter pout = null;\r
-        try {\r
-            pout = new OutputStreamWriter(new FileOutputStream(portletXmlFile),\r
-                    Charset.forName("UTF-8"));\r
-        } catch (FileNotFoundException e) {\r
-            System.out.println(portletXmlFile + " not found!");\r
-        }\r
-        // open liferay-portlet.xml\r
-        File liferayPortletXmlFile = new File(args[0] + File.separatorChar\r
-                + LIFERAY_PORTLET_XML_FILE);\r
-        OutputStreamWriter lpout = null;\r
-        try {\r
-            lpout = new OutputStreamWriter(new FileOutputStream(\r
-                    liferayPortletXmlFile), Charset.forName("UTF-8"));\r
-        } catch (FileNotFoundException e) {\r
-            System.out.println(liferayPortletXmlFile + " not found!");\r
-        }\r
-        // open liferay-display.xml\r
-        File liferayDisplayXmlFile = new File(args[0] + File.separatorChar\r
-                + LIFERAY_DISPLAY_XML_FILE);\r
-        OutputStreamWriter ldout = null;\r
-        try {\r
-            ldout = new OutputStreamWriter(new FileOutputStream(\r
-                    liferayDisplayXmlFile), Charset.forName("UTF-8"));\r
-        } catch (FileNotFoundException e) {\r
-            System.out.println(liferayDisplayXmlFile + " not found!");\r
-        }\r
-        // open jboss object.xml\r
-        File jbossObjectXmlFile = new File(args[0] + File.separatorChar\r
-                + JBOSS_OBJECT_FILE);\r
-        OutputStreamWriter joout = null;\r
-        try {\r
-            joout = new OutputStreamWriter(new FileOutputStream(\r
-                    jbossObjectXmlFile), Charset.forName("UTF-8"));\r
-        } catch (FileNotFoundException e) {\r
-            System.out.println(jbossObjectXmlFile + " not found!");\r
-        }\r
-        // open jboss instance.xml\r
-        File jbossInstanceXmlFile = new File(args[0] + File.separatorChar\r
-                + JBOSS_INSTANCE_FILE);\r
-        OutputStreamWriter jiout = null;\r
-        try {\r
-            jiout = new OutputStreamWriter(new FileOutputStream(\r
-                    jbossInstanceXmlFile), Charset.forName("UTF-8"));\r
-        } catch (FileNotFoundException e) {\r
-            System.out.println(jbossInstanceXmlFile + " not found!");\r
-        }\r
-\r
-        if (pout != null && lpout != null && ldout != null && joout != null\r
-                && jiout != null) {\r
-\r
-            String pstring = PORTLET_XML_HEAD;\r
-            String lpstring = LIFERAY_PORTLET_XML_HEAD;\r
-            String ldstring = LIFERAY_DISPLAY_XML_HEAD;\r
-            String jostring = JBOSS_OBJECT_HEAD;\r
-            String jistring = JBOSS_INSTANCE_HEAD;\r
-\r
-            Pattern p1 = Pattern\r
-                    .compile("<servlet-mapping>.*?<servlet-name>(.*?)<\\/servlet-name>.*?<url-pattern>(.*?)<\\/url-pattern>(.*?)<\\/servlet-mapping>");\r
-            Pattern p2 = Pattern\r
-                    .compile(".*?<!--\\s+portlet\\s?style=([^ ]*)?\\s+-->.*?");\r
-            Pattern findWidgetset = Pattern\r
-                    .compile("<init-param>.*?<param-name>widgetset<\\/param-name>.*?<param-value>(.*?)<\\/param-value>");\r
-\r
-            Matcher m = p1.matcher(webXml);\r
-            while (m.find()) {\r
-                if (m.groupCount() < 3) {\r
-                    // don't include\r
-                    continue;\r
-                }\r
-\r
-                String name = m.group(1);\r
-                // remove leading- and trailing whitespace\r
-                name = name.replaceAll("^\\s*", "");\r
-                name = name.replaceAll("\\s*$", "");\r
-\r
-                String comment = m.group(3);\r
-                Matcher m2 = p2.matcher(comment);\r
-                if (!m2.find()) {\r
-                    // don't include\r
-                    continue;\r
-                }\r
-\r
-                String style = "";\r
-                if (m2.groupCount() == 1 && m2.group(1) != null\r
-                        && !m2.group(1).equals("")) {\r
-                    style = "<init-param><name>style</name><value>"\r
-                            + m2.group(1) + "</value></init-param>";\r
-                }\r
-\r
-                // Find widgetset\r
-                Pattern findServlet = Pattern\r
-                        .compile("<servlet>.*?<servlet-name>" + name\r
-                                + "<\\/servlet-name>(.*?)<\\/servlet>");\r
-                Matcher servletMatcher = findServlet.matcher(webXml);\r
-                if (servletMatcher.find()) {\r
-                    String servletXml = servletMatcher.group(1);\r
-                    Matcher widgetsetMatcher = findWidgetset\r
-                            .matcher(servletXml);\r
-                    if (widgetsetMatcher.find()) {\r
-                        String definedWidgetSet = widgetsetMatcher.group(1);\r
-                        if (!definedWidgetSet.equals(widgetset)) {\r
-                            System.err\r
-                                    .println("WARNING: Widgetset in web.xml ("\r
-                                            + definedWidgetSet\r
-                                            + ") does not match used ("\r
-                                            + widgetset + ")");\r
-                        }\r
-                    }\r
-                }\r
-\r
-                if (widgetset != null && !widgetset.equals("")) {\r
-                    System.err.println("Using widgetset: " + widgetset);\r
-                    style += "\n                "\r
-                            + "<init-param><name>widgetset</name><value>"\r
-                            + widgetset + "</value></init-param>";\r
-\r
-                }\r
-\r
-                String pname = name + "Portlet";\r
-                String url = m.group(2);\r
-                // remove leading- and trailing whitespace\r
-                url = url.replaceAll("^\\s*", "");\r
-                url = url.replaceAll("\\s*$", "");\r
-                if (url.startsWith("/")) {\r
-                    url = url.substring(1);\r
-                }\r
-                if (url.endsWith("*")) {\r
-                    url = url.substring(0, url.length() - 1);\r
-                }\r
-                if (url.endsWith("/")) {\r
-                    url = url.substring(0, url.length() - 1);\r
-                }\r
-\r
-                System.out.println("Mapping " + pname + " to " + url);\r
-\r
-                String s = PORTLET_XML_SECTION;\r
-                s = s.replaceAll("%NAME%", name);\r
-                s = s.replaceAll("%PORTLETNAME%", pname);\r
-                s = s.replaceAll("%URL%", url);\r
-                s = s.replaceAll("%EXTRAPARAMS%", style);\r
-\r
-                pstring += s;\r
-\r
-                s = LIFERAY_PORTLET_XML_SECTION;\r
-                s = s.replaceAll("%NAME%", name);\r
-                s = s.replaceAll("%PORTLETNAME%", pname);\r
-                s = s.replaceAll("%URL%", url);\r
-                lpstring += s;\r
-\r
-                s = LIFERAY_DISPLAY_XML_SECTION;\r
-                s = s.replaceAll("%NAME%", name);\r
-                s = s.replaceAll("%PORTLETNAME%", pname);\r
-                s = s.replaceAll("%URL%", url);\r
-                ldstring += s;\r
-\r
-                s = JBOSS_OBJECT_SECTION;\r
-                s = s.replaceAll("%NAME%", name);\r
-                s = s.replaceAll("%PORTLETNAME%", pname);\r
-                s = s.replaceAll("%URL%", url);\r
-                jostring += s;\r
-\r
-                s = JBOSS_INSTANCE_SECTION;\r
-                s = s.replaceAll("%NAME%", name);\r
-                s = s.replaceAll("%PORTLETNAME%", pname);\r
-                s = s.replaceAll("%URL%", url);\r
-                jistring += s;\r
-\r
-            }\r
-\r
-            pstring += PORTLET_XML_FOOT;\r
-            lpstring += LIFERAY_PORTLET_XML_FOOT;\r
-            ldstring += LIFERAY_DISPLAY_XML_FOOT;\r
-            jostring += JBOSS_OBJECT_FOOT;\r
-            jistring += JBOSS_INSTANCE_FOOT;\r
-\r
-            try {\r
-                pout.write(pstring);\r
-                lpout.write(lpstring);\r
-                ldout.write(ldstring);\r
-                joout.write(jostring);\r
-                jiout.write(jistring);\r
-            } catch (IOException e) {\r
-                System.out.println("Write FAILED:" + e);\r
-            }\r
-\r
-        }\r
-\r
-        try {\r
-            if (pout != null) {\r
-                pout.close();\r
-            }\r
-            if (lpout != null) {\r
-                lpout.close();\r
-            }\r
-            if (ldout != null) {\r
-                ldout.close();\r
-            }\r
-            if (joout != null) {\r
-                joout.close();\r
-            }\r
-            if (jiout != null) {\r
-                jiout.close();\r
-            }\r
-        } catch (IOException e) {\r
-            System.out.println("Close FAILED: " + e);\r
-        }\r
-        System.out.println("Done.");\r
-    }\r
-}\r
diff --git a/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java b/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java
new file mode 100644 (file)
index 0000000..0ed54a9
--- /dev/null
@@ -0,0 +1,114 @@
+package com.vaadin.buildhelpers;
+
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+import java.util.Comparator;
+
+/**
+ * Helper to combine css diveded into separate per component dirs into one to
+ * optimize http requests.
+ * 
+ */
+public class CompileDefaultTheme {
+
+    private static final String THEME_DIR = "./WebContent/ITMILL/themes/";
+    private static final String BASE = "base";
+    private static final String DEFAULT = "default";
+    private static final String REINDEER = "reindeer";
+
+    /**
+     * @param args
+     * @throws IOException
+     */
+    public static void main(String[] args) throws IOException {
+        combineTheme(new String[] { BASE });
+        combineTheme(new String[] { BASE, DEFAULT });
+        combineTheme(new String[] { BASE, REINDEER });
+    }
+
+    /**
+     * 
+     * @param themeNames
+     *            All themes that should be combined together (to include
+     *            inheritance). The order is the same in which the styles are
+     *            catenated. The resulted file is placed in the last specified
+     *            theme folder.
+     * @throws IOException
+     */
+    private static void combineTheme(String[] themeNames) throws IOException {
+
+        StringBuffer combinedCss = new StringBuffer();
+
+        for (int j = 0; j < themeNames.length; j++) {
+            File f = new File(THEME_DIR + themeNames[j]);
+            combinedCss
+                    .append("/* Automatically compiled css file from subdirectories. */\n");
+
+            File[] subdir = f.listFiles();
+            Arrays.sort(subdir, new Comparator() {
+                public int compare(Object arg0, Object arg1) {
+                    return ((File) arg0).compareTo((File) arg1);
+                }
+            });
+
+            for (int i = 0; i < subdir.length; i++) {
+                File dir = subdir[i];
+                String name = dir.getName();
+                String filename = dir.getPath() + "/" + name + ".css";
+
+                File cssFile = new File(filename);
+                if (cssFile.isFile()) {
+
+                    combinedCss.append("\n");
+                    combinedCss.append("/* " + filename.replaceAll("\\\\", "/")
+                            + " */");
+                    combinedCss.append("\n");
+
+                    FileInputStream fstream = new FileInputStream(cssFile);
+                    // Get the object of DataInputStream
+                    DataInputStream in = new DataInputStream(fstream);
+                    BufferedReader br = new BufferedReader(
+                            new InputStreamReader(in));
+                    String strLine;
+                    while ((strLine = br.readLine()) != null) {
+                        // Define image url prefix
+                        String urlPrefix = "";
+                        if (j < themeNames.length - 1) {
+                            urlPrefix = "../" + themeNames[j] + "/";
+                        }
+
+                        if (strLine.indexOf("url(../") > 0) {
+                            strLine = strLine.replaceAll("url\\(../",
+                                    ("url\\(" + urlPrefix));
+
+                        } else {
+                            strLine = strLine.replaceAll("url\\(", ("url\\("
+                                    + urlPrefix + name + "/"));
+
+                        }
+                        combinedCss.append(strLine);
+                        combinedCss.append("\n");
+                    }
+                    // Close the input stream
+                    in.close();
+                }
+            }
+        }
+
+        BufferedWriter out = new BufferedWriter(new FileWriter(THEME_DIR
+                + themeNames[themeNames.length - 1] + "/styles.css"));
+        out.write(combinedCss.toString());
+        out.close();
+
+        System.out.println("Compiled CSS to " + THEME_DIR
+                + themeNames[themeNames.length - 1] + "/styles.css ("
+                + combinedCss.toString().length() + " bytes)");
+    }
+}
diff --git a/build/buildhelpers/com/vaadin/buildhelpers/PortletConfigurationGenerator.java b/build/buildhelpers/com/vaadin/buildhelpers/PortletConfigurationGenerator.java
new file mode 100644 (file)
index 0000000..638e85b
--- /dev/null
@@ -0,0 +1,403 @@
+/**\r
+ * \r
+ */\r
+package com.vaadin.buildhelpers;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.FileOutputStream;\r
+import java.io.FileReader;\r
+import java.io.IOException;\r
+import java.io.OutputStreamWriter;\r
+import java.nio.charset.Charset;\r
+import java.util.regex.Matcher;\r
+import java.util.regex.Pattern;\r
+\r
+/**\r
+ * Generates portlet.xml, liferay-portlet.xml, liferay-display.xml from web.xml.\r
+ * Currently uses regular expressions to avoid dependencies; does not strictly\r
+ * adhere to xml rules, but should work with a 'normal' web.xml.\r
+ * \r
+ * To be included, the servlet-mapping must include a special comment: <!--\r
+ * portlet --> If the portlet requires some special styles (i.e height): <!--\r
+ * portlet style=height:400px -->\r
+ * \r
+ * @author marc\r
+ */\r
+public class PortletConfigurationGenerator {\r
+    // can be changed for debugging:\r
+    private static final String WEB_XML_FILE = "web.xml";\r
+    private static final String PORTLET_XML_FILE = "portlet.xml";\r
+    private static final String LIFERAY_PORTLET_XML_FILE = "liferay-portlet.xml";\r
+    private static final String LIFERAY_DISPLAY_XML_FILE = "liferay-display.xml";\r
+    private static final String JBOSS_OBJECT_FILE = "itmill-object.xml";\r
+    private static final String JBOSS_INSTANCE_FILE = "portlet-instances.xml";\r
+\r
+    // "templates" follow;\r
+    private static final String PORTLET_XML_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"\r
+            + "<portlet-app\n"\r
+            + "        xmlns=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\"\n"\r
+            + "        version=\"1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"\r
+            + "        xsi:schemaLocation=\"http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd\">\n";\r
+    private static final String PORTLET_XML_SECTION = "        <portlet>\n"\r
+            + "                <portlet-name>%PORTLETNAME%</portlet-name>\n"\r
+            + "                <display-name>IT Mill Toolkit %NAME%</display-name>\n"\r
+            + "                <portlet-class>com.vaadin.terminal.gwt.server.ApplicationPortlet</portlet-class>\n"\r
+            + "                <init-param>\n"\r
+            + "                        <name>application</name>\n"\r
+            + "                        <value>%URL%</value>\n"\r
+            + "                </init-param>\n"\r
+            + "                %EXTRAPARAMS%\n"\r
+            + "                <supports>\n"\r
+            + "                        <mime-type>text/html</mime-type>\n"\r
+            + "                        <portlet-mode>view</portlet-mode>\n"\r
+            + "                        <portlet-mode>edit</portlet-mode>\n"\r
+            + "                        <portlet-mode>help</portlet-mode>\n"\r
+            + "                </supports>\n"\r
+            + "                <portlet-info>\n"\r
+            + "                        <title>%NAME%</title>\n"\r
+            + "                        <short-title>%NAME%</short-title>\n"\r
+            + "                </portlet-info>\n" + "                \n"\r
+            + "                <security-role-ref>\n"\r
+            + "                        <role-name>administrator</role-name>\n"\r
+            + "                </security-role-ref>\n"\r
+            + "                <security-role-ref>\n"\r
+            + "                        <role-name>guest</role-name>\n"\r
+            + "                </security-role-ref>\n"\r
+            + "                <security-role-ref>\n"\r
+            + "                        <role-name>power-user</role-name>\n"\r
+            + "                </security-role-ref>\n"\r
+            + "                <security-role-ref>\n"\r
+            + "                        <role-name>user</role-name>\n"\r
+            + "                </security-role-ref>\n" + "        </portlet>\n";\r
+    private static final String PORTLET_XML_FOOT = "\n" + "</portlet-app>";\r
+\r
+    private static final String LIFERAY_PORTLET_XML_HEAD = "<?xml version=\"1.0\"?>\n"\r
+            + "<!DOCTYPE liferay-portlet-app PUBLIC \"-//Liferay//DTD Portlet Application 4.3.0//EN\" \"http://www.liferay.com/dtd/liferay-portlet-app_4_3_0.dtd\">\n"\r
+            + "\n" + "<liferay-portlet-app>\n" + "";\r
+    private static final String LIFERAY_PORTLET_XML_SECTION = "        <portlet>\n"\r
+            + "                <portlet-name>%PORTLETNAME%</portlet-name>\n"\r
+            + "                <instanceable>true</instanceable>       \n"\r
+            + "                <ajaxable>false</ajaxable>\n"\r
+            + "        </portlet>\n" + "";\r
+    private static final String LIFERAY_PORTLET_XML_FOOT = "    \n"\r
+            + "        <role-mapper>\n"\r
+            + "                <role-name>administrator</role-name>\n"\r
+            + "                <role-link>Administrator</role-link>\n"\r
+            + "        </role-mapper>\n" + "        <role-mapper>\n"\r
+            + "                <role-name>guest</role-name>\n"\r
+            + "                <role-link>Guest</role-link>\n"\r
+            + "        </role-mapper>\n" + "        <role-mapper>\n"\r
+            + "                <role-name>power-user</role-name>\n"\r
+            + "                <role-link>Power User</role-link>\n"\r
+            + "        </role-mapper>\n" + "        <role-mapper>\n"\r
+            + "                <role-name>user</role-name>\n"\r
+            + "                <role-link>User</role-link>\n"\r
+            + "        </role-mapper>\n" + "        \n"\r
+            + "</liferay-portlet-app>";\r
+    private static final String LIFERAY_DISPLAY_XML_HEAD = "<?xml version=\"1.0\"?>\n"\r
+            + "<!DOCTYPE display PUBLIC \"-//Liferay//DTD Display 4.0.0//EN\" \"http://www.liferay.com/dtd/liferay-display_4_0_0.dtd\">\n"\r
+            + "\n"\r
+            + "<display>\n"\r
+            + "        <category name=\"IT Mill Toolkit\">\n" + "";\r
+    private static final String LIFERAY_DISPLAY_XML_SECTION = "                <portlet id=\"%PORTLETNAME%\" />\n";\r
+    private static final String LIFERAY_DISPLAY_XML_FOOT = "\n"\r
+            + "        </category>\n" + "</display>";\r
+\r
+    private static final String JBOSS_INSTANCE_HEAD = "<?xml version=\"1.0\" standalone=\"yes\"?>\r\n"\r
+            + "<!DOCTYPE deployments PUBLIC\r\n"\r
+            + "   \"-//JBoss Portal//DTD Portlet Instances 2.6//EN\"\r\n"\r
+            + "   \"http://www.jboss.org/portal/dtd/portlet-instances_2_6.dtd\">\r\n"\r
+            + "<deployments>\r\n";\r
+    private static final String JBOSS_INSTANCE_SECTION = "   <deployment>\r\n      <instance>\r\n"\r
+            + "         <instance-id>%PORTLETNAME%Instance</instance-id>\r\n"\r
+            + "         <portlet-ref>%PORTLETNAME%</portlet-ref>\r\n"\r
+            + "      </instance>\r\n   </deployment>\r\n";\r
+    private static final String JBOSS_INSTANCE_FOOT = "</deployments>";\r
+    private static final String JBOSS_OBJECT_HEAD = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"\r
+            + "<!DOCTYPE deployments PUBLIC\r\n"\r
+            + "   \"-//JBoss Portal//DTD Portal Object 2.6//EN\"\r\n"\r
+            + "   \"http://www.jboss.org/portal/dtd/portal-object_2_6.dtd\">\r\n"\r
+            + "<deployments>\r\n";\r
+    private static final String JBOSS_OBJECT_SECTION = "   <deployment>\r\n"\r
+            + "      <parent-ref>default.default</parent-ref>\r\n"\r
+            + "      <if-exists>overwrite</if-exists>"\r
+            + "      <window>\r\n"\r
+            + "         <window-name>%PORTLETNAME%Window</window-name>\r\n"\r
+            + "         <content>\r\n"\r
+            + "                <content-type>portlet</content-type>\r\n"\r
+            + "                <content-uri>%PORTLETNAME%Instance</content-uri>\r\n"\r
+            + "         </content>\r\n"\r
+            + "         <region>center</region>\r\n"\r
+            + "         <height>1</height>\r\n"\r
+            + "      </window>\r\n   </deployment>\r\n";\r
+    private static final String JBOSS_OBJECT_FOOT = "</deployments>";\r
+\r
+    /**\r
+     * @param args\r
+     *            <path to directory with web.xml> [default widgetset to use]\r
+     */\r
+    public static void main(String[] args) {\r
+        if (args.length < 1 || !new File(args[0]).isDirectory()) {\r
+            System.err\r
+                    .println("Usage: PortletConfigurationGenerator <directory> [widgetset]");\r
+            return;\r
+        }\r
+\r
+        String widgetset = "";\r
+        if (args.length > 1) {\r
+            widgetset = args[1];\r
+        }\r
+\r
+        /*\r
+         * Read web.xml\r
+         */\r
+        File dir = new File(args[0]);\r
+        File webxmlFile = new File(dir.getAbsolutePath() + File.separatorChar\r
+                + WEB_XML_FILE);\r
+        String webXml = "";\r
+        BufferedReader in = null;\r
+        try {\r
+            in = new BufferedReader(new FileReader(webxmlFile));\r
+            String line = in.readLine();\r
+            while (line != null) {\r
+                webXml += line;\r
+                line = in.readLine();\r
+            }\r
+        } catch (FileNotFoundException e1) {\r
+            System.out.println(webxmlFile + " not found!");\r
+            return;\r
+        } catch (IOException e2) {\r
+            System.out.println("IOException while reading " + webxmlFile);\r
+            webXml = null;\r
+        }\r
+        try {\r
+            if (in != null) {\r
+                in.close();\r
+            }\r
+        } catch (IOException e1) {\r
+            System.out.println("IOException while closing " + webxmlFile);\r
+        }\r
+        if (webXml == null) {\r
+            System.out.println("Could not read web.xml!");\r
+            return;\r
+        }\r
+\r
+        /*\r
+         * Open outputs\r
+         */\r
+\r
+        // Open portlet.xml\r
+        File portletXmlFile = new File(args[0] + File.separatorChar\r
+                + PORTLET_XML_FILE);\r
+        OutputStreamWriter pout = null;\r
+        try {\r
+            pout = new OutputStreamWriter(new FileOutputStream(portletXmlFile),\r
+                    Charset.forName("UTF-8"));\r
+        } catch (FileNotFoundException e) {\r
+            System.out.println(portletXmlFile + " not found!");\r
+        }\r
+        // open liferay-portlet.xml\r
+        File liferayPortletXmlFile = new File(args[0] + File.separatorChar\r
+                + LIFERAY_PORTLET_XML_FILE);\r
+        OutputStreamWriter lpout = null;\r
+        try {\r
+            lpout = new OutputStreamWriter(new FileOutputStream(\r
+                    liferayPortletXmlFile), Charset.forName("UTF-8"));\r
+        } catch (FileNotFoundException e) {\r
+            System.out.println(liferayPortletXmlFile + " not found!");\r
+        }\r
+        // open liferay-display.xml\r
+        File liferayDisplayXmlFile = new File(args[0] + File.separatorChar\r
+                + LIFERAY_DISPLAY_XML_FILE);\r
+        OutputStreamWriter ldout = null;\r
+        try {\r
+            ldout = new OutputStreamWriter(new FileOutputStream(\r
+                    liferayDisplayXmlFile), Charset.forName("UTF-8"));\r
+        } catch (FileNotFoundException e) {\r
+            System.out.println(liferayDisplayXmlFile + " not found!");\r
+        }\r
+        // open jboss object.xml\r
+        File jbossObjectXmlFile = new File(args[0] + File.separatorChar\r
+                + JBOSS_OBJECT_FILE);\r
+        OutputStreamWriter joout = null;\r
+        try {\r
+            joout = new OutputStreamWriter(new FileOutputStream(\r
+                    jbossObjectXmlFile), Charset.forName("UTF-8"));\r
+        } catch (FileNotFoundException e) {\r
+            System.out.println(jbossObjectXmlFile + " not found!");\r
+        }\r
+        // open jboss instance.xml\r
+        File jbossInstanceXmlFile = new File(args[0] + File.separatorChar\r
+                + JBOSS_INSTANCE_FILE);\r
+        OutputStreamWriter jiout = null;\r
+        try {\r
+            jiout = new OutputStreamWriter(new FileOutputStream(\r
+                    jbossInstanceXmlFile), Charset.forName("UTF-8"));\r
+        } catch (FileNotFoundException e) {\r
+            System.out.println(jbossInstanceXmlFile + " not found!");\r
+        }\r
+\r
+        if (pout != null && lpout != null && ldout != null && joout != null\r
+                && jiout != null) {\r
+\r
+            String pstring = PORTLET_XML_HEAD;\r
+            String lpstring = LIFERAY_PORTLET_XML_HEAD;\r
+            String ldstring = LIFERAY_DISPLAY_XML_HEAD;\r
+            String jostring = JBOSS_OBJECT_HEAD;\r
+            String jistring = JBOSS_INSTANCE_HEAD;\r
+\r
+            Pattern p1 = Pattern\r
+                    .compile("<servlet-mapping>.*?<servlet-name>(.*?)<\\/servlet-name>.*?<url-pattern>(.*?)<\\/url-pattern>(.*?)<\\/servlet-mapping>");\r
+            Pattern p2 = Pattern\r
+                    .compile(".*?<!--\\s+portlet\\s?style=([^ ]*)?\\s+-->.*?");\r
+            Pattern findWidgetset = Pattern\r
+                    .compile("<init-param>.*?<param-name>widgetset<\\/param-name>.*?<param-value>(.*?)<\\/param-value>");\r
+\r
+            Matcher m = p1.matcher(webXml);\r
+            while (m.find()) {\r
+                if (m.groupCount() < 3) {\r
+                    // don't include\r
+                    continue;\r
+                }\r
+\r
+                String name = m.group(1);\r
+                // remove leading- and trailing whitespace\r
+                name = name.replaceAll("^\\s*", "");\r
+                name = name.replaceAll("\\s*$", "");\r
+\r
+                String comment = m.group(3);\r
+                Matcher m2 = p2.matcher(comment);\r
+                if (!m2.find()) {\r
+                    // don't include\r
+                    continue;\r
+                }\r
+\r
+                String style = "";\r
+                if (m2.groupCount() == 1 && m2.group(1) != null\r
+                        && !m2.group(1).equals("")) {\r
+                    style = "<init-param><name>style</name><value>"\r
+                            + m2.group(1) + "</value></init-param>";\r
+                }\r
+\r
+                // Find widgetset\r
+                Pattern findServlet = Pattern\r
+                        .compile("<servlet>.*?<servlet-name>" + name\r
+                                + "<\\/servlet-name>(.*?)<\\/servlet>");\r
+                Matcher servletMatcher = findServlet.matcher(webXml);\r
+                if (servletMatcher.find()) {\r
+                    String servletXml = servletMatcher.group(1);\r
+                    Matcher widgetsetMatcher = findWidgetset\r
+                            .matcher(servletXml);\r
+                    if (widgetsetMatcher.find()) {\r
+                        String definedWidgetSet = widgetsetMatcher.group(1);\r
+                        if (!definedWidgetSet.equals(widgetset)) {\r
+                            System.err\r
+                                    .println("WARNING: Widgetset in web.xml ("\r
+                                            + definedWidgetSet\r
+                                            + ") does not match used ("\r
+                                            + widgetset + ")");\r
+                        }\r
+                    }\r
+                }\r
+\r
+                if (widgetset != null && !widgetset.equals("")) {\r
+                    System.err.println("Using widgetset: " + widgetset);\r
+                    style += "\n                "\r
+                            + "<init-param><name>widgetset</name><value>"\r
+                            + widgetset + "</value></init-param>";\r
+\r
+                }\r
+\r
+                String pname = name + "Portlet";\r
+                String url = m.group(2);\r
+                // remove leading- and trailing whitespace\r
+                url = url.replaceAll("^\\s*", "");\r
+                url = url.replaceAll("\\s*$", "");\r
+                if (url.startsWith("/")) {\r
+                    url = url.substring(1);\r
+                }\r
+                if (url.endsWith("*")) {\r
+                    url = url.substring(0, url.length() - 1);\r
+                }\r
+                if (url.endsWith("/")) {\r
+                    url = url.substring(0, url.length() - 1);\r
+                }\r
+\r
+                System.out.println("Mapping " + pname + " to " + url);\r
+\r
+                String s = PORTLET_XML_SECTION;\r
+                s = s.replaceAll("%NAME%", name);\r
+                s = s.replaceAll("%PORTLETNAME%", pname);\r
+                s = s.replaceAll("%URL%", url);\r
+                s = s.replaceAll("%EXTRAPARAMS%", style);\r
+\r
+                pstring += s;\r
+\r
+                s = LIFERAY_PORTLET_XML_SECTION;\r
+                s = s.replaceAll("%NAME%", name);\r
+                s = s.replaceAll("%PORTLETNAME%", pname);\r
+                s = s.replaceAll("%URL%", url);\r
+                lpstring += s;\r
+\r
+                s = LIFERAY_DISPLAY_XML_SECTION;\r
+                s = s.replaceAll("%NAME%", name);\r
+                s = s.replaceAll("%PORTLETNAME%", pname);\r
+                s = s.replaceAll("%URL%", url);\r
+                ldstring += s;\r
+\r
+                s = JBOSS_OBJECT_SECTION;\r
+                s = s.replaceAll("%NAME%", name);\r
+                s = s.replaceAll("%PORTLETNAME%", pname);\r
+                s = s.replaceAll("%URL%", url);\r
+                jostring += s;\r
+\r
+                s = JBOSS_INSTANCE_SECTION;\r
+                s = s.replaceAll("%NAME%", name);\r
+                s = s.replaceAll("%PORTLETNAME%", pname);\r
+                s = s.replaceAll("%URL%", url);\r
+                jistring += s;\r
+\r
+            }\r
+\r
+            pstring += PORTLET_XML_FOOT;\r
+            lpstring += LIFERAY_PORTLET_XML_FOOT;\r
+            ldstring += LIFERAY_DISPLAY_XML_FOOT;\r
+            jostring += JBOSS_OBJECT_FOOT;\r
+            jistring += JBOSS_INSTANCE_FOOT;\r
+\r
+            try {\r
+                pout.write(pstring);\r
+                lpout.write(lpstring);\r
+                ldout.write(ldstring);\r
+                joout.write(jostring);\r
+                jiout.write(jistring);\r
+            } catch (IOException e) {\r
+                System.out.println("Write FAILED:" + e);\r
+            }\r
+\r
+        }\r
+\r
+        try {\r
+            if (pout != null) {\r
+                pout.close();\r
+            }\r
+            if (lpout != null) {\r
+                lpout.close();\r
+            }\r
+            if (ldout != null) {\r
+                ldout.close();\r
+            }\r
+            if (joout != null) {\r
+                joout.close();\r
+            }\r
+            if (jiout != null) {\r
+                jiout.close();\r
+            }\r
+        } catch (IOException e) {\r
+            System.out.println("Close FAILED: " + e);\r
+        }\r
+        System.out.println("Done.");\r
+    }\r
+}\r