[MRM-1096] [MRM-989] fix plugin download type, add default for other types such as javadoc, clean all icons

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@756883 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2009-03-21 07:20:09 +00:00
parent d1428eb60f
commit 3457a487f1
8 changed files with 23 additions and 1 deletions

View File

@ -40,7 +40,9 @@ import org.codehaus.plexus.component.repository.exception.ComponentLookupExcepti
import java.io.IOException; import java.io.IOException;
import java.io.Writer; import java.io.Writer;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
@ -56,6 +58,8 @@ import javax.servlet.jsp.PageContext;
public class DownloadArtifact public class DownloadArtifact
extends Component extends Component
{ {
private static final String DEFAULT_DOWNLOAD_IMAGE = "download-type-other.png";
/** /**
* @plexus.requirement role-hint="jdo" * @plexus.requirement role-hint="jdo"
*/ */
@ -81,6 +85,18 @@ public class DownloadArtifact
private DecimalFormat decimalFormat; private DecimalFormat decimalFormat;
private static final Map<String, String> DOWNLOAD_IMAGES = new HashMap<String,String>();
static
{
DOWNLOAD_IMAGES.put( "jar", "download-type-jar.png" );
DOWNLOAD_IMAGES.put( "java-source", "download-type-jar.png" );
DOWNLOAD_IMAGES.put( "pom", "download-type-pom.png" );
DOWNLOAD_IMAGES.put( "maven-plugin", "download-type-maven-plugin.png" );
DOWNLOAD_IMAGES.put( "maven-archetype", "download-type-archetype.png" );
DOWNLOAD_IMAGES.put( "maven-skin", "download-type-skin.png" );
}
public DownloadArtifact( ValueStack stack, PageContext pageContext ) public DownloadArtifact( ValueStack stack, PageContext pageContext )
{ {
super( stack ); super( stack );
@ -238,10 +254,16 @@ public class DownloadArtifact
ArchivaArtifact artifact ) ArchivaArtifact artifact )
{ {
String type = artifact.getType(); String type = artifact.getType();
String linkText = "<img src=\"" + req.getContextPath() + "/images/download-type-" + type + ".png\" />"; String linkText = "<img src=\"" + req.getContextPath() + "/images/" + getDownloadImage( type ) + "\" />";
appendLink( sb, prefix, repo, artifact, linkText ); appendLink( sb, prefix, repo, artifact, linkText );
} }
private String getDownloadImage( String type )
{
String name = DOWNLOAD_IMAGES.get( type );
return name != null ? name : DEFAULT_DOWNLOAD_IMAGE;
}
private static void appendLink( StringBuffer sb, String prefix, ManagedRepositoryContent repo, private static void appendLink( StringBuffer sb, String prefix, ManagedRepositoryContent repo,
ArchivaArtifact artifact, String linkText ) ArchivaArtifact artifact, String linkText )
{ {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 969 B

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 946 B

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB