提交 fbad52ef 编写于 作者: K kohsuke

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
上级 426a9686
...@@ -8,6 +8,7 @@ import hudson.model.Run; ...@@ -8,6 +8,7 @@ import hudson.model.Run;
import hudson.model.Items; import hudson.model.Items;
import hudson.model.JobPropertyDescriptor; import hudson.model.JobPropertyDescriptor;
import hudson.model.Job; import hudson.model.Job;
import hudson.model.Action;
import org.kohsuke.stapler.Ancestor; import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse; import org.kohsuke.stapler.StaplerResponse;
...@@ -353,4 +354,16 @@ public class Functions { ...@@ -353,4 +354,16 @@ public class Functions {
public static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz) { public static List<JobPropertyDescriptor> getJobPropertyDescriptors(Class<? extends Job> clazz) {
return JobPropertyDescriptor.getPropertyDescriptors(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;
}
} }
...@@ -26,10 +26,19 @@ import java.io.Serializable; ...@@ -26,10 +26,19 @@ import java.io.Serializable;
*/ */
public interface Action extends Serializable, ModelObject { 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 * @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 <tt>/images/24x24</tt>.
* This is useful for using one of the stock images.
* <p>
* 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.
* <p>
* 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 <tt>floatBox.jelly</tt> * but this can be used for actions that only contribute <tt>floatBox.jelly</tt>
* and no task list item. * and no task list item.
*/ */
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<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:i="jelly:fmt"> <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:i="jelly:fmt">
<j:forEach var="action" items="${it.actions}"> <j:forEach var="action" items="${it.actions}">
<j:if test="${action.iconFileName!=null}"> <j:if test="${action.iconFileName!=null}">
<l:task icon="images/24x24/${action.iconFileName}" href="${rootURL}/${it.url}${action.urlName}/" title="${action.displayName}" /> <l:task icon="${h.getIconFilePath(action)}" href="${rootURL}/${it.url}${action.urlName}/" title="${action.displayName}" />
</j:if> </j:if>
</j:forEach> </j:forEach>
</j:jelly> </j:jelly>
\ No newline at end of file
...@@ -3,6 +3,6 @@ ...@@ -3,6 +3,6 @@
--> -->
<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">
<j:forEach var="action" items="${it.actions}" varStatus="i"> <j:forEach var="action" items="${it.actions}" varStatus="i">
<l:task icon="images/24x24/${action.iconFileName}" href="action?${i.index}" title="${action.title}" /> <l:task icon="${h.getIconFilePath(action)}" href="action?${i.index}" title="${action.title}" />
</j:forEach> </j:forEach>
</j:jelly> </j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册