提交 8670e139 编写于 作者: J Jesse Glick

More conservative UI change: just collapse tool installation sections by default.

上级 df0db7b4
......@@ -110,10 +110,8 @@ import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
import java.util.regex.Pattern;
import org.apache.commons.lang.StringUtils;
......@@ -803,29 +801,6 @@ public class Functions {
return DescriptorVisibilityFilter.apply(Jenkins.getInstance(),answer);
}
/**
*
* @param supertype binary name of supertype within Jenkins core
* @param include true to include all subtypes and nothing else, false to include everything except subtypes
* @return same as {@link #getSortedDescriptorsForGlobalConfig} except restricted according to parameters
* @since 1.475
*/
@SuppressWarnings("rawtypes")
public static Collection<Descriptor> getFilteredSortedDescriptorsForGlobalConfig(String supertype, boolean include) {
Class clazz = Describable.class;
try {
clazz = Class.forName(supertype);
} catch (ClassNotFoundException x) {
Logger.getLogger(Functions.class.getName()).log(Level.WARNING, null, x);
}
Collection<Descriptor> r = new ArrayList<Descriptor>();
for (Descriptor d : getSortedDescriptorsForGlobalConfig()) {
if (d.isSubTypeOf(clazz) == include) {
r.add(d);
}
}
return r;
}
/**
* Computes the path to the icon of the given action
......
......@@ -679,6 +679,18 @@ public abstract class Descriptor<T extends Describable<T>> implements Saveable {
return type.isAssignableFrom(clazz);
}
/**
* Like {@link #isSubTypeOf(Class)} but usable from Jelly scripts.
* @since XXX
*/
public final boolean isSubTypeOf(String type) {
try {
return Class.forName(type, true, clazz.getClassLoader()).isAssignableFrom(clazz);
} catch (ClassNotFoundException x) {
return false;
}
}
/**
* @deprecated
* As of 1.239, use {@link #configure(StaplerRequest, JSONObject)}.
......
......@@ -69,6 +69,7 @@ import hudson.model.OverallLoadStatistics;
import hudson.model.Project;
import hudson.model.RestartListener;
import hudson.model.RootAction;
import hudson.model.Saveable;
import hudson.model.Slave;
import hudson.model.TaskListener;
import hudson.model.TopLevelItem;
......@@ -222,6 +223,7 @@ import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.BindInterceptor;
import org.kohsuke.stapler.HttpRedirect;
import org.kohsuke.stapler.HttpResponse;
import org.kohsuke.stapler.HttpResponses;
......@@ -249,7 +251,6 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import static hudson.init.InitMilestone.*;
import hudson.tools.ToolInstallation;
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
import static javax.servlet.http.HttpServletResponse.SC_NOT_FOUND;
import java.io.File;
......@@ -258,6 +259,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.lang.reflect.Type;
import java.net.BindException;
import java.net.URL;
import java.nio.charset.Charset;
......@@ -2644,8 +2646,11 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
systemMessage = Util.nullify(req.getParameter("system_message"));
jdks.clear();
jdks.addAll(req.bindJSONToList(JDK.class,json.get("jdks")));
boolean result = true;
for( Descriptor<?> d : Functions.getFilteredSortedDescriptorsForGlobalConfig(ToolInstallation.class.getName(), false) )
for( Descriptor<?> d : Functions.getSortedDescriptorsForGlobalConfig() )
result &= configureDescriptor(req,json,d);
version = VERSION;
......@@ -2661,31 +2666,6 @@ public class Jenkins extends AbstractCIBase implements ModifiableItemGroup<TopLe
}
}
/**
* Accepts submission from the tool configuration page.
*/
public synchronized void doConfigToolsSubmit(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException, FormException {
BulkChange bc = new BulkChange(this);
try {
checkPermission(ADMINISTER);
JSONObject json = req.getSubmittedForm();
jdks.clear();
jdks.addAll(req.bindJSONToList(JDK.class, json.get("jdks")));
boolean result = true;
for (Descriptor<?> d : Functions.getFilteredSortedDescriptorsForGlobalConfig(ToolInstallation.class.getName(), true)) {
result &= configureDescriptor(req, json, d);
}
save();
if (result) {
FormApply.success(req.getContextPath() + '/').generateResponse(req, rsp, null);
} else {
FormApply.success("configureTools").generateResponse(req, rsp, null);
}
} finally {
bc.commit();
}
}
/**
* Gets the {@link CrumbIssuer} currently in use.
*
......
......@@ -53,10 +53,19 @@ THE SOFTWARE.
</f:entry>
<!-- global configuration from everyone -->
<j:forEach var="descriptor" items="${h.getFilteredSortedDescriptorsForGlobalConfig('hudson.tools.ToolInstallation', false)}">
<j:forEach var="descriptor" items="${h.getSortedDescriptorsForGlobalConfig()}">
<j:set var="instance" value="${descriptor}" /><!-- this makes the <f:textbox field=.../> work -->
<f:rowSet name="${descriptor.jsonSafeClassName}">
<st:include page="${descriptor.globalConfigPage}" from="${descriptor}" />
<j:choose>
<j:when test="${descriptor.isSubTypeOf('hudson.tools.ToolInstallation')}">
<f:advanced title="${%tool.installations(descriptor.displayName)}" align="left">
<st:include page="${descriptor.globalConfigPage}" from="${descriptor}" />
</f:advanced>
</j:when>
<j:otherwise>
<st:include page="${descriptor.globalConfigPage}" from="${descriptor}" />
</j:otherwise>
</j:choose>
</f:rowSet>
</j:forEach>
......
......@@ -28,3 +28,4 @@ statsBlurb=\
Help make Jenkins better by sending anonymous usage statistics and crash reports to the Jenkins project.
no.such.JDK=<span class=error>No such JDK exists</span>
tool.installations={0} installations
<!--
The MIT License
Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Erik Ramfelt, Jean-Baptiste Quenot, Stephen Connolly, Tom Huybrechts, Yahoo! 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.
-->
<?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">
<l:layout norefresh="true" permission="${it.ADMINISTER}" title="${%Configure Tools}">
<st:include page="sidepanel.jelly" />
<f:breadcrumb-config-outline />
<l:main-panel>
<div class="behavior-loading">${%LOADING}</div>
<f:form method="post" name="config" action="configToolsSubmit">
<j:forEach var="descriptor" items="${h.getFilteredSortedDescriptorsForGlobalConfig('hudson.tools.ToolInstallation', true)}">
<j:set var="instance" value="${descriptor}" />
<f:rowSet name="${descriptor.jsonSafeClassName}">
<st:include page="${descriptor.globalConfigPage}" from="${descriptor}" />
</f:rowSet>
</j:forEach>
<!-- XXX try to grab ToolLocationNodeProperty too -->
<f:block>
<div id="bottom-sticker" >
<div class="bottom-sticker-inner">
<f:submit value="${%Save}" />
<f:apply />
</div>
</div>
</f:block>
</f:form>
</l:main-panel>
</l:layout>
</j:jelly>
......@@ -70,10 +70,6 @@ THE SOFTWARE.
<local:feature icon="setting.png" href="configure" title="${%Configure System}">
${%Configure global settings and paths.}
</local:feature>
<!-- XXX icon TBD -->
<local:feature icon="setting.png" href="configureTools" title="${%Manage Tools}">
${%Manage available JDKs, build tools, and more.}
</local:feature>
<local:feature icon="refresh.png" href="reload" title="${%Reload Configuration from Disk}">
${%Discard all the loaded data in memory and reload everything from file system.}
${%Useful when you modified config files directly on disk.}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册