Skip to content
Permalink
Browse files
Merge pull request #2 from jenkinsci/JENKINS-36472
[JENKINS-36472] depend on Icon Shim Plugin
  • Loading branch information
cpoenisch committed Jan 6, 2017
2 parents 5e8f792 + 2a0a74d commit d8bdb345c0fc021c78d410eb1fa93f1dc86c0b0c
Showing with 142 additions and 119 deletions.
  1. +11 −5 pom.xml
  2. +47 −0 src/main/java/de/tracetronic/jenkins/plugins/ecutest/ETPlugin.java
  3. +17 −40 src/main/java/de/tracetronic/jenkins/plugins/ecutest/report/AbstractReportAction.java
  4. +8 −8 src/main/java/de/tracetronic/jenkins/plugins/ecutest/report/atx/AbstractATXAction.java
  5. +2 −11 ...n/java/de/tracetronic/jenkins/plugins/ecutest/report/generator/AbstractReportGeneratorAction.java
  6. +2 −2 src/main/java/de/tracetronic/jenkins/plugins/ecutest/report/log/AbstractETLogAction.java
  7. +2 −2 src/main/java/de/tracetronic/jenkins/plugins/ecutest/report/trf/AbstractTRFAction.java
  8. +20 −18 src/main/resources/de/tracetronic/jenkins/plugins/ecutest/report/atx/ATXBuildAction/index.jelly
  9. +7 −7 src/main/resources/de/tracetronic/jenkins/plugins/ecutest/report/atx/ATXBuildAction/report.jelly
  10. +6 −6 ...es/de/tracetronic/jenkins/plugins/ecutest/report/generator/ReportGeneratorBuildAction/index.jelly
  11. +2 −2 ...s/de/tracetronic/jenkins/plugins/ecutest/report/generator/ReportGeneratorBuildAction/report.jelly
  12. +6 −6 src/main/resources/de/tracetronic/jenkins/plugins/ecutest/report/log/ETLogBuildAction/index.jelly
  13. +2 −2 src/main/resources/de/tracetronic/jenkins/plugins/ecutest/report/log/ETLogBuildAction/report.jelly
  14. +7 −7 src/main/resources/de/tracetronic/jenkins/plugins/ecutest/report/trf/TRFBuildAction/index.jelly
  15. +3 −3 src/main/resources/de/tracetronic/jenkins/plugins/ecutest/report/trf/TRFBuildAction/report.jelly
  16. BIN src/main/webapp/icons/16x16/atx-report.png
  17. BIN src/main/webapp/icons/16x16/atx-trend.png
  18. BIN src/main/webapp/icons/16x16/ecu-test-pkg.png
  19. BIN src/main/webapp/icons/16x16/ecu-test-prj.png
  20. BIN src/main/webapp/icons/16x16/ecu-test.png
  21. BIN src/main/webapp/icons/16x16/report-generator.png
  22. BIN src/main/webapp/icons/16x16/test-guide.png
  23. BIN src/main/webapp/icons/16x16/trf-report.png
  24. BIN src/main/webapp/icons/24x24/{atx.png → atx-report.png}
  25. BIN src/main/webapp/icons/24x24/ecu-test.png
  26. BIN src/main/webapp/icons/24x24/report-generator.png
  27. BIN src/main/webapp/icons/24x24/test-guide.png
  28. BIN src/main/webapp/icons/24x24/{trf.png → trf-report.png}
  29. BIN src/main/webapp/icons/32x32/atx-report.png
  30. BIN src/main/webapp/icons/32x32/atx-trend.png
  31. BIN src/main/webapp/icons/32x32/ecu-test-pkg.png
  32. BIN src/main/webapp/icons/32x32/ecu-test-prj.png
  33. BIN src/main/webapp/icons/32x32/ecu-test.png
  34. BIN src/main/webapp/icons/32x32/report-generator.png
  35. BIN src/main/webapp/icons/32x32/test-guide.png
  36. BIN src/main/webapp/icons/32x32/trf-report.png
  37. BIN src/main/webapp/icons/48x48/atx-report.png
  38. BIN src/main/webapp/icons/48x48/atx-trend.png
  39. BIN src/main/webapp/icons/48x48/ecu-test.png
  40. BIN src/main/webapp/icons/48x48/test-guide.png
  41. BIN src/main/webapp/icons/48x48/{trf.png → trf-report.png}
16 pom.xml
@@ -84,6 +84,7 @@

