From a38814815eb482be6cb5dbb8a097cc875768a8d5 Mon Sep 17 00:00:00 2001 From: stephenconnolly Date: Wed, 1 Aug 2007 08:53:57 +0000 Subject: [PATCH] Simplifying the display logic for health report icons. Providing a mechanism for custom health report icons which are correctly sized. Providing a mechanism for plugins to provide multiple health reports if they know what they are doing! git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3968 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/model/HealthReport.java | 40 +++++++++++++++++++ core/src/main/java/hudson/model/Job.java | 12 +++++- .../resources/lib/hudson/projectView.jelly | 6 +-- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/core/src/main/java/hudson/model/HealthReport.java b/core/src/main/java/hudson/model/HealthReport.java index a7f0e3200c..e43bc0a4c3 100644 --- a/core/src/main/java/hudson/model/HealthReport.java +++ b/core/src/main/java/hudson/model/HealthReport.java @@ -1,6 +1,10 @@ package hudson.model; import java.io.Serializable; +import java.util.List; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; /** * Represents health of something (typically project). @@ -43,6 +47,8 @@ public class HealthReport implements Serializable, Comparable { * If the path begins with a '/' then it will be the absolute path, otherwise the image is * assumed to be in one of /images/16x16/, /images/24x24/ or * /images/32x32/ depending on the icon size selected by the user. + * When calculating the url to display for absolute paths, the getIconUrl(String) method + * will replace /32x32/ in the path with the appropriate size. * @param description The health icon's tool-tip. */ public HealthReport(int score, String iconUrl, String description) { @@ -109,6 +115,21 @@ public class HealthReport implements Serializable, Comparable { return iconUrl; } + /** + * Get's the iconUrl relative to the hudson root url, for the correct size. + * @param size The size, e.g. 32x32, 24x24 or 16x16. + * @return The url relative to hudson's root url. + */ + public String getIconUrl(String size) { + if (iconUrl == null) { + return "/images/" + size + "/" + HEALTH_UNKNOWN; + } + if (iconUrl.startsWith("/")) { + return iconUrl.replace("/32x32/", "/" + size + "/"); + } + return "/images/" + size + "/" + iconUrl; + } + /** * Setter for property 'iconUrl'. * @@ -136,6 +157,25 @@ public class HealthReport implements Serializable, Comparable { this.description = description; } + /** + * Getter for property 'aggregatedReports'. + * + * @return Value for property 'aggregatedReports'. + */ + public List getAggregatedReports() { + return Collections.EMPTY_LIST; + } + + /** + * Getter for property 'aggregateReport'. + * + * @return Value for property 'aggregateReport'. + */ + public boolean isAggregateReport() { + return false; + } + + /** {@inheritDoc} */ public int compareTo(HealthReport o) { return (this.score < o.score ? -1 : (this.score == o.score ? 0 : 1)); } diff --git a/core/src/main/java/hudson/model/Job.java b/core/src/main/java/hudson/model/Job.java index aeb7074fc6..1a63504d9a 100644 --- a/core/src/main/java/hudson/model/Job.java +++ b/core/src/main/java/hudson/model/Job.java @@ -522,12 +522,20 @@ public abstract class Job, RunT extends Runthis.className='healthReport hover';return true; this.className='healthReport';return true; - ${buildHealth.score}% + ${buildHealth.score}%
@@ -59,8 +58,7 @@
- + ${rpt.description} ${rpt.score}