From 7ac3a80631bef452e1e6d14b5b908438114f9ad7 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sun, 18 Oct 2020 05:17:45 +0200 Subject: [PATCH] Improved category logo management. --- .../devinsy/statoolinfos/core/Category.java | 23 ++++++++++++++++--- src/fr/devinsy/statoolinfos/core/Factory.java | 2 ++ .../statoolinfos/htmlize/category.xhtml | 3 ++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Category.java b/src/fr/devinsy/statoolinfos/core/Category.java index ec6711f..eb6f34c 100644 --- a/src/fr/devinsy/statoolinfos/core/Category.java +++ b/src/fr/devinsy/statoolinfos/core/Category.java @@ -18,6 +18,8 @@ */ package fr.devinsy.statoolinfos.core; +import org.apache.commons.lang3.StringUtils; + import fr.devinsy.strings.StringList; /** @@ -25,6 +27,8 @@ import fr.devinsy.strings.StringList; */ public class Category { + public static final String DEFAULT_LOGO_PATH = "categories/default.png"; + private String name; private String description; private StringList softwares; @@ -38,7 +42,7 @@ public class Category this.name = name; this.description = description; this.softwares = new StringList(); - this.logoPath = "categories/default.png"; + this.logoPath = DEFAULT_LOGO_PATH; } /** @@ -56,7 +60,7 @@ public class Category this.name = name; this.description = description; this.softwares = new StringList(softwares); - this.logoPath = "categories/default.png"; + this.logoPath = DEFAULT_LOGO_PATH; } public String getDescription() @@ -123,9 +127,22 @@ public class Category this.description = description; } + /** + * Sets the logo path. + * + * @param logoPath + * the new logo path + */ public void setLogoPath(final String logoPath) { - this.logoPath = logoPath; + if (StringUtils.isBlank(logoPath)) + { + this.logoPath = DEFAULT_LOGO_PATH; + } + else + { + this.logoPath = logoPath; + } } public void setName(final String name) diff --git a/src/fr/devinsy/statoolinfos/core/Factory.java b/src/fr/devinsy/statoolinfos/core/Factory.java index e9aa1f0..25badcf 100644 --- a/src/fr/devinsy/statoolinfos/core/Factory.java +++ b/src/fr/devinsy/statoolinfos/core/Factory.java @@ -70,6 +70,7 @@ public class Factory String name = properties.get(prefix + ".name"); String description = properties.get(prefix + ".description"); String softwares = properties.get(prefix + ".softwares"); + String logoPath = properties.get(prefix + ".logoPath"); StringList softwareList = new StringList(); if (StringUtils.isNotBlank(softwares)) @@ -81,6 +82,7 @@ public class Factory } Category category = new Category(name, description, softwareList); + category.setLogoPath(logoPath); result.add(category); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/category.xhtml b/src/fr/devinsy/statoolinfos/htmlize/category.xhtml index d4039e6..b5129cd 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/category.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/category.xhtml @@ -17,7 +17,8 @@
-

n/a

+
n/a
+
Nombre de services : n/a