implement view runner settings for nuget .exe field
authorEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 17:22:48 +0000 (19:22 +0200)
committerEugene.Petrenko <eugene.petrenko@gmail.com>
Tue, 23 Aug 2011 17:22:48 +0000 (19:22 +0200)
nuget-server/resources/install/viewInstallPackage.jsp
nuget-server/resources/pack/viewPack.jsp
nuget-server/resources/publish/viewPublish.jsp
nuget-server/resources/tool/runnerSettingsEdit.jsp [moved from nuget-server/resources/tool/runnerSettings.jsp with 93% similarity]
nuget-server/resources/tool/runnerSettingsView.jsp [new file with mode: 0644]
nuget-server/src/jetbrains/buildServer/nuget/server/toolRegistry/ui/ToolSelectorController.java

index 1cd43d58dad7d36bf9ee69c4ed7be10fd0fe8c7e..a6c867b227205f40c7b03acc4a59625ee05c53fb 100644 (file)
@@ -20,7 +20,7 @@
 <jsp:useBean id="ib" class="jetbrains.buildServer.nuget.server.runner.install.InstallBean" scope="request"/>\r
 \r
 <div class="parameter">\r
-  Path to NuGet.exe: <strong><props:displayValue name="${ib.nuGetPathKey}"/></strong>\r
+  Path to NuGet.exe: <jsp:include page="../tool/runnerSettings.html?name=${ib.nuGetPathKey}&class=longField&view=1"/>\r
 </div>\r
 <div class="parameter">\r
   Package Sources: <strong><props:displayValue name="${ib.nuGetSourcesKey}"\r
index eb1c4cc667b2e9da33649ec903193bd505ca45ff..348b3ac10825e0fbbc962f11d678b42b19dd64a6 100644 (file)
 \r
 \r
 <div class="parameter">\r
-  Path to NuGet.exe: <strong><props:displayValue name="${ib.nuGetPathKey}"/></strong>\r
+  Path to NuGet.exe: <jsp:include page="../tool/runnerSettings.html?name=${ib.nuGetPathKey}&class=longField&view=1"/>\r
 </div>\r
 \r
-\r
 <div class="parameter">\r
   Specification file: <strong><props:displayValue name="${ib.packSpecFile}"/></strong>\r
 </div>\r
index 311c8c705c83c46838357584db2754353175d51e..20062d018c85f7bf42aad277d02c76a88f7f1a34 100644 (file)
@@ -20,8 +20,9 @@
 <jsp:useBean id="ib" class="jetbrains.buildServer.nuget.server.runner.publish.PublishBean" scope="request"/>\r
 \r
 <div class="parameter">\r
-  Path to NuGet.exe: <strong><props:displayValue name="${ib.nuGetPathKey}"/></strong>\r
+  Path to NuGet.exe: <jsp:include page="../tool/runnerSettings.html?name=${ib.nuGetPathKey}&class=longField&view=1"/>\r
 </div>\r
+\r
 <div class="parameter">\r
   Package Sources: <strong><props:displayValue name="${ib.nuGetSourceKey}"\r
                                                emptyValue="Use default source"/></strong>\r
similarity index 93%
rename from nuget-server/resources/tool/runnerSettings.jsp
rename to nuget-server/resources/tool/runnerSettingsEdit.jsp
index d2e1f4590b71c8283c1fc61d739dbf056d98b589..d73e194583371fea757a938d2923ea28382217d4 100644 (file)
@@ -13,6 +13,7 @@
   ~ See the License for the specific language governing permissions and\r
   ~ limitations under the License.\r
   --%>\r
+\r
 <%@ include file="/include-internal.jsp"%>\r
 <%@ taglib prefix="forms" tagdir="/WEB-INF/tags/forms" %>\r
 <%@ taglib prefix="props" tagdir="/WEB-INF/tags/props" %>\r
