From ff0e9cfb1ee0ac812ccf2c6bf52da7ac5b85aa29 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 24 Sep 2020 02:45:31 +0200 Subject: [PATCH] Added breadcrumb management. --- .../statoolinfos/htmlize/AboutPage.java | 4 +- .../statoolinfos/htmlize/Breadcrumb.java | 89 +++++++++++++++ .../statoolinfos/htmlize/BreadcrumbTrail.java | 103 ++++++++++++++++++ .../statoolinfos/htmlize/FederationPage.java | 3 +- .../htmlize/OrganizationPage.java | 4 +- .../htmlize/PropertiesFilesPage.java | 4 +- .../htmlize/PropertyStatsPage.java | 4 +- .../statoolinfos/htmlize/ServicePage.java | 5 +- .../statoolinfos/htmlize/ServicesPage.java | 4 +- .../statoolinfos/htmlize/WebCharterView.java | 22 ++++ .../statoolinfos/htmlize/federation.xhtml | 3 - .../statoolinfos/htmlize/webCharterView.xhtml | 7 +- 12 files changed, 237 insertions(+), 15 deletions(-) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java create mode 100644 src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java diff --git a/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java b/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java index 527d6f9..0d683c0 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/AboutPage.java @@ -52,7 +52,9 @@ public class AboutPage String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/about.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add("À propos", "about.xhtml"); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java b/src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java new file mode 100644 index 0000000..71d1d4a --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/Breadcrumb.java @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +public class Breadcrumb +{ + private String label; + private String link; + + /** + * Instantiates a new breadcrumb. + */ + public Breadcrumb() + { + } + + /** + * Instantiates a new breadcrumb. + * + * @param label + * the label + * @param link + * the link + */ + public Breadcrumb(final String label, final String link) + { + this.label = label; + this.link = link; + } + + /** + * Gets the label. + * + * @return the label + */ + public String getLabel() + { + return this.label; + } + + /** + * Gets the link. + * + * @return the link + */ + public String getLink() + { + return this.link; + } + + /** + * Sets the label. + * + * @param label + * the new label + */ + public void setLabel(final String label) + { + this.label = label; + } + + /** + * Sets the link. + * + * @param link + * the new link + */ + public void setLink(final String link) + { + this.link = link; + } + +} \ No newline at end of file diff --git a/src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java b/src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java new file mode 100644 index 0000000..350a687 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/BreadcrumbTrail.java @@ -0,0 +1,103 @@ +/* + * Copyright (C) 2020 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +import java.util.ArrayList; + +import fr.devinsy.strings.StringList; + +/** + * The Class BreadcrumbTrail. + */ +public class BreadcrumbTrail extends ArrayList +{ + private static final long serialVersionUID = -2688444486042912675L; + + /** + * Instantiates a new breadcrumb trail. + */ + public BreadcrumbTrail() + { + this("🏡", "index.xhtml"); + } + + /** + * Instantiates a new breadcrumb trail. + * + * @param label + * the label + * @param link + * the link + */ + public BreadcrumbTrail(final String label, final String link) + { + super(); + add(label, link); + } + + /** + * Adds the. + * + * @param label + * the label + * @param link + * the link + */ + public BreadcrumbTrail add(final String label, final String link) + { + BreadcrumbTrail result; + + Breadcrumb crumb = new Breadcrumb(label, link); + + add(crumb); + + result = this; + + // + return result; + } + + /** + * To string. + * + * @return the string + */ + @Override + public String toString() + { + String result; + + StringList buffer = new StringList(); + + for (Breadcrumb crumb : this) + { + buffer.append(String.format("%s", crumb.getLink(), crumb.getLabel())); + buffer.append(" > "); + } + if (buffer.size() > 2) + { + buffer.removeLast(); + } + + result = buffer.toString(); + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java index cbe0cf6..1bf0b36 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java @@ -76,7 +76,8 @@ public class FederationPage String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federation.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index d71c543..c544b95 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -77,7 +77,9 @@ public class OrganizationPage String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/organization.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(organization.getName(), organization.getTechnicalName() + ".xhtml"); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java index 5d26d53..7f41ee4 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java @@ -86,7 +86,9 @@ public class PropertiesFilesPage String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertiesFiles.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add("Fichiers", "propertiesFiles.xhtml"); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java index 9811ed0..616dc9d 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyStatsPage.java @@ -140,7 +140,9 @@ public class PropertyStatsPage // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyStats.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add("Propriétés", "propertyStats.xhtml"); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index 006ebbb..4c41c07 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -62,7 +62,10 @@ public class ServicePage String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/service.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(service.getOrganization().getName(), service.getOrganization().getTechnicalName() + ".xhtml"); + trail.add(service.getName(), service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java index da14c6e..478e747 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicesPage.java @@ -74,7 +74,9 @@ public class ServicesPage String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/services.xhtml", data).toString(); - result = WebCharterView.build(content); + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add("Services", "services.xhtml"); + result = WebCharterView.build(content, trail); } catch (XidynException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java b/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java index ba91af8..719817d 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/WebCharterView.java @@ -52,6 +52,27 @@ public class WebCharterView { String result; + result = build(content, new BreadcrumbTrail()); + + // + return result; + } + + /** + * Builds the. + * + * @param content + * the content + * @param trail + * the trail + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String build(final String content, final BreadcrumbTrail trail) throws StatoolInfosException + { + String result; + try { logger.debug("Building WebCharterView."); @@ -61,6 +82,7 @@ public class WebCharterView data.setContent("versionsup", BuildInformation.instance().version()); data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE))); data.setContent("webCharterContent", XidynUtils.extractBodyContent(content)); + data.setContent("breadcrumbTrail", trail.toString()); result = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml", data).toString(); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml index 0678d7b..0ffea95 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml @@ -13,9 +13,6 @@

Federation name

-
- Raw -

Bla bla description

Nombre de membres : n/a
Nombre de services : n/a
diff --git a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml index 262b9c7..bb650cb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/webCharterView.xhtml @@ -19,14 +19,11 @@ Fichiers Propriétés Services - Logiciels + Logiciels Catégories
-
- Fédération > … -
- +