summaryrefslogtreecommitdiffstats
path: root/build/buildhelpers
diff options
context:
space:
mode:
authorJouni Koivuviita <jouni.koivuviita@itmill.com>2008-12-03 06:59:37 +0000
committerJouni Koivuviita <jouni.koivuviita@itmill.com>2008-12-03 06:59:37 +0000
commit9fce7f89912089f2e1197ce3744920f53ced6d43 (patch)
tree055253f328a31b6b07137024e71b2673211197a6 /build/buildhelpers
parente3f647937a3481ab212be1572cdc72bd3c7e5519 (diff)
downloadvaadin-framework-9fce7f89912089f2e1197ce3744920f53ced6d43.tar.gz
vaadin-framework-9fce7f89912089f2e1197ce3744920f53ced6d43.zip
Modified theme build helper to support theme inheritance (to aid in #2269).
svn changeset:6079/svn branch:trunk
Diffstat (limited to 'build/buildhelpers')
-rw-r--r--build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java108
1 files changed, 70 insertions, 38 deletions
diff --git a/build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java b/build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java
index 779b85ec3f..66c4b00bdd 100644
--- a/build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java
+++ b/build/buildhelpers/com/itmill/toolkit/buildhelpers/CompileDefaultTheme.java
@@ -18,62 +18,94 @@ import java.util.Comparator;
*/
public class CompileDefaultTheme {
- private static final String SRCDIR = "./WebContent/ITMILL/themes/default";
+ private static final String THEME_DIR = "./WebContent/ITMILL/themes/";
+ private static final String BONES = "bones";
+ private static final String DEFAULT = "default";
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
- File f = new File(SRCDIR);
+ // combineTheme(new String[] { BONES });
+ combineTheme(new String[] { DEFAULT });
+ }
+
+ /**
+ *
+ * @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();
- 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();
-
- File cssFile = new File(dir.getPath() + "/" + name + ".css");
- if (cssFile.isFile()) {
- 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) {
- if (strLine.indexOf("url(../") > 0) {
- strLine = strLine.replaceAll("url\\(../", ("url\\("));
-
- } else {
- strLine = strLine.replaceAll("url\\(",
- ("url\\(" + name + "/"));
+ 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");
- }
- combinedCss.append(strLine);
+ 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 + "*/");
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();
}
- // Close the input stream
- in.close();
}
}
- BufferedWriter out = new BufferedWriter(new FileWriter(SRCDIR
- + "/styles.css"));
+ 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 " + SRCDIR + "/styles.css ("
+ System.out.println("Compiled CSS to " + THEME_DIR
+ + themeNames[themeNames.length - 1] + "/styles.css ("
+ combinedCss.toString().length() + " bytes)");
-
}
}