@@ -73,7 +74,8 @@
         BS.Util.hide($('customPathContainer'));\r
       } else if(selected == "custom") {\r
         var val = this.getValue();\r
-        $('nugetCustomPath').value = this.isPackage(val) ? "<bs:forJs>${customValue}</bs:forJs>" : val;\r
+        val = this.isPackage(val) ? "<bs:forJs>${customValue}</bs:forJs>" : val;\r
+        $('nugetCustomPath').value = this.isPackage(val) ? "" : val;\r
         this.customPathChanged();\r
         BS.Util.show($('customPathContainer'));\r
       } else {\r
diff --git a/nuget-server/resources/tool/runnerSettingsView.jsp b/nuget-server/resources/tool/runnerSettingsView.jsp
new file mode 100644 (file)
index 0000000..56013f8
--- /dev/null
@@ -0,0 +1,32 @@
+<%--\r
+  ~ Copyright 2000-2011 JetBrains s.r.o.\r
+  ~\r
+  ~ Licensed under the Apache License, Version 2.0 (the "License");\r
+  ~ you may not use this file except in compliance with the License.\r
+  ~ You may obtain a copy of the License at\r
+  ~\r
+  ~ http://www.apache.org/licenses/LICENSE-2.0\r
+  ~\r
+  ~ Unless required by applicable law or agreed to in writing, software\r
+  ~ distributed under the License is distributed on an "AS IS" BASIS,\r
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+  ~ See the License for the specific language governing permissions and\r
+  ~ limitations under the License.\r
+  --%>\r
+\r
+<%@ include file="/include-internal.jsp"%>\r
+<%@ taglib prefix="forms" tagdir="/WEB-INF/tags/forms" %>\r
+<%@ taglib prefix="props" tagdir="/WEB-INF/tags/props" %>\r
+<%@ taglib prefix="l" tagdir="/WEB-INF/tags/layout" %>\r
+<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>\r
+<jsp:useBean id="tool" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="bundled" scope="request" type="java.lang.Boolean"/>\r
+\r
+<c:choose>\r
+  <c:when test="${bundled}">\r
+    <strong>NuGet (version <c:out value="${tool}"/>)</strong>\r
+  </c:when>\r
+  <c:otherwise>\r
+    <strong><c:out value="${tool}"/></strong>\r
+  </c:otherwise>\r
+</c:choose>\r
index def62d1541fc068a56be38f7a99708b31416e238..2e87c06c6b619e68f1d61e628a5c1052f338954c 100644 (file)
@@ -61,26 +61,40 @@ public class ToolSelectorController extends BaseController {
     final String name = safe(request.getParameter("name"));\r
     String value = parseValue(request, "value", name);\r
     final Collection<ToolInfo> tools = getTools();\r
-    ensureVersion(value, tools);\r
+    final ToolInfo bundledTool = ensureVersion(value, tools);\r
 \r
-\r
-    ModelAndView mv = new ModelAndView(myDescriptor.getPluginResourcesPath("tool/runnerSettings.jsp"));\r
-    mv.getModel().put("name", name);\r
-    mv.getModel().put("value", value);\r
-    mv.getModel().put("customValue", safe(parseValue(request, "customValue", "nugetCustomPath")));\r
-    mv.getModel().put("clazz", safe(request.getParameter("class")));\r
-    mv.getModel().put("style", safe(request.getParameter("style")));\r
-    mv.getModel().put("items", tools);\r
-    mv.getModel().put("settingsUrl", "/admin/serverConfig.html?init=1&tab=" + ServerSettingsTab.TAB_ID);\r
-    return mv;\r
+    if (!StringUtil.isEmptyOrSpaces(request.getParameter("view"))) {\r
+      ModelAndView mv = new ModelAndView(myDescriptor.getPluginResourcesPath("tool/runnerSettingsView.jsp"));\r
+      if (bundledTool != null) {\r
+        mv.getModel().put("tool", bundledTool.getVersion());\r
+        mv.getModel().put("bundled", true);\r
+      } else {\r
+        mv.getModel().put("tool", value);\r
+        mv.getModel().put("bundled", false);\r
+      }\r
+      return mv;\r
+    } else {\r
+      ModelAndView mv = new ModelAndView(myDescriptor.getPluginResourcesPath("tool/runnerSettingsEdit.jsp"));\r
+      mv.getModel().put("name", name);\r
+      mv.getModel().put("value", value);\r
+      mv.getModel().put("customValue", safe(parseValue(request, "customValue", "nugetCustomPath")));\r
+      mv.getModel().put("clazz", safe(request.getParameter("class")));\r
+      mv.getModel().put("style", safe(request.getParameter("style")));\r
+      mv.getModel().put("items", tools);\r
+      mv.getModel().put("settingsUrl", "/admin/serverConfig.html?init=1&tab=" + ServerSettingsTab.TAB_ID);\r
+      return mv;\r
+    }\r
   }\r
 \r
-  private void ensureVersion(@NotNull final String version, @NotNull Collection<ToolInfo> actionInfos) {\r
-    if (!version.startsWith("?")) return;\r
+  @Nullable\r
+  private ToolInfo ensureVersion(@NotNull final String version, @NotNull Collection<ToolInfo> actionInfos) {\r
+    if (!version.startsWith("?")) return null;\r
     for (ToolInfo actionInfo : actionInfos) {\r
-      if (actionInfo.getId().equals(version)) return;\r
+      if (actionInfo.getId().equals(version)) return actionInfo;\r
     }\r
-    actionInfos.add(new ToolInfo(version, "Not Installed: " + version.substring(1)));\r
+    final ToolInfo notInstalled = new ToolInfo(version, "Not Installed: " + version.substring(1));\r
+    actionInfos.add(notInstalled);\r
+    return notInstalled;\r
   }\r
 \r
   @NotNull\r