From 4434ed77063bcb1b939072011b2c7ec9401ce771 Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Sat, 28 May 2011 18:26:04 +0200 Subject: [PATCH] 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. --- core/pom.xml | 2 +- .../main/java/hudson/model/Descriptor.java | 22 ++++++-- .../hudson/PluginManager/sidepanel.groovy | 37 ++++++++++++++ .../hudson/PluginManager/sidepanel.jelly | 40 --------------- .../resources/hudson/tasks/Ant/config.groovy | 51 +++++++++++++++++++ .../resources/hudson/tasks/Ant/config.jelly | 51 ------------------- .../main/resources/lib/form/hetero-list.jelly | 2 +- 7 files changed, 108 insertions(+), 97 deletions(-) create mode 100644 core/src/main/resources/hudson/PluginManager/sidepanel.groovy delete mode 100644 core/src/main/resources/hudson/PluginManager/sidepanel.jelly create mode 100644 core/src/main/resources/hudson/tasks/Ant/config.groovy delete mode 100644 core/src/main/resources/hudson/tasks/Ant/config.jelly diff --git a/core/pom.xml b/core/pom.xml index 968db674ee..a99d813ce5 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -382,7 +382,7 @@ THE SOFTWARE. org.kohsuke.stapler stapler-groovy - 1.166 + 1.167-SNAPSHOT commons-jelly diff --git a/core/src/main/java/hudson/model/Descriptor.java b/core/src/main/java/hudson/model/Descriptor.java index 50ca708da0..843a420ff9 100644 --- a/core/src/main/java/hudson/model/Descriptor.java +++ b/core/src/main/java/hudson/model/Descriptor.java @@ -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> implements Saveable { } public String getConfigPage() { - return getViewPage(clazz, "config.jelly"); + List names = new ArrayList(); + 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> implements Saveable { } private String getViewPage(Class clazz, String pageName, String defaultValue) { + return getViewPage(clazz,Collections.singleton(pageName),defaultValue); + } + + private String getViewPage(Class clazz, Collection 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; diff --git a/core/src/main/resources/hudson/PluginManager/sidepanel.groovy b/core/src/main/resources/hudson/PluginManager/sidepanel.groovy new file mode 100644 index 0000000000..593bfae961 --- /dev/null +++ b/core/src/main/resources/hudson/PluginManager/sidepanel.groovy @@ -0,0 +1,37 @@ +/* + * 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")) + } + } +} diff --git a/core/src/main/resources/hudson/PluginManager/sidepanel.jelly b/core/src/main/resources/hudson/PluginManager/sidepanel.jelly deleted file mode 100644 index b6c634dae2..0000000000 --- a/core/src/main/resources/hudson/PluginManager/sidepanel.jelly +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/core/src/main/resources/hudson/tasks/Ant/config.groovy b/core/src/main/resources/hudson/tasks/Ant/config.groovy new file mode 100644 index 0000000000..3a7b6a6987 --- /dev/null +++ b/core/src/main/resources/hudson/tasks/Ant/config.groovy @@ -0,0 +1,51 @@ +/* + * 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) + } +} diff --git a/core/src/main/resources/hudson/tasks/Ant/config.jelly b/core/src/main/resources/hudson/tasks/Ant/config.jelly deleted file mode 100644 index 2a011af5f5..0000000000 --- a/core/src/main/resources/hudson/tasks/Ant/config.jelly +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/core/src/main/resources/lib/form/hetero-list.jelly b/core/src/main/resources/lib/form/hetero-list.jelly index 643e477235..c8f5b0cbc5 100644 --- a/core/src/main/resources/lib/form/hetero-list.jelly +++ b/core/src/main/resources/lib/form/hetero-list.jelly @@ -110,7 +110,7 @@ THE SOFTWARE.
- + -- GitLab