From e1ba5860d285258dda944d9604135de2c34fa620 Mon Sep 17 00:00:00 2001 From: Ralf Wisser Date: Fri, 7 Jun 2024 11:38:25 +0200 Subject: [PATCH] HTML-support --- admin/ColorManager.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/admin/ColorManager.java b/admin/ColorManager.java index 041efa66c..3305e283d 100644 --- a/admin/ColorManager.java +++ b/admin/ColorManager.java @@ -20,7 +20,6 @@ public class ColorManager { public static void main(String[] args) throws IOException { - Path sourcePath = new File("src/main/gui").toPath(); Files.walkFileTree(sourcePath, new FileVisitor()); @@ -31,7 +30,11 @@ public static void main(String[] args) throws IOException { out.println(); out.println("public class Colors {"); colors.forEach((key, color) -> { - out.println("\tpublic static Color " + key + " = " + color+ ";"); + if (key.startsWith("HTML")) { + out.println("\tpublic static String " + key + " = " + color+ ";"); + } else { + out.println("\tpublic static Color " + key + " = " + color+ ";"); + } }); out.println("}"); out.close(); @@ -57,6 +60,16 @@ public FileVisitResult visitFile(final Path file, final BasicFileAttributes attr System.out.println(file); String content = new String(Files.readAllBytes(file)); String result = transform(content); + if (file.getFileName().toString().matches(".*\\.java")) { + result = find("color\\s*=\\s*\\\\\"(?:\\#)?([0-9a-zA-Z]+)\\\\\"", + result, m -> { + String key = "HTMLColor_" + m.group(1); + String color = "\"#" + m.group(1) + "\""; + System.out.println("!" + key); + colors.put(key, color); + return "\" + Colors." + key + " + \""; + }); + } if (!result.equals(content) && !file.getFileName().toString().matches(".*\\bColors\\.java")) { Files.write(file, result.getBytes()); } @@ -94,7 +107,7 @@ private String transform(String content) { colors.put(key, color); return ""; }); - + return result; } }