提交 4434ed77 编写于 作者: K Kohsuke Kawaguchi

A few more Jelly files switched to Groovy as a test

Now config.jelly can be converted into groovy.
Verified that the auto-selection of the proper view type is working.
上级 5c53144d
......@@ -382,7 +382,7 @@ THE SOFTWARE.
<dependency>
<groupId>org.kohsuke.stapler</groupId>
<artifactId>stapler-groovy</artifactId>
<version>1.166</version>
<version>1.167-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>commons-jelly</groupId>
......
......@@ -36,6 +36,7 @@ import hudson.views.ListViewColumn;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.kohsuke.stapler.*;
import org.kohsuke.stapler.jelly.JellyCompatibleFacet;
import org.springframework.util.StringUtils;
import org.jvnet.tiger_types.Types;
import org.apache.commons.io.IOUtils;
......@@ -648,7 +649,14 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
public String getConfigPage() {
return getViewPage(clazz, "config.jelly");
List<String> names = new ArrayList<String>();
for (Facet f : WebApp.get(Hudson.getInstance().servletContext).facets) {
if (f instanceof JellyCompatibleFacet) {
JellyCompatibleFacet jcf = (JellyCompatibleFacet) f;
names.add("config"+jcf.getDefaultScriptExtension());
}
}
return getViewPage(clazz,names,"config.jelly");
}
public String getGlobalConfigPage() {
......@@ -656,10 +664,16 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
}
private String getViewPage(Class<?> clazz, String pageName, String defaultValue) {
return getViewPage(clazz,Collections.singleton(pageName),defaultValue);
}
private String getViewPage(Class<?> clazz, Collection<String> pageNames, String defaultValue) {
while(clazz!=Object.class) {
String name = clazz.getName().replace('.', '/').replace('$', '/') + "/" + pageName;
if(clazz.getClassLoader().getResource(name)!=null)
return '/'+name;
for (String pageName : pageNames) {
String name = clazz.getName().replace('.', '/').replace('$', '/') + "/" + pageName;
if(clazz.getClassLoader().getResource(name)!=null)
return '/'+name;
}
clazz = clazz.getSuperclass();
}
return defaultValue;
......
/*
* The MIT License
*
* Copyright (c) 2011, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import hudson.taglibs.LayoutTagLib
l=namespace(LayoutTagLib)
l.header()
l.side_panel {
l.tasks {
l.task(icon:"images/24x24/up.png", href:rootURL+'/', title:_("Back to Dashboard"))
l.task(icon:"images/24x24/setting.png", href:"${rootURL}/manage", title:_("Manage Jenkins"), permission:app.ADMINISTER, it:app)
if (!app.updateCenter.jobs.isEmpty()) {
l.task(icon:"images/24x24/plugin.png", href:"${rootURL}/updateCenter/", title:_("Update Center"))
}
}
}
<!--
The MIT License
Copyright (c) 2004-2011, Sun Microsystems, Inc., Kohsuke Kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<!--
Side panel
-->
<?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:s="/lib/form">
<l:header />
<l:side-panel>
<l:tasks>
<l:task icon="images/24x24/up.gif" href="${rootURL}/" title="${%Back to Dashboard}" />
<l:task icon="images/24x24/setting.gif" href="${rootURL}/manage" title="${%Manage Jenkins}" permission="${app.ADMINISTER}" it="${app}" />
<j:if test="${!empty(app.updateCenter.jobs)}">
<l:task icon="images/32x32/plugin.gif" href="${rootURL}/updateCenter/" title="${%Update Center}" />
</j:if>
</l:tasks>
</l:side-panel>
</j:jelly>
/*
* The MIT License
*
* Copyright (c) 2011, CloudBees, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
f=namespace("/lib/form")
if (!descriptor.installations) {
f.entry(title:_("Ant Version")) {
select(class:"setting-input",name:"ant.antName") {
option(value:"(Default)", _("Default"))
descriptor.installations.each {
f.option(selected:it.name==instance?.ant?.name, value:it.name, it.name)
}
}
}
}
f.entry(title:_("Targets"),help:"/help/ant/ant-targets.html") {
f.expandableTextbox(name:"ant.targets",value:instance?.targets)
}
f.advanced {
f.entry(title:_("Build File"),help:"/help/ant/ant-buildfile.html") {
f.expandableTextbox(name:"ant.buildFile",value:instance?.buildFile)
}
f.entry(title:_("Properties"),help:"/help/ant/ant-properties.html") {
f.expandableTextbox(name:"ant.properties",value:instance?.properties)
}
f.entry(title:_("Java Options"),help:"/help/ant/ant-opts.html") {
f.expandableTextbox(name:"ant.antOpts",value:instance?.antOpts)
}
}
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<?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:if test="${!empty(descriptor.installations)}">
<f:entry title="${%Ant Version}">
<select class="setting-input" name="ant.antName">
<option value="(Default)">(${%Default})</option>
<j:forEach var="inst" items="${descriptor.installations}">
<f:option selected="${inst.name==instance.ant.name}" value="${inst.name}">${inst.name}</f:option>
</j:forEach>
</select>
</f:entry>
</j:if>
<f:entry title="${%Targets}" help="/help/ant/ant-targets.html">
<f:expandableTextbox name="ant.targets" value="${instance.targets}" />
</f:entry>
<f:advanced>
<f:entry title="${%Build File}" help="/help/ant/ant-buildfile.html">
<f:textbox name="ant.buildFile" value="${instance.buildFile}"/>
</f:entry>
<f:entry title="${%Properties}" help="/help/ant/ant-properties.html">
<f:textarea name="ant.properties" value="${instance.properties}"/>
</f:entry>
<f:entry title="${%Java Options}" help="/help/ant/ant-opts.html">
<f:expandableTextbox name="ant.antOpts" value="${instance.antOpts}"/>
</f:entry>
</f:advanced>
</j:jelly>
\ No newline at end of file
......@@ -110,7 +110,7 @@ THE SOFTWARE.
<j:forEach var="descriptor" items="${attrs.descriptors}" varStatus="loop">
<div name="${attrs.name}" title="${descriptor.displayName}" tooltip="${descriptor.tooltip}" descriptorId="${descriptor.id}">
<local:body deleteCaption="${attrs.deleteCaption}">
<l:renderOnDemand tag="tr" clazz="config-page" capture="descriptor,it">
<l:renderOnDemand tag="tr" clazz="config-page" capture="descriptor,it,instance">
<l:ajax>
<st:include from="${descriptor}" page="${descriptor.configPage}" optional="true" />
</l:ajax>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册