\r
<l:settingsGroup title="NuGet settings">\r
<tr>\r
- <th>Path to NuGet.exe<l:star/></th>\r
+ <th>NuGet.exe<l:star/></th>\r
<td>\r
- <props:textProperty name="${ib.nuGetPathKey}" className="longField"/>\r
- <span class="smallNote">Specify path to NuGet.exe</span>\r
- <span class="error" id="error_${ib.nuGetPathKey}"></span>\r
+ <jsp:include page="../tool/runnerSettings.html?name=${ib.nuGetPathKey}&class=longField"/>\r
</td>\r
</tr>\r
<tr>\r
\r
<l:settingsGroup title="NuGet settings">\r
<tr>\r
- <th>Path to NuGet.exe<l:star/></th>\r
+ <th>NuGet.exe<l:star/></th>\r
<td>\r
- <props:textProperty name="${ib.nuGetPathKey}" className="longField"/>\r
- <span class="smallNote">Specify path to NuGet.exe</span>\r
- <span class="error" id="error_${ib.nuGetPathKey}"></span>\r
+ <jsp:include page="../tool/runnerSettings.html?name=${ib.nuGetPathKey}&class=longField"/>\r
</td>\r
</tr>\r
<tr>\r
--- /dev/null
+<%--\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
+<%@ 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="name" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="clazz" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="style" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="value" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="settingsUrl" scope="request" type="java.lang.String"/>\r
+<jsp:useBean id="items" scope="request" type="java.util.Collection<jetbrains.buildServer.nuget.server.toolRegistry.ui.ToolInfo >"/>\r
+\r
+<props:selectProperty name="${name}" className="${clazz}" style="${style}">\r
+ <c:set var="isSelected" value="${value eq ''}"/>\r
+ <props:option value="" selected="${isSelected}">-- Select NuGet version to run --</props:option>\r
+ <c:set var="hasSelected" value="${isSelected}"/>\r
+ <c:forEach var="it" items="${items}">\r
+ <c:set var="isSelected" value="${it.id eq value}"/>\r
+ <props:option value="${it.id}" selected="${isSelected}"><c:out value="${it.version}"/></props:option>\r
+ <c:if test="${isSelected}"><c:set var="hasSelected" value="${true}"/></c:if>\r
+ </c:forEach>\r
+ <c:if test="${not hasSelected}">\r
+ <props:option value="${value}" selected="${true}">Custom: <c:out value="${value}"/></props:option>\r
+ </c:if>\r
+</props:selectProperty>\r
+<span class="smallNote">Specify NuGet.exe version.\r
+ Check intalled NuGet Commandline tools in <a href="<c:url value="${settingsUrl}"/>">NuGet Settings</a>\r
+</span>\r
+<span class="error" id="error_${name}"></span>\r
<jsp:useBean id="ib" class="jetbrains.buildServer.nuget.server.trigger.TriggerBean" scope="request"/>\r
\r
<tr>\r
- <td>NuGet path:<l:star/></td>\r
+ <th>NuGet.exe<l:star/></th>\r
<td>\r
- <props:textProperty name="${ib.nuGetExeKey}" style="width:20em;" />\r
- <span class="smallNote">Specify path to NuGet.exe </span>\r
- <span class="error" id="error_${ib.sourceKey}"></span>\r
+ <jsp:include page="../tool/runnerSettings.html?name=${ib.nuGetExeKey}&style=width:20em"/>\r
</td>\r
</tr>\r
\r
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"\r
default-autowire="constructor">\r
+ <bean class="jetbrains.buildServer.nuget.server.toolRegistry.ui.ToolSelectorController"/>\r
+\r
<bean class="jetbrains.buildServer.nuget.server.toolRegistry.tab.PermissionChecker"/>\r
<bean class="jetbrains.buildServer.nuget.server.toolRegistry.tab.ServerSettingsTab"/>\r
<bean class="jetbrains.buildServer.nuget.server.toolRegistry.tab.InstalledToolsController"/>\r
* Date: 10.08.11 20:35\r
*/\r
public class ServerSettingsTab extends SimpleCustomTab {\r
+ public static final String TAB_ID = "nugetServerSettingsTab";\r
private final PermissionChecker myChecker;\r
\r
public ServerSettingsTab(@NotNull final PagePlaces pagePlaces,\r
@NotNull final PermissionChecker checker) {\r
super(pagePlaces,\r
PlaceId.ADMIN_SERVER_CONFIGURATION_TAB,\r
- "nugetServerSettingsTab",\r
+ TAB_ID,\r
controller.getPath(),\r
"NuGet");\r
myChecker = checker;\r
--- /dev/null
+/*\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
+package jetbrains.buildServer.nuget.server.toolRegistry.ui;\r
+\r
+import jetbrains.buildServer.nuget.server.toolRegistry.NuGetInstalledTool;\r
+import org.jetbrains.annotations.NotNull;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 16.08.11 11:00\r
+ */\r
+public class ToolInfo {\r
+ private final String myId;\r
+ private final String myVersion;\r
+\r
+ public ToolInfo(@NotNull final NuGetInstalledTool tool) {\r
+ this("?" + tool.getId(), tool.getVersion());\r
+ }\r
+\r
+ public ToolInfo(@NotNull final String id,\r
+ @NotNull final String version) {\r
+ myId = id;\r
+ myVersion = version;\r
+ }\r
+\r
+ @NotNull\r
+ public String getId() {\r
+ return myId;\r
+ }\r
+\r
+ @NotNull\r
+ public String getVersion() {\r
+ return myVersion;\r
+ }\r
+}\r
--- /dev/null
+/*\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
+package jetbrains.buildServer.nuget.server.toolRegistry.ui;\r
+\r
+import jetbrains.buildServer.controllers.BaseController;\r
+import jetbrains.buildServer.controllers.BasePropertiesBean;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.NuGetInstalledTool;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.NuGetToolManager;\r
+import jetbrains.buildServer.nuget.server.toolRegistry.tab.ServerSettingsTab;\r
+import jetbrains.buildServer.util.StringUtil;\r
+import jetbrains.buildServer.web.openapi.PluginDescriptor;\r
+import jetbrains.buildServer.web.openapi.WebControllerManager;\r
+import org.jetbrains.annotations.NotNull;\r
+import org.jetbrains.annotations.Nullable;\r
+import org.springframework.web.servlet.ModelAndView;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+/**\r
+ * Created by Eugene Petrenko (eugene.petrenko@gmail.com)\r
+ * Date: 16.08.11 10:21\r
+ */\r
+public class ToolSelectorController extends BaseController {\r
+ private final NuGetToolManager myToolManager;\r
+ private final PluginDescriptor myDescriptor;\r
+ private final String myPath;\r
+\r
+ public ToolSelectorController(@NotNull final NuGetToolManager toolManager,\r
+ @NotNull final PluginDescriptor descriptor,\r
+ @NotNull final WebControllerManager web) {\r
+ myToolManager = toolManager;\r
+ myDescriptor = descriptor;\r
+ myPath = descriptor.getPluginResourcesPath("tool/runnerSettings.html");\r
+ web.registerController(myPath, this);\r
+ }\r
+\r
+ @NotNull\r
+ public String getPath() {\r
+ return myPath;\r
+ }\r
+\r
+ @Override\r
+ protected ModelAndView doHandle(HttpServletRequest request, HttpServletResponse response) throws Exception {\r
+ final String name = safe(request.getParameter("name"));\r
+ String value = parseValue(request, name);\r
+ final Collection<ToolInfo> tools = getTools();\r
+ 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("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
+ private void ensureVersion(@NotNull final String version, @NotNull Collection<ToolInfo> actionInfos) {\r
+ if (!version.startsWith("?")) return;\r
+ for (ToolInfo actionInfo : actionInfos) {\r
+ if (actionInfo.getId().equals(version)) return;\r
+ }\r
+ actionInfos.add(new ToolInfo(version, "Not Installed: " + version.substring(1)));\r
+ }\r
+\r
+ @NotNull\r
+ private Collection<ToolInfo> getTools() {\r
+ final ArrayList<ToolInfo> result = new ArrayList<ToolInfo>();\r
+ for (NuGetInstalledTool nuGetInstalledTool : myToolManager.getInstalledTools()) {\r
+ result.add(new ToolInfo(nuGetInstalledTool));\r
+ }\r
+ return result;\r
+ }\r
+\r
+ private static String safe(@Nullable String s) {\r
+ if (StringUtil.isEmptyOrSpaces(s)) return "";\r
+ return s;\r
+ }\r
+\r
+ @NotNull\r
+ private String parseValue(HttpServletRequest request, String name) {\r
+ String value = null;\r
+\r
+ final BasePropertiesBean bean = (BasePropertiesBean)request.getAttribute("propertiesBean");\r
+ if (bean != null) {\r
+ value = bean.getProperties().get(name);\r
+ }\r
+ if (value == null) {\r
+ value = request.getParameter("value");\r
+ }\r
+ if (value == null) {\r
+ value = "";\r
+ }\r
+ return value;\r
+ }\r
+}\r