1 | <%-- $Id: edit_server.jsp 1108 2009-06-04 07:18:10Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2009 Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 2 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, |
---|
21 | Boston, MA 02111-1307, USA. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | --%> |
---|
26 | <%@ page |
---|
27 | pageEncoding="UTF-8" |
---|
28 | session="false" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.SessionControl" |
---|
31 | import="net.sf.basedb.core.PluginConfigurationRequest" |
---|
32 | import="net.sf.basedb.core.RequestInformation" |
---|
33 | import="net.sf.basedb.core.PluginParameter" |
---|
34 | import="net.sf.basedb.clients.web.Base" |
---|
35 | import="net.sf.basedb.clients.web.util.HTML" |
---|
36 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
37 | import="net.sf.basedb.util.Values" |
---|
38 | import="java.util.List" |
---|
39 | %> |
---|
40 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
41 | <% |
---|
42 | final SessionControl sc = Base.getExistingSessionControl(request, true); |
---|
43 | final String ID = sc.getId(); |
---|
44 | |
---|
45 | final PluginConfigurationRequest pcRequest = |
---|
46 | (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request"); |
---|
47 | final RequestInformation ri = pcRequest.getRequestInformation(); |
---|
48 | |
---|
49 | final String errorMessage = (String)sc.getSessionSetting("plugin.configure.errors.message"); |
---|
50 | final List<Throwable> errors = (List<Throwable>)sc.getSessionSetting("plugin.configure.errors.list"); |
---|
51 | |
---|
52 | final PluginParameter gpServer = ri.getParameter("gpServer"); |
---|
53 | final String currentGpServer = (String)pcRequest.getCurrentParameterValue("gpServer"); |
---|
54 | |
---|
55 | final PluginParameter gpModule = ri.getParameter("gpModule"); |
---|
56 | final String currentGpModule = (String)pcRequest.getCurrentParameterValue("gpModule"); |
---|
57 | |
---|
58 | final String homeUrl = ExtensionsControl.getHomeUrl("net.sf.basedb.genepattern.options"); |
---|
59 | final String title = ri.getTitle(); |
---|
60 | %> |
---|
61 | <base:page type="popup" title="<%=HTML.encodeTags(title)%>"> |
---|
62 | <base:head scripts="ajax.js,newjoust.js"> |
---|
63 | <script language="JavaScript"> |
---|
64 | function hideErrorList() |
---|
65 | { |
---|
66 | Main.hide('errorlist'); |
---|
67 | Main.show('showerrorlist'); |
---|
68 | } |
---|
69 | function showErrorList() |
---|
70 | { |
---|
71 | Main.show('errorlist'); |
---|
72 | Main.hide('showerrorlist'); |
---|
73 | } |
---|
74 | function cancelPlugin() |
---|
75 | { |
---|
76 | location.href= 'index.jsp?ID=<%=ID%>&cmd=CancelWizard'; |
---|
77 | } |
---|
78 | function saveSettings() |
---|
79 | { |
---|
80 | var frm = document.forms['plugin']; |
---|
81 | if (frm['parameter:gpModule'].value == '') |
---|
82 | { |
---|
83 | alert('Please enter module or pipeline name'); |
---|
84 | frm['parameter:gpModule'].focus(); |
---|
85 | return; |
---|
86 | } |
---|
87 | frm.submit(); |
---|
88 | } |
---|
89 | function getModuleList() |
---|
90 | { |
---|
91 | var frm = document.forms['plugin']; |
---|
92 | var url = '<%=homeUrl%>/Ajax.servlet?ID=<%=ID%>&cmd=ListModules'; |
---|
93 | url += '&server=' + encodeURIComponent(frm['parameter:gpServer'].value); |
---|
94 | var request = Ajax.getXmlHttpRequest(); |
---|
95 | request.open("GET", url, true); |
---|
96 | Ajax.setReadyStateHandler(request, getModulesListCallback); |
---|
97 | request.send(null); |
---|
98 | document.getElementById('ajaxStatus').innerHTML = 'Please wait. . .'; |
---|
99 | //setTimeout('getModulesListCallback(null)', 15000); |
---|
100 | setTimeout('showProgress()', 250); |
---|
101 | } |
---|
102 | function showProgress() |
---|
103 | { |
---|
104 | var progress = document.getElementById('ajaxStatus'); |
---|
105 | if (progress.innerHTML.indexOf('Please wait') == 0) |
---|
106 | { |
---|
107 | progress.innerHTML += ' .'; |
---|
108 | setTimeout('showProgress()', 250); |
---|
109 | } |
---|
110 | } |
---|
111 | |
---|
112 | function getModulesListCallback(request) |
---|
113 | { |
---|
114 | if (document.getElementById('ajaxStatus').innerHTML.indexOf('Please wait') != 0) return; |
---|
115 | var frm = document.forms['plugin']; |
---|
116 | var responseText = request != null ? |
---|
117 | request.responseText : |
---|
118 | 'status:error\nstacktrace:No response from server'; |
---|
119 | var response = Ajax.parseResponse(responseText); |
---|
120 | if (response.isError()) |
---|
121 | { |
---|
122 | var stacktrace = response.getElements()[0]['stacktrace']; |
---|
123 | document.getElementById('ajaxStatus').innerHTML = |
---|
124 | '<div class="error stacktrace" style="width: 420px; height: 15em; overflow: auto;">' + stacktrace + '</div>'; |
---|
125 | } |
---|
126 | else |
---|
127 | { |
---|
128 | var modules = response.getElements(); |
---|
129 | modules.sort(compareGpModules); |
---|
130 | var lastType = null; |
---|
131 | var html = '<div style="width: 420px; height: 15em; overflow: auto;">'; |
---|
132 | for (var i = 0; i < modules.length; i++) |
---|
133 | { |
---|
134 | var type = modules[i]['taskType']; |
---|
135 | if (type != 'Visualizer') |
---|
136 | { |
---|
137 | if (type != lastType) |
---|
138 | { |
---|
139 | html += '<b>' + type + '</b><br>'; |
---|
140 | lastType = type; |
---|
141 | } |
---|
142 | html += ' <a id="module.' + i + '" href="javascript:setModule('+i+')" title="' + modules[i]['description'] + '">'; |
---|
143 | html += modules[i]['name'] + '</a><br>'; |
---|
144 | } |
---|
145 | } |
---|
146 | html += '</div>'; |
---|
147 | document.getElementById('ajaxStatus').innerHTML = html; |
---|
148 | } |
---|
149 | } |
---|
150 | function compareGpModules(m1, m2) |
---|
151 | { |
---|
152 | var type1 = m1['taskType']; |
---|
153 | var type2 = m2['taskType']; |
---|
154 | if (type1 < type2) return -1; |
---|
155 | if (type1 > type2) return 1; |
---|
156 | var name1 = m1['name']; |
---|
157 | var name2 = m2['name']; |
---|
158 | if (name1 < name2) return -1; |
---|
159 | if (name1 > name2) return 1; |
---|
160 | return 0; |
---|
161 | } |
---|
162 | function setModule(index) |
---|
163 | { |
---|
164 | var frm = document.forms['plugin']; |
---|
165 | frm['parameter:gpModule'].value = document.getElementById('module.'+index).innerHTML; |
---|
166 | } |
---|
167 | </script> |
---|
168 | </base:head> |
---|
169 | <base:body> |
---|
170 | <form action="index.jsp" method="post" name="plugin"> |
---|
171 | <input type="hidden" name="ID" value="<%=ID%>"> |
---|
172 | <input type="hidden" name="requestId" value="<%=request.getParameter("requestId")%>"> |
---|
173 | <input type="hidden" name="cmd" value="SetParameters"> |
---|
174 | |
---|
175 | |
---|
176 | <h3 class="docked"><%=HTML.encodeTags(title)%></h3> |
---|
177 | <div class="boxedbottom"> |
---|
178 | <% |
---|
179 | if (errorMessage != null || (errors != null && errors.size() > 0)) |
---|
180 | { |
---|
181 | %> |
---|
182 | <div id="errors" style="margin-bottom: 12px;" class="parameterhelp"> |
---|
183 | <div class="error" style="margin: 0px;"> |
---|
184 | <%=errorMessage %> |
---|
185 | </div> |
---|
186 | <% |
---|
187 | if (errors != null && errors.size() > 0) |
---|
188 | { |
---|
189 | %> |
---|
190 | <div id="showerrorlist" style="display: none;"> |
---|
191 | <base:icon image="bullet.gif" /><a href="javascript:showErrorList()">Show details</a> |
---|
192 | </div> |
---|
193 | <div id="errorlist"> |
---|
194 | <ol> |
---|
195 | <% |
---|
196 | for (Throwable t : errors) |
---|
197 | { |
---|
198 | %> |
---|
199 | <li><%=t.getMessage()%><br> |
---|
200 | <% |
---|
201 | } |
---|
202 | %> |
---|
203 | </ol> |
---|
204 | <base:icon image="bullet.gif" /><a href="javascript:hideErrorList()">Hide details</a> |
---|
205 | </div> |
---|
206 | <% |
---|
207 | } |
---|
208 | %> |
---|
209 | </div> |
---|
210 | <% |
---|
211 | } |
---|
212 | %> |
---|
213 | |
---|
214 | <table class="form" cellspacing=0> |
---|
215 | <tr> |
---|
216 | <td></td> |
---|
217 | <td><%=HTML.encodeTags(ri.getDescription())%></td> |
---|
218 | </tr> |
---|
219 | <tr> |
---|
220 | <td class="prompt"><%=HTML.encodeTags(gpServer.getLabel())%></td> |
---|
221 | <td> |
---|
222 | <select name="parameter:gpServer" class="required" |
---|
223 | title="<%=HTML.encodeTags(gpServer.getDescription())%>" > |
---|
224 | <% |
---|
225 | for (String server : (List<String>)gpServer.getParameterType().getItems()) |
---|
226 | { |
---|
227 | String option = HTML.encodeTags(server); |
---|
228 | %> |
---|
229 | <option value="<%=option%>" <%=server.equals(currentGpServer) ? "selected" : ""%> |
---|
230 | ><%=option%> |
---|
231 | <% |
---|
232 | } |
---|
233 | %> |
---|
234 | </select> |
---|
235 | </td> |
---|
236 | </tr> |
---|
237 | <tr> |
---|
238 | <td class="prompt"><%=HTML.encodeTags(gpModule.getLabel())%></td> |
---|
239 | <td> |
---|
240 | <input class="text required" type="text" name="parameter:gpModule" size="40" |
---|
241 | value="<%=HTML.encodeTags(currentGpModule)%>" |
---|
242 | title="<%=HTML.encodeTags(gpModule.getDescription())%>"> |
---|
243 | </td> |
---|
244 | </tr> |
---|
245 | <tr> |
---|
246 | <td class="prompt">Available modules</td> |
---|
247 | <td> |
---|
248 | <table border=0 cellspacing=0><tr><td><base:button |
---|
249 | title="Get list" onclick="getModuleList()" |
---|
250 | image="<%=homeUrl + "/images/genepattern.gif" %>" |
---|
251 | /></td> |
---|
252 | </tr></table> |
---|
253 | </td> |
---|
254 | </tr> |
---|
255 | <tr> |
---|
256 | <td class="prompt"></td> |
---|
257 | <td id="ajaxStatus"></td> |
---|
258 | </tr> |
---|
259 | </table> |
---|
260 | </div> |
---|
261 | <p> |
---|
262 | <table align="center"> |
---|
263 | <tr> |
---|
264 | <td width="50%"><base:button onclick="saveSettings();" title="Next" /></td> |
---|
265 | <td width="50%"><base:button onclick="cancelPlugin();" title="Cancel" /></td> |
---|
266 | </tr> |
---|
267 | </table> |
---|
268 | </base:body> |
---|
269 | </base:page> |
---|