From 1c59d56532bc4330445fa3c15fb7369572881b75 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 29 Oct 2020 19:41:53 +0100 Subject: [PATCH] Improved property check. --- .../statoolinfos/checker/PropertyChecks.java | 5 +- .../htmlize/PropertyFileCheckPage.java | 83 ++++++++++++------- .../htmlize/propertyFileCheck.xhtml | 44 +++++++++- 3 files changed, 101 insertions(+), 31 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java b/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java index 79fcccb..28a8d7d 100644 --- a/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java +++ b/src/fr/devinsy/statoolinfos/checker/PropertyChecks.java @@ -19,6 +19,7 @@ package fr.devinsy.statoolinfos.checker; import java.util.ArrayList; +import java.util.regex.Pattern; import fr.devinsy.statoolinfos.core.Service.Status; @@ -48,9 +49,11 @@ public class PropertyChecks extends ArrayList result = new PropertyChecks(); + Pattern pattern = Pattern.compile("^(\\s*[^#\\s]|#\\s*\\[).*$"); + for (PropertyCheck check : this) { - if (!check.getLine().matches("^(|#\\s?[^\\[].*)$")) + if (pattern.matcher(check.getLine()).matches()) { result.add(check); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java index 742a03d..63c31d6 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckPage.java @@ -33,6 +33,7 @@ import fr.devinsy.statoolinfos.checker.PropertyChecks; import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Service; +import fr.devinsy.statoolinfos.core.Service.Status; import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; @@ -108,36 +109,19 @@ public class PropertyFileCheckPage data.setContent("line", index, "lineIndex", check.getIndex()); data.setEscapedContent("line", index, "lineComment", check.getComment()); data.setEscapedContent("line", index, "lineContent", check.getLine()); + data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus())); + index += 1; + } + + index = 0; + for (PropertyCheck check : checks.extractActiveLines()) + { // - String statusClass; - switch (check.getStatus()) - { - case OK: - statusClass = "bg_ok"; - break; - - case WARNING: - statusClass = "bg_warning"; - break; - - case ALERT: - statusClass = "bg_alert"; - break; - - case ERROR: - statusClass = "bg_error"; - break; - - case OVER: - statusClass = "bg_over"; - break; - - case VOID: - default: - statusClass = "bg_void"; - } - data.setAttribute("line", index, "lineContent", "class", statusClass); + data.setContent("shrunkLine", index, "shrunkLineIndex", check.getIndex()); + data.setEscapedContent("shrunkLine", index, "shrunkLineContent", check.getLine()); + data.setEscapedContent("shrunkLine", index, "shrunkLineComment", check.getComment()); + data.setAttribute("shrunkLine", index, "shrunkLineContent", "class", statusToCSS(check.getStatus())); index += 1; } @@ -157,4 +141,47 @@ public class PropertyFileCheckPage // return result; } + + /** + * Status to CSS. + * + * @param status + * the status + * @return the string + */ + public static String statusToCSS(final Status status) + { + String result; + + switch (status) + { + case OK: + result = "bg_ok"; + break; + + case WARNING: + result = "bg_warning"; + break; + + case ALERT: + result = "bg_alert"; + break; + + case ERROR: + result = "bg_error"; + break; + + case OVER: + result = "bg_over"; + break; + + case VOID: + default: + result = "bg_void"; + } + + // + return result; + } + } diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml index 9eee313..5f8a1be 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml @@ -16,7 +16,15 @@

n/a


-
+
+ Shrunk + +
+ +
@@ -27,6 +35,38 @@
-
+ + + + +