Skip to content

Commit

Permalink
Merge pull request #84 from stephenc/jenkins-38960-followup
Browse files Browse the repository at this point in the history
[JENKINS-38960 Follow-up] Switch to IconSpec
  • Loading branch information
stephenc committed Oct 20, 2016
2 parents 4b29ab8 + d658fe9 commit 6fcec84
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/images/make-inkscape.sh
@@ -0,0 +1,19 @@
#!/bin/sh -e

dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
for src in "$dir"/*.svg
do
echo "Processing $(basename "$src")..."
file=$(basename "$src" | sed -e s/.svg/.png/ )
for sz in 16 24 32 48
do
mkdir -p "${dir}/../../src/main/webapp/images/${sz}x${sz}"
dst="${dir}/../../src/main/webapp/images/${sz}x${sz}/${file}"
if [ ! -e "$dst" -o "$src" -nt "$dst" ]
then
echo -n " generating ${sz}x${sz}..."
mkdir "${dir}/../../src/main/webapp/images/${sz}x${sz}" > /dev/null 2>&1 || true
inkscape -z -C -w ${sz} -h ${sz} -e "$dst" "$src" 2>&1 | grep "Bitmap saved as"
fi
done
done
349 changes: 349 additions & 0 deletions src/images/mavenmoduleset.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 30 additions & 2 deletions src/main/java/hudson/maven/MavenModuleSet.java
Expand Up @@ -45,7 +45,6 @@
import hudson.model.Executor;
import hudson.model.Item;
import hudson.model.ItemGroup;
import static hudson.model.ItemGroupMixIn.loadChildren;
import hudson.model.Job;
import hudson.model.Queue;
import hudson.model.Queue.Task;
Expand Down Expand Up @@ -102,6 +101,9 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.maven.model.building.ModelBuildingRequest;
import org.jenkins.ui.icon.Icon;
import org.jenkins.ui.icon.IconSet;
import org.jenkins.ui.icon.IconSpec;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.HttpResponse;
Expand All @@ -111,6 +113,8 @@
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.export.Exported;

import static hudson.model.ItemGroupMixIn.loadChildren;

/**
* Group of {@link MavenModule}s.
*
Expand Down Expand Up @@ -1300,7 +1304,7 @@ public DescriptorImpl getDescriptor() {
@Extension(ordinal=900)
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();

public static final class DescriptorImpl extends AbstractProjectDescriptor {
public static final class DescriptorImpl extends AbstractProjectDescriptor implements IconSpec {
/**
* Globally-defined MAVEN_OPTS.
*/
Expand Down Expand Up @@ -1403,6 +1407,15 @@ public String getIconFilePathPattern() {
return "plugin/maven-plugin/images/:size/mavenmoduleset.png";
}

/**
* {@inheritDoc}
*/
@Override
public String getIconClassName() {
return "icon-maven-moduleset";
}


public MavenModuleSet newInstance(ItemGroup parent, String name) {
MavenModuleSet mms = new MavenModuleSet(parent,name);
mms.setSettings(GlobalMavenConfig.get().getSettingsProvider());
Expand Down Expand Up @@ -1442,6 +1455,21 @@ public boolean isApplicable(Descriptor descriptor) {
Mailer.class, // for historical reasons, Maven uses MavenMailer
JUnitResultArchiver.class // done by SurefireArchiver
));

static {
IconSet.icons.addIcon(
new Icon("icon-maven-moduleset icon-sm",
"plugin/maven/images/16x16/mavenmoduleset.png", Icon.ICON_SMALL_STYLE));
IconSet.icons.addIcon(
new Icon("icon-maven-moduleset icon-md",
"plugin/maven/images/24x24/mavenmoduleset.png", Icon.ICON_MEDIUM_STYLE));
IconSet.icons.addIcon(
new Icon("icon-maven-moduleset icon-lg",
"plugin/maven/images/32x32/mavenmoduleset.png", Icon.ICON_LARGE_STYLE));
IconSet.icons.addIcon(
new Icon("icon-maven-moduleset icon-xlg",
"plugin/maven/images/48x48/mavenmoduleset.png", Icon.ICON_XLARGE_STYLE));
}
}

private static final Logger LOGGER = Logger.getLogger(MavenModuleSet.class.getName());
Expand Down
Binary file added src/main/webapp/images/16x16/mavenmoduleset.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/images/24x24/mavenmoduleset.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/main/webapp/images/32x32/mavenmoduleset.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/webapp/images/48x48/mavenmoduleset.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6fcec84

Please sign in to comment.