From 2c3b714c37cf261b56cc85277bd70349780446d7 Mon Sep 17 00:00:00 2001 From: John Ahlroos Date: Tue, 23 Apr 2013 14:09:48 +0300 Subject: addons.scss should contain "addons"-mixin and include all found mixins into that. Also now that addon stylesheet metadata now contains the full path of the stylesheet, the @import should handle it by prefixing the paths with "../" . Change-Id: I9631e8151e053337e6d0fa2023c38faeec7a0a5b --- .../themeutils/SASSAddonImportFileCreator.java | 42 ++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) (limited to 'server') diff --git a/server/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java b/server/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java index 5cec9bd9d5..f199c347eb 100644 --- a/server/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java +++ b/server/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java @@ -45,8 +45,8 @@ public class SASSAddonImportFileCreator { private static final String ADDON_IMPORTS_FILE = "addons.scss"; - private static final String ADDON_IMPORTS_FILE_TEXT = "This file is managed by the Eclipse plug-in and " - + "will be overwritten from time to time. Do not manually edit this file."; + private static final String ADDON_IMPORTS_FILE_TEXT = "This file is automatically managed and " + + "will be overwritten from time to time."; /** * @@ -90,6 +90,8 @@ public class SASSAddonImportFileCreator { printStream.println("/* " + ADDON_IMPORTS_FILE_TEXT + " */"); + printStream.println("/* Do not manually edit this file. */"); + printStream.println(); Map addonThemes = info.getAddonStyles(); @@ -113,37 +115,46 @@ public class SASSAddonImportFileCreator { } }); + List mixins = new ArrayList(); for (String path : paths) { - addImport(printStream, path, addonThemes.get(path)); + mixins.addAll(addImport(printStream, path, + addonThemes.get(path))); printStream.println(); } + createAddonsMixin(printStream, mixins); + } catch (FileNotFoundException e) { // Should not happen since file is checked before this e.printStackTrace(); } } - private static void addImport(PrintStream stream, String file, URL location) { + private static List addImport(PrintStream stream, String file, + URL location) { // Add import comment printImportComment(stream, location); + List foundMixins = new ArrayList(); + if (file.endsWith(".css")) { - stream.print("@import url(\"../" + file + "\");\n"); + stream.print("@import url(\"../../../" + file + "\");\n"); } else { // Assume SASS - stream.print("@import \"../" + file + "\";\n"); + stream.print("@import \"../../../" + file + "\";\n"); - // Convention is to name the mixing after the stylesheet. Strip + // Convention is to name the mixin after the stylesheet. Strip // .scss from filename String mixin = file.substring(file.lastIndexOf("/") + 1, file.length() - ".scss".length()); - stream.print("@include " + mixin + ";"); + foundMixins.add(mixin); } stream.println(); + + return foundMixins; } private static void printImportComment(PrintStream stream, URL location) { @@ -164,8 +175,19 @@ public class SASSAddonImportFileCreator { // location.getPath() returns } - stream.println("/* Added by Vaadin Plug-in for Eclipse from " + path - + " */"); + stream.println("/* Provided by " + path + " */"); + } + + private static void createAddonsMixin(PrintStream stream, + List mixins) { + + stream.println("/* Import and include this mixin into your project theme to include the addon themes */"); + stream.println("@mixin addons {"); + for (String addon : mixins) { + stream.println("\t@include " + addon + ";"); + } + stream.println("}"); + stream.println(); } private static void printUsage() { -- cgit v1.2.3