Skip to content

Commit

Permalink
HTML-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Wisser committed Jun 7, 2024
1 parent 98c1006 commit e1ba586
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions admin/ColorManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand All @@ -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();
Expand All @@ -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());
}
Expand Down Expand Up @@ -94,7 +107,7 @@ private String transform(String content) {
colors.put(key, color);
return "<Connection code=\"Colors." + key + "\" type=\"code\"/>";
});

return result;
}
}
Expand Down

0 comments on commit e1ba586

Please sign in to comment.