diff options
-rw-r--r-- | server/src/com/vaadin/server/themeutils/SASSAddonImportFileCreator.java | 42 |
1 files changed, 32 insertions, 10 deletions
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<String, URL> addonThemes = info.getAddonStyles(); @@ -113,37 +115,46 @@ public class SASSAddonImportFileCreator { } }); + List<String> mixins = new ArrayList<String>(); 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<String> addImport(PrintStream stream, String file, + URL location) { // Add import comment printImportComment(stream, location); + List<String> foundMixins = new ArrayList<String>(); + 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<String> 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() { |