<!-- Jenkins plugins -->
<matrix-project.version>1.4</matrix-project.version>
<icon-shim.version>2.0.2</icon-shim.version>
<junit.version>1.3</junit.version>
<job-dsl.version>1.37</job-dsl.version>
<structs.version>1.5</structs.version>
@@ -159,6 +160,16 @@
<artifactId>matrix-project</artifactId>
<version>${matrix-project.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.icon-shim</groupId>
<artifactId>icon-shim</artifactId>
<version>${icon-shim.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>${structs.version}</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>junit</artifactId>
@@ -186,11 +197,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>${structs.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
@@ -37,6 +37,9 @@
import jenkins.model.Jenkins;

import org.apache.commons.lang.builder.HashCodeBuilder;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkins.ui.icon.IconType;

import de.tracetronic.jenkins.plugins.ecutest.report.atx.ATXPublisher.DescriptorImpl;

@@ -191,6 +194,50 @@ public static ToolVersion parse(final String version) throws IllegalArgumentExce
}
}

@Override
public void start() throws Exception {
super.start();

for (final String name : new String[] {
"atx-report",
"atx-trend",
"ecu-test",
"ecu-test-pkg",
"ecu-test-prj",
"report-generator",
"test-guide",
"trf-report",
}) {
// Register small (16x16) icons
IconSet.icons.addIcon(new Icon(
String.format("icon-ecutest-%s icon-sm", name),
String.format("ecutest/icons/16x16/%s.png", name),
Icon.ICON_SMALL_STYLE, IconType.PLUGIN)
);

// Register medium (24x24) icons
IconSet.icons.addIcon(new Icon(
String.format("icon-ecutest-%s icon-md", name),
String.format("ecutest/icons/24x24/%s.png", name),
Icon.ICON_MEDIUM_STYLE, IconType.PLUGIN)
);

// Register large (32x32) icons
IconSet.icons.addIcon(new Icon(
String.format("icon-ecutest-%s icon-lg", name),
String.format("ecutest/icons/32x32/%s.png", name),
Icon.ICON_LARGE_STYLE, IconType.PLUGIN)
);

// Register x-large (48x48) icons
IconSet.icons.addIcon(new Icon(
String.format("icon-ecutest-%s icon-xlg", name),
String.format("ecutest/icons/48x48/%s.png", name),
Icon.ICON_XLARGE_STYLE, IconType.PLUGIN)
);
}
}

@Override
public void postInitialize() throws Exception {
super.postInitialize();
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2015-2017 TraceTronic GmbH
* Copyright (c) 2015-2016 TraceTronic GmbH
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
@@ -29,24 +29,23 @@
*/
package de.tracetronic.jenkins.plugins.ecutest.report;

import hudson.PluginWrapper;
import hudson.model.Action;
import hudson.model.Job;
import hudson.model.Run;

import java.io.File;
import java.net.URISyntaxException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

import javax.annotation.CheckForNull;

import jenkins.model.Jenkins;
import jenkins.util.VirtualFile;

import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkins.ui.icon.IconSpec;
import org.kohsuke.stapler.StaplerRequest;

import de.tracetronic.jenkins.plugins.ecutest.ETPlugin;
import de.tracetronic.jenkins.plugins.ecutest.report.atx.AbstractATXAction;
import de.tracetronic.jenkins.plugins.ecutest.report.trf.AbstractTRFAction;

@@ -55,9 +54,7 @@
*
* @author Christian Pönisch <christian.poenisch@tracetronic.de>
*/
public abstract class AbstractReportAction extends AbstractRequestHandler implements Action {

private static final Logger LOGGER = Logger.getLogger(AbstractReportAction.class.getName());
public abstract class AbstractReportAction extends AbstractRequestHandler implements Action, IconSpec {

private final boolean projectLevel;

@@ -111,36 +108,16 @@ protected VirtualFile getArchiveTargetDir(final File rootDir) {
@CheckForNull
protected abstract Run<?, ?> getLastReportBuild(Job<?, ?> project);

/**
* Gets the icon path inside of this plugin.
*
* @param icon
* the icon to search
* @return the full icon path or {@code null} if the icon does not exist
*/
@CheckForNull
protected String getIconPath(final String icon) {
String iconPath = null;
if (icon == null) {
return iconPath;
}
// Try plugin icons dir, fallback to Jenkins image
final Jenkins instance = Jenkins.getInstance();
if (instance != null) {
final PluginWrapper wrapper = instance.getPluginManager().getPlugin(ETPlugin.class);
boolean pluginIconExists = false;
try {
pluginIconExists = wrapper != null
&& new File(wrapper.baseResourceURL.toURI().getPath() + "/icons/" + icon).exists();
} catch (final URISyntaxException e) {
LOGGER.log(Level.WARNING, e.getMessage());
}
if (pluginIconExists) {
iconPath = "/plugin/" + wrapper.getShortName() + "/icons/" + icon;
} else {
iconPath = "/images/48x48/document.png";
}
@Override
public String getIconFileName() {
final String iconClass = getIconClassName() + " icon-xlg";
try {
// FIXME: workaround signature changes in different versions of {@link IconSet} by reflection
final Method getIconByClassSpec = IconSet.class.getMethod("getIconByClassSpec", Object.class);
return ((Icon) getIconByClassSpec.invoke(IconSet.icons, iconClass)).getUrl();
} catch (final NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
// ignore
}
return iconPath;
return IconSet.icons.getIconByClassSpec(iconClass).getUrl();
}
}
@@ -66,21 +66,21 @@ public String getUrlName() {
}

@Override
public String getIconFileName() {
return getIconPath("48x48/test-guide.png");
public String getIconClassName() {
return "icon-ecutest-test-guide";
}

/**
* @return the report icon file name
* @return the report icon class name
*/
public String getReportIconFileName() {
return getIconPath("24x24/atx.png");
public String getReportIconClassName() {
return "icon-ecutest-atx-report";
}

/**
* @return the trend icon file name
* @return the trend icon class name
*/
public String getTrendIconFileName() {
return getIconPath("24x24/atx-trend.png");
public String getTrendIconClassName() {
return "icon-ecutest-atx-trend";
}
}
@@ -66,16 +66,7 @@ public String getUrlName() {
}

@Override
public String getIconFileName() {
return getIconPath("48x48/report-generator.png");
}

/**
* Gets the small icon file name.
*
* @return the small icon file name
*/
public String getSmallIconFileName() {
return getIconPath("24x24/report-generator.png");
public String getIconClassName() {
return "icon-ecutest-report-generator";
}
}
@@ -77,7 +77,7 @@ public String getUrlName() {
}

@Override
public String getIconFileName() {
return getIconPath("48x48/ecu-test.png");
public String getIconClassName() {
return "icon-ecutest-ecu-test";
}
}
@@ -67,7 +67,7 @@ public String getUrlName() {
}

@Override
public String getIconFileName() {
return getIconPath("48x48/trf.png");
public String getIconClassName() {
return "icon-ecutest-trf-report";
}
}
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2015 TraceTronic GmbH
Copyright (c) 2015-2016 TraceTronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@@ -29,14 +29,14 @@
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:lsi="/shim/layout/icon">
<j:set var="owner" value="${it.getOwner(request)}" />
<j:set var="build" value="${it.getBuild(request)}" />
<l:layout title="${it.displayName}" norefresh="true">
<st:include page="sidepanel.jelly" it="${owner}" />
<l:main-panel>
<h1>
<img src="${resURL}${it.iconFileName}" alt="ATX reports" height="48" width="48" />
<lsi:icon class="${it.iconClassName} icon-xlg" alt="ATX reports" />
${it.displayName}
</h1>
<j:if test="${owner != null}">
@@ -48,25 +48,27 @@
<table class="fileList">
<j:set var="indent" value="0" />
<j:set var="reports" value="${it.getATXReports()}" />
<j:forEach var="report" items="${reports}">
<st:include page="report.jelly" />
</j:forEach>
<j:choose>
<j:when test="${empty(reports)}">
${%reports.empty}
</j:when>
<j:when test="${it.hasArchivedReports()}">
<tr>
<td style="text-align:right;" colspan="2">
<div style="margin-top: 1em;">
<img src="${resURL}/images/16x16/package.png" /><st:nbsp />
<a href="${rootURL}/${build.url}${it.urlName}/zipDownload">
${%download.zip}
</a>
</div>
</td>
</tr>
</j:when>
<j:otherwhise>
<j:forEach var="report" items="${reports}">
<st:include page="report.jelly" />
</j:forEach>
<j:if test="${it.hasArchivedReports()}">
<tr>
<td style="text-align:right;" colspan="2">
<div style="margin-top: 1em;">
<l:icon class="icon-package icon-sm" /><st:nbsp />
<a href="${rootURL}/${build.url}${it.urlName}/zipDownload">
${%download.zip}
</a>
</div>
</td>
</tr>
</j:if>
</j:otherwhise>
</j:choose>
</table>
</j:if>
@@ -1,5 +1,5 @@
<!--
Copyright (c) 2015 TraceTronic GmbH
Copyright (c) 2015-2016 TraceTronic GmbH
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
@@ -29,23 +29,23 @@
-->

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:lsi="/shim/layout/icon">
<tr>
<td>
<div style="text-indent: ${indent}px;">
<j:choose>
<j:when test="${report.hasTrendReport()}">
<lsi:icon class="${it.trendIconClassName} icon-sm" alt="ATX report" />
<st:nbsp />
<j:if test="${owner == build}">
<img src="${resURL}${it.trendIconFileName}" alt="ATX report" height="16" width="16" />
<st:nbsp /><a href="${report.url}" target="_blank">${%trend.view}</a>
<a href="${report.url}" target="_blank">${%trend.view}</a>
</j:if>
<j:if test="${owner != build}">
<img src="${resURL}${it.trendIconFileName}" alt="ATX trend report" height="16" width="16" />
<st:nbsp /><a href="${rootURL}/${build.url}${it.urlName}/${report.id}" target="_blank">${%trend.view}</a>
<a href="${rootURL}/${build.url}${it.urlName}/${report.id}" target="_blank">${%trend.view}</a>
</j:if>
</j:when>
<j:otherwise>
<img src="${resURL}${it.reportIconFileName}" alt="ATX report" height="16" width="16" />
<lsi:icon class="${it.reportIconClassName} icon-sm" alt="ATX report" />
<st:nbsp />
<j:if test="${owner == build}">
<a href="${report.url}" target="_blank">${report.title}</a>

0 comments on commit d8bdb34

Please sign in to comment.