summaryrefslogtreecommitdiffstats
path: root/build/buildhelpers/com
diff options
context:
space:
mode:
authorJouni Koivuviita <jouni.koivuviita@itmill.com>2009-08-27 12:26:49 +0000
committerJouni Koivuviita <jouni.koivuviita@itmill.com>2009-08-27 12:26:49 +0000
commitad101f842727ca84a184f1bf1ad7c5e63878302b (patch)
treeb636516fa19ef5dab996c9160e576e3169e50f7b /build/buildhelpers/com
parent7072fbb2f053ab9a390ee5e004d65e465c7b93e7 (diff)
downloadvaadin-framework-ad101f842727ca84a184f1bf1ad7c5e63878302b.tar.gz
vaadin-framework-ad101f842727ca84a184f1bf1ad7c5e63878302b.zip
The Button Component Strikes Back
Fixes many theme issues with Button (mostly Reindeer theme), including #3110, #3193, #3194, #3180 and 3079. Default button is now rendered on the client side with a DIV. Disabled buttons can now have descriptions, which fixes #2085. Added a "new" component, NativeButton, which uses native BUTTON element rendering on the client side. Theme compilation script now understands simple @import statements, which help keep things more organized in theme development. svn changeset:8558/svn branch:6.1
Diffstat (limited to 'build/buildhelpers/com')
-rw-r--r--build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java112
1 files changed, 71 insertions, 41 deletions
diff --git a/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java b/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java
index 9e0455e474..96d5a3440a 100644
--- a/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java
+++ b/build/buildhelpers/com/vaadin/buildhelpers/CompileDefaultTheme.java
@@ -41,6 +41,8 @@ public class CompileDefaultTheme {
* inheritance). The order is the same in which the styles are
* catenated. The resulted file is placed in the last specified
* theme folder.
+ *
+ * @param
* @throws IOException
*/
private static void combineTheme(String[] themeNames,
@@ -54,53 +56,19 @@ public class CompileDefaultTheme {
.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);
+ Arrays.sort(subdir, new Comparator<File>() {
+ public int compare(File arg0, File arg1) {
+ return arg0.compareTo(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");
+ String folder = dir.getName();
+ String filename = dir.getPath() + "/" + folder + ".css";
- 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();
- }
+ processCSSFile(new File(filename), folder, themeNames[j],
+ combinedCss, j < themeNames.length - 1);
}
}
@@ -131,6 +99,68 @@ public class CompileDefaultTheme {
}
}
+ private static void processCSSFile(File cssFile, String folder,
+ String themeName, StringBuffer combinedCss, boolean inheritedFile)
+ throws FileNotFoundException, IOException {
+ if (cssFile.isFile()) {
+
+ 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) {
+
+ // Parse import rules
+ if (strLine.startsWith("@import")) {
+ // All import statements must be exactly
+ // @import "file-to-import.css";
+ // No sub-directories are allowed in the url
+ String importFilename = strLine.split("\"")[1];
+
+ File importFile = new File(THEME_DIR + themeName + "/"
+ + folder + "/" + importFilename);
+ if (importFile.isFile()) {
+ processCSSFile(importFile, folder, themeName,
+ combinedCss, inheritedFile);
+ } else {
+ System.out
+ .println("File not found for @import statement "
+ + THEME_DIR
+ + themeName
+ + "/"
+ + folder
+ + "/" + importFilename);
+ }
+ }
+
+ // Define image url prefix
+ String urlPrefix = "";
+ if (inheritedFile) {
+ urlPrefix = "../" + themeName + "/";
+ }
+
+ if (strLine.indexOf("url(../") > 0) {
+ strLine = strLine.replaceAll("url\\(../",
+ ("url\\(" + urlPrefix));
+
+ } else {
+ strLine = strLine.replaceAll("url\\(", ("url\\("
+ + urlPrefix + folder + "/"));
+
+ }
+ if (!strLine.startsWith("@import")) {
+ combinedCss.append(strLine);
+ combinedCss.append("\n");
+ }
+ }
+ // Close the input stream
+ in.close();
+ }
+ }
+
private static void createSprites(String themeName)
throws FileNotFoundException, IOException {
String[] parameters = new String[] { "--sprite-png-depth", "AUTO",