From fbad52ef18f361e017bd466ec986e846b33f9776 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 25 Mar 2007 23:50:35 +0000 Subject: [PATCH] allowed images to be loaded from plugins. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2662 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Functions.java | 13 +++++++++++++ core/src/main/java/hudson/model/Action.java | 13 +++++++++++-- .../resources/hudson/model/Actionable/actions.jelly | 2 +- core/src/main/resources/lib/hudson/actions.jelly | 2 +- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index b1a1acc74a..d0849ed81c 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -8,6 +8,7 @@ import hudson.model.Run; import hudson.model.Items; import hudson.model.JobPropertyDescriptor; import hudson.model.Job; +import hudson.model.Action; import org.kohsuke.stapler.Ancestor; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -353,4 +354,16 @@ public class Functions { public static List getJobPropertyDescriptors(Class clazz) { return JobPropertyDescriptor.getPropertyDescriptors(clazz); } + + /** + * Computes the path to the icon of the given action + * from the context path. + */ + public static String getIconFilePath(Action a) { + String name = a.getIconFileName(); + if(name.startsWith("/")) + return name.substring(1); + else + return "images/24x24/"+name; + } } diff --git a/core/src/main/java/hudson/model/Action.java b/core/src/main/java/hudson/model/Action.java index 4a41362576..e37447fa21 100644 --- a/core/src/main/java/hudson/model/Action.java +++ b/core/src/main/java/hudson/model/Action.java @@ -26,10 +26,19 @@ import java.io.Serializable; */ public interface Action extends Serializable, ModelObject { /** - * Gets the file name of the icon (relative to /images/24x24). + * Gets the file name of the icon. * * @return - * null to hide it from the task list. This is normally not very useful, + * If just a file name (like "abc.gif") is returned, it will be + * interpreted as a file name inside /images/24x24. + * This is useful for using one of the stock images. + *

+ * If an absolute file name that starts from '/' is returned (like + * "/plugin/foo/abc.gif'), then it will be interpreted as a path + * from the context root of Hudson. This is useful to pick up + * image files from a plugin. + *

+ * Finally, return null to hide it from the task list. This is normally not very useful, * but this can be used for actions that only contribute floatBox.jelly * and no task list item. */ diff --git a/core/src/main/resources/hudson/model/Actionable/actions.jelly b/core/src/main/resources/hudson/model/Actionable/actions.jelly index 9c5c01f94a..6915c11340 100644 --- a/core/src/main/resources/hudson/model/Actionable/actions.jelly +++ b/core/src/main/resources/hudson/model/Actionable/actions.jelly @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/core/src/main/resources/lib/hudson/actions.jelly b/core/src/main/resources/lib/hudson/actions.jelly index 37cbc22b18..c2f6ea7b05 100644 --- a/core/src/main/resources/lib/hudson/actions.jelly +++ b/core/src/main/resources/lib/hudson/actions.jelly @@ -3,6 +3,6 @@ --> - + \ No newline at end of file -- GitLab