1 | <%-- $Id: configure.jsp 7030 2015-11-25 10:28:13Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Johan Enell, Jari Häkkinen, Nicklas Nordborg, Gregory Vincic |
---|
5 | Copyright (C) 2007 Johan Enell, Nicklas Nordborg |
---|
6 | |
---|
7 | This file is part of BASE - BioArray Software Environment. |
---|
8 | Available at http://base.thep.lu.se/ |
---|
9 | |
---|
10 | BASE is free software; you can redistribute it and/or |
---|
11 | modify it under the terms of the GNU General Public License |
---|
12 | as published by the Free Software Foundation; either version 3 |
---|
13 | of the License, or (at your option) any later version. |
---|
14 | |
---|
15 | BASE is distributed in the hope that it will be useful, |
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
18 | GNU General Public License for more details. |
---|
19 | |
---|
20 | You should have received a copy of the GNU General Public License |
---|
21 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
22 | ------------------------------------------------------------------ |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page pageEncoding="UTF-8" session="false" |
---|
28 | import="net.sf.basedb.core.SessionControl" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.BasicItem" |
---|
31 | import="net.sf.basedb.core.Permission" |
---|
32 | import="net.sf.basedb.core.Item" |
---|
33 | import="net.sf.basedb.core.File" |
---|
34 | import="net.sf.basedb.core.Nameable" |
---|
35 | import="net.sf.basedb.core.Job" |
---|
36 | import="net.sf.basedb.core.PluginDefinition" |
---|
37 | import="net.sf.basedb.core.PluginConfiguration" |
---|
38 | import="net.sf.basedb.core.PluginConfigurationRequest" |
---|
39 | import="net.sf.basedb.core.RequestInformation" |
---|
40 | import="net.sf.basedb.core.PluginParameter" |
---|
41 | import="net.sf.basedb.core.Type" |
---|
42 | import="net.sf.basedb.core.ParameterType" |
---|
43 | import="net.sf.basedb.core.StringParameterType" |
---|
44 | import="net.sf.basedb.core.IntegerParameterType" |
---|
45 | import="net.sf.basedb.core.LongParameterType" |
---|
46 | import="net.sf.basedb.core.FloatParameterType" |
---|
47 | import="net.sf.basedb.core.DoubleParameterType" |
---|
48 | import="net.sf.basedb.core.ItemParameterType" |
---|
49 | import="net.sf.basedb.core.DateParameterType" |
---|
50 | import="net.sf.basedb.core.TimestampParameterType" |
---|
51 | import="net.sf.basedb.core.BooleanParameterType" |
---|
52 | import="net.sf.basedb.core.FileParameterType" |
---|
53 | import="net.sf.basedb.core.PathParameterType" |
---|
54 | import="net.sf.basedb.core.ItemContext" |
---|
55 | import="net.sf.basedb.core.Path" |
---|
56 | import="net.sf.basedb.util.Enumeration" |
---|
57 | import="net.sf.basedb.util.error.ThrowableUtil" |
---|
58 | import="net.sf.basedb.util.json.JsonConverter" |
---|
59 | import="net.sf.basedb.util.json.JsonUtil" |
---|
60 | import="net.sf.basedb.plugins.util.Parameters" |
---|
61 | import="net.sf.basedb.clients.web.Base" |
---|
62 | import="net.sf.basedb.clients.web.WebException" |
---|
63 | import="net.sf.basedb.clients.web.util.HTML" |
---|
64 | import="net.sf.basedb.util.formatter.Formatter" |
---|
65 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
66 | import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
---|
67 | import="net.sf.basedb.util.Values" |
---|
68 | import="java.util.Date" |
---|
69 | import="java.util.List" |
---|
70 | import="java.util.Arrays" |
---|
71 | import="java.util.HashSet" |
---|
72 | import="java.util.Set" |
---|
73 | import="java.util.Collections" |
---|
74 | import="org.json.simple.JSONArray" |
---|
75 | import="org.json.simple.JSONObject" |
---|
76 | %> |
---|
77 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
78 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
79 | <%! |
---|
80 | List getParameterValues(PluginParameter pp, DbControl dc, javax.servlet.http.HttpServletRequest request, |
---|
81 | PluginConfigurationRequest pcRequest, ItemContext currentContext) |
---|
82 | { |
---|
83 | ParameterType pType = pp.getParameterType(); |
---|
84 | |
---|
85 | // Get the current values... First we look in the http request object... |
---|
86 | String[] requestValues = request.getParameterValues("parameter:"+pp.getName()); |
---|
87 | |
---|
88 | // ...or in the current values from the job / plugin configuration |
---|
89 | List values = requestValues != null ? Arrays.asList(requestValues) : pcRequest.getCurrentParameterValues(pp.getName()); |
---|
90 | |
---|
91 | // File parameters should also check the auto-detected-file (if not enumeration) |
---|
92 | if ((values == null || values.size() == 0) && !pType.isEnumeration() && |
---|
93 | pType instanceof FileParameterType) |
---|
94 | { |
---|
95 | if (currentContext != null && currentContext.getObject("auto-detected-file") != null) |
---|
96 | { |
---|
97 | values = Collections.singletonList(currentContext.getObject("auto-detected-file")); |
---|
98 | currentContext.setObject("auto-detected-file", null); |
---|
99 | } |
---|
100 | } |
---|
101 | // Then, we check the parameters default value |
---|
102 | if ((values == null || values.size() == 0) && pp.getDefaultValue() != null) |
---|
103 | { |
---|
104 | values = Collections.singletonList(pp.getDefaultValue()); |
---|
105 | } |
---|
106 | |
---|
107 | // Item and File parameters will also look in the current context unless they are enumerated |
---|
108 | if ((values == null || values.size() == 0) && |
---|
109 | !pType.isEnumeration() && |
---|
110 | (pType instanceof ItemParameterType || pType instanceof FileParameterType)) |
---|
111 | { |
---|
112 | Item parameterItemType = Item.fromClass(pType.getParameterClass()); |
---|
113 | ItemContext cc = currentContext; |
---|
114 | if (cc == null || parameterItemType != cc.getItemType()) |
---|
115 | { |
---|
116 | cc = dc.getSessionControl().getCurrentContext(parameterItemType); |
---|
117 | } |
---|
118 | if (cc.getId() != 0 && pType.getMultiplicity() == 1) |
---|
119 | { |
---|
120 | values = new java.util.ArrayList(); |
---|
121 | if (pType instanceof FileParameterType) |
---|
122 | { |
---|
123 | try |
---|
124 | { |
---|
125 | values.add(File.getById(dc, cc.getId()).getPath().toString()); |
---|
126 | } |
---|
127 | catch (Throwable t) |
---|
128 | {} |
---|
129 | } |
---|
130 | else |
---|
131 | { |
---|
132 | values.add(cc.getId()); |
---|
133 | } |
---|
134 | } |
---|
135 | else if (cc.getSelected().size() > 0 && pType.getMultiplicity() != 1) |
---|
136 | { |
---|
137 | values = new java.util.ArrayList(cc.getSelected()); |
---|
138 | } |
---|
139 | } |
---|
140 | // Finally, if the parameter has multiplicity=1, is requried and has a list of enumeration values |
---|
141 | if ((values == null || values.size() == 0) && pType.getNotNull() && |
---|
142 | pType.getMultiplicity() == 1 && pType.getItems() != null && pType.getItems().size() > 0) |
---|
143 | { |
---|
144 | values = Collections.singletonList(pType.getItems().get(0)); |
---|
145 | } |
---|
146 | |
---|
147 | return values; |
---|
148 | } |
---|
149 | |
---|
150 | JSONArray convertToJson(List values, DbControl dc, ParameterType pType, Formatter<Date> dateFormatter, Formatter<Date> dateTimeFormatter) |
---|
151 | { |
---|
152 | JSONArray json = new JSONArray(); |
---|
153 | |
---|
154 | if (values != null && values.size() > 0) |
---|
155 | { |
---|
156 | for (Object value : values) |
---|
157 | { |
---|
158 | if (value instanceof Date) |
---|
159 | { |
---|
160 | if (pType.isEnumeration()) |
---|
161 | { |
---|
162 | value = ((Date)value).getTime(); |
---|
163 | } |
---|
164 | else |
---|
165 | { |
---|
166 | if (pType.getValueType() == Type.TIMESTAMP) |
---|
167 | { |
---|
168 | value = dateTimeFormatter.format((Date)value); |
---|
169 | } |
---|
170 | else |
---|
171 | { |
---|
172 | value = dateFormatter.format((Date)value); |
---|
173 | } |
---|
174 | } |
---|
175 | } |
---|
176 | else if (value instanceof File && pType instanceof FileParameterType) |
---|
177 | { |
---|
178 | File file = File.getById(dc, ((File)value).getId()); |
---|
179 | value = file.getPath().toString(); |
---|
180 | } |
---|
181 | else if (value instanceof BasicItem) |
---|
182 | { |
---|
183 | value = ((BasicItem)value).getId(); |
---|
184 | } |
---|
185 | if (value != null) |
---|
186 | { |
---|
187 | json.add(value.toString()); |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | return json; |
---|
192 | } |
---|
193 | %> |
---|
194 | <% |
---|
195 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
196 | final String ID = sc.getId(); |
---|
197 | final float scale = Base.getScale(sc); |
---|
198 | |
---|
199 | final Item itemType = request.getParameter("item_type") == null ? null : Item.valueOf(request.getParameter("item_type")); |
---|
200 | final String subContext = Values.getString(request.getParameter("subcontext"), ""); |
---|
201 | final ItemContext currentContext = itemType == null ? null : sc.getCurrentContext(itemType, subContext); |
---|
202 | final DbControl dc = sc.newDbControl(); |
---|
203 | try |
---|
204 | { |
---|
205 | final Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
206 | String dateFormat = FormatterSettings.getDateFormat(sc); |
---|
207 | String htmlDateFormat = HTML.encodeTags(dateFormat); |
---|
208 | final Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
209 | String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc); |
---|
210 | String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat); |
---|
211 | |
---|
212 | final PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request"); |
---|
213 | if (pcRequest == null) throw new WebException("popup", "No request information found", "No request information found"); |
---|
214 | |
---|
215 | final PluginDefinition plugin = (PluginDefinition)sc.getSessionSetting("plugin.configure.plugin"); |
---|
216 | final Job job = (Job)sc.getSessionSetting("plugin.configure.job"); |
---|
217 | dc.reattachItem(plugin, false); |
---|
218 | |
---|
219 | final Set<String> options = new HashSet<String>(); |
---|
220 | final PluginConfiguration pluginConfig = (PluginConfiguration)sc.getSessionSetting("plugin.configure.config"); |
---|
221 | String errorMessage = (String)sc.getSessionSetting("plugin.configure.errors.message"); |
---|
222 | List<Throwable> errors = (List<Throwable>)sc.getSessionSetting("plugin.configure.errors.list"); |
---|
223 | |
---|
224 | final RequestInformation ri = pcRequest.getRequestInformation(); |
---|
225 | List<PluginParameter<?>> parameters = ri.getParameters(); |
---|
226 | String title = HTML.encodeTags(ri.getTitle()); |
---|
227 | String jobName = Values.getString(request.getParameter("job_name"), title); |
---|
228 | StringBuilder sb = new StringBuilder(); |
---|
229 | String helpText = ri.getDescription(); |
---|
230 | if (helpText == null && pluginConfig != null) helpText = pluginConfig.getDescription(); |
---|
231 | if (helpText == null) helpText = plugin.getDescription(); |
---|
232 | List<File> recentFiles = currentContext == null ? null : (List<File>)currentContext.getRecent(dc, Item.FILE); |
---|
233 | |
---|
234 | JSONArray jsonParameters = JsonUtil.toArray(parameters, new JsonConverter<PluginParameter>() |
---|
235 | { |
---|
236 | public Object convert(PluginParameter pp) |
---|
237 | { |
---|
238 | ParameterType pType = pp.getParameterType(); |
---|
239 | JSONObject json = new JSONObject(); |
---|
240 | json.put("name", pp.getName()); |
---|
241 | json.put("label", pp.getLabel()); |
---|
242 | json.put("hidden", pp.isHidden() ? 1 : 0); |
---|
243 | if ("parserSection".equals(pp.getName())) |
---|
244 | { |
---|
245 | if (plugin.supports("net.sf.basedb.util.parser.ConfigureByExample")) |
---|
246 | { |
---|
247 | options.add("configure-by-example"); |
---|
248 | } |
---|
249 | } |
---|
250 | if (pType != null) |
---|
251 | { |
---|
252 | json.put("valueClass", pType.getClass().getSimpleName()); |
---|
253 | if (pType instanceof PathParameterType) |
---|
254 | { |
---|
255 | PathParameterType ppType = (PathParameterType)pType; |
---|
256 | json.put("pathType", ppType.getPathType().name()); |
---|
257 | } |
---|
258 | json.put("nullable", pType.getNotNull() ? 0 : 1); |
---|
259 | json.put("enumeration", pType.isEnumeration() ? 1 : 0); |
---|
260 | json.put("multiplicity", pType.getMultiplicity()); |
---|
261 | List values = getParameterValues(pp, dc, request, pcRequest, currentContext); |
---|
262 | json.put("values", convertToJson(values, dc, pType, dateFormatter, dateTimeFormatter)); |
---|
263 | } |
---|
264 | return json; |
---|
265 | } |
---|
266 | }); |
---|
267 | %> |
---|
268 | <base:page type="popup" title="<%=title%>"> |
---|
269 | <base:head scripts="~configure.js" styles="parameters.css" /> |
---|
270 | <base:body> |
---|
271 | <h1><%=title%> <base:help |
---|
272 | helpid="<%="runplugin.configure"+(job != null ? "." + plugin.getMainType().name().toLowerCase() : "") %>" /></h1> |
---|
273 | <div id="page-data" class="data-container" |
---|
274 | data-plugin-parameters="<%=HTML.encodeTags(jsonParameters.toJSONString())%>" |
---|
275 | ></div> |
---|
276 | |
---|
277 | <form action="index.jsp?ID=<%=ID%>" method="post" name="configure"> |
---|
278 | <input type="hidden" name="cmd" value="SetParameters"> |
---|
279 | <input type="hidden" name="title" value="<%=title%>"> |
---|
280 | <input type="hidden" name="requestId" value="<%=request.getParameter("requestId")%>"> |
---|
281 | <% |
---|
282 | if (itemType != null) |
---|
283 | { |
---|
284 | %> |
---|
285 | <input type="hidden" name="item_type" value="<%=itemType.name()%>"> |
---|
286 | <% |
---|
287 | } |
---|
288 | %> |
---|
289 | <input type="hidden" name="subcontext" value="<%=subContext%>"> |
---|
290 | |
---|
291 | <div class="content bottomborder"> |
---|
292 | |
---|
293 | <div class="absolutefull bg-filled-100" style="height: 4.5em;"> |
---|
294 | <table style="height: 100%; margin:auto;"><tr><td style="padding: 3px;"> |
---|
295 | <b> |
---|
296 | <%=plugin == null ? "" : HTML.encodeTags(plugin.getName())%> |
---|
297 | <%=pluginConfig == null ? "" : "(" + HTML.encodeTags(pluginConfig.getName()) + ")"%> |
---|
298 | </b><br> |
---|
299 | <%=HTML.niceFormat(helpText)%> |
---|
300 | </td></tr></table> |
---|
301 | </div> |
---|
302 | |
---|
303 | <div class="absolutefull topborder" style="top: 4.5em;"> |
---|
304 | <div class="absolutefull bg-filled-100 rightborder" style="width: 18em;"> |
---|
305 | <div class="absolutefull parameterlist" id="parameter-list" style="bottom: 2em;"> |
---|
306 | </div> |
---|
307 | |
---|
308 | <div class="absolutefull topborder" style="top: auto; bottom: 0px; height: 2em;"> |
---|
309 | <table style="height: 100%; margin:auto;"><tr><td> |
---|
310 | <base:icon image="hasvalues.png" />= has value(s), <base:icon image="required.png" />= required |
---|
311 | </td></tr></table> |
---|
312 | </div> |
---|
313 | </div> |
---|
314 | |
---|
315 | <div class="absolutefull input100" style="left: 18em; padding: 8px;"> |
---|
316 | <% |
---|
317 | if (errorMessage != null || (errors != null && errors.size() > 0)) |
---|
318 | { |
---|
319 | %> |
---|
320 | <div id="errors" style="margin-bottom: 12px;"> |
---|
321 | <div class="messagecontainer error" style="margin: 0px;"> |
---|
322 | <%=errorMessage %> |
---|
323 | <% |
---|
324 | if (errors != null && errors.size() > 0) |
---|
325 | { |
---|
326 | %> |
---|
327 | <div id="showerrorlist"> |
---|
328 | <base:icon |
---|
329 | id="btnShowErrorList" |
---|
330 | image="gonext.png" |
---|
331 | style="color: #FFFFFF;" |
---|
332 | tooltip="Show more information about each error" |
---|
333 | /> |
---|
334 | </div> |
---|
335 | <div id="errorlist" style="display: none; margin: 0px;"> |
---|
336 | <base:icon |
---|
337 | id="btnHideErrorList" |
---|
338 | image="move_down.png" |
---|
339 | style="color: #FFFFFF;" |
---|
340 | tooltip="Show less information" |
---|
341 | /> |
---|
342 | <ol> |
---|
343 | <% |
---|
344 | int i = 0; |
---|
345 | for (Throwable t : errors) |
---|
346 | { |
---|
347 | ++i; |
---|
348 | %> |
---|
349 | <li><%=t.getMessage()%> |
---|
350 | <base:icon |
---|
351 | subclass="auto-init" |
---|
352 | data-auto-init="toggle-stacktrace" |
---|
353 | data-stracktrace-index="<%=i%>" |
---|
354 | image="gonext.png" |
---|
355 | tooltip="Toggle display of detailed stacktrace" |
---|
356 | id="<%="stacktracelink." + i %>" |
---|
357 | /> |
---|
358 | <div id="stacktrace.<%=i%>" class="stacktrace" |
---|
359 | style="display:none; height: 15em;"><%=ThrowableUtil.stackTraceToString(t)%></div> |
---|
360 | <% |
---|
361 | } |
---|
362 | %> |
---|
363 | </ol> |
---|
364 | </div> |
---|
365 | <% |
---|
366 | } |
---|
367 | %> |
---|
368 | </div> |
---|
369 | </div> |
---|
370 | <% |
---|
371 | } |
---|
372 | %> |
---|
373 | |
---|
374 | <div id="valuecontainer" style="display: none;"> |
---|
375 | <table> |
---|
376 | <tr > |
---|
377 | <td> |
---|
378 | <b>Values</b> <span id="multiplicity"></span><br> |
---|
379 | <select name="values" id="values" size="5" style="width: 20em;" multiple> |
---|
380 | </select> |
---|
381 | </td> |
---|
382 | <td> </td> |
---|
383 | <td> |
---|
384 | <td> |
---|
385 | <br> |
---|
386 | <base:buttongroup vertical="true"> |
---|
387 | <base:button id="btnAddValue" subclass="leftaligned" title="Add" /> |
---|
388 | <base:button id="btnRemoveValue" subclass="leftaligned" title="Remove" /> |
---|
389 | </base:buttongroup> |
---|
390 | </td> |
---|
391 | </table> |
---|
392 | </div> |
---|
393 | |
---|
394 | <% |
---|
395 | if (parameters != null && parameters.size() > 0) |
---|
396 | { |
---|
397 | for (PluginParameter<?> param : parameters) |
---|
398 | { |
---|
399 | if (!param.isHidden()) |
---|
400 | { |
---|
401 | ParameterType pType = param.getParameterType(); |
---|
402 | String fieldName = "parameter-"+param.getName(); |
---|
403 | if (pType != null) |
---|
404 | { |
---|
405 | int multiplicity = pType.getMultiplicity(); |
---|
406 | String select = null; |
---|
407 | if (multiplicity == 0) |
---|
408 | { |
---|
409 | if (pType.getNotNull()) |
---|
410 | { |
---|
411 | select = "Select one or more"; |
---|
412 | } |
---|
413 | else |
---|
414 | { |
---|
415 | select = "Select zero or more"; |
---|
416 | } |
---|
417 | } |
---|
418 | else if (multiplicity == 1) |
---|
419 | { |
---|
420 | select = "Select one"; |
---|
421 | } |
---|
422 | else |
---|
423 | { |
---|
424 | if (pType.getNotNull()) |
---|
425 | { |
---|
426 | select = "Select 1 -- " + multiplicity; |
---|
427 | } |
---|
428 | else |
---|
429 | { |
---|
430 | select = "Select 0 -- " + multiplicity; |
---|
431 | } |
---|
432 | } |
---|
433 | %> |
---|
434 | <div id="<%=fieldName%>:section" style="display: none;"> |
---|
435 | <% |
---|
436 | if (pType.isEnumeration()) |
---|
437 | { |
---|
438 | Enumeration<?, String> enumeration = pType.getEnumeration(); |
---|
439 | List<?> values = pType.getItems(); |
---|
440 | %> |
---|
441 | <b><%=HTML.encodeTags(param.getLabel())%></b> (<%=select%>) |
---|
442 | <% |
---|
443 | if (multiplicity != 1) |
---|
444 | { |
---|
445 | %> |
---|
446 | <base:icon |
---|
447 | id="<%=fieldName+":select-all"%>" |
---|
448 | subclass="auto-init" |
---|
449 | data-auto-init="select-all" |
---|
450 | data-field="<%=fieldName%>" |
---|
451 | image="check_uncheck.png" |
---|
452 | tooltip="Select/deselect all" |
---|
453 | /> |
---|
454 | <% |
---|
455 | } |
---|
456 | %> |
---|
457 | <br> |
---|
458 | <% |
---|
459 | if (multiplicity == 1) |
---|
460 | { |
---|
461 | %> |
---|
462 | <select name="<%=fieldName%>" id="<%=fieldName%>" style="min-width: 8em;"> |
---|
463 | <% |
---|
464 | if (!pType.getNotNull()) |
---|
465 | { |
---|
466 | %> |
---|
467 | <option value="" style="font-style: italic;">- not specified - |
---|
468 | <% |
---|
469 | } |
---|
470 | } |
---|
471 | else |
---|
472 | { |
---|
473 | %> |
---|
474 | <select name="<%=fieldName%>" id="<%=fieldName%>" |
---|
475 | multiple size="10" style="width: 30em;"> |
---|
476 | <% |
---|
477 | } |
---|
478 | for (int i = 0; i < values.size(); ++i) |
---|
479 | { |
---|
480 | Object value; |
---|
481 | String listValue = ""; |
---|
482 | String listText = ""; |
---|
483 | String listTitle = ""; |
---|
484 | if (enumeration != null) |
---|
485 | { |
---|
486 | value = enumeration.getKey(i); |
---|
487 | listText = HTML.encodeTags(enumeration.getValue(i)); |
---|
488 | } |
---|
489 | else |
---|
490 | { |
---|
491 | value = values.get(i); |
---|
492 | } |
---|
493 | if (value instanceof Date) |
---|
494 | { |
---|
495 | listValue = Long.toString(((Date)value).getTime()); |
---|
496 | if (enumeration == null) |
---|
497 | { |
---|
498 | if (pType.getValueType() == Type.TIMESTAMP) |
---|
499 | { |
---|
500 | listText = dateTimeFormatter.format((Date)value); |
---|
501 | } |
---|
502 | else |
---|
503 | { |
---|
504 | listText = dateFormatter.format((Date)value); |
---|
505 | } |
---|
506 | } |
---|
507 | } |
---|
508 | else if (value instanceof BasicItem) |
---|
509 | { |
---|
510 | BasicItem item = (BasicItem)value; |
---|
511 | listValue = Integer.toString(item.getId()); |
---|
512 | if (item instanceof Nameable) |
---|
513 | { |
---|
514 | Nameable nameable = (Nameable)item; |
---|
515 | if (enumeration == null) listText = HTML.encodeTags(nameable.getName()); |
---|
516 | listTitle = HTML.encodeTags(nameable.getDescription()); |
---|
517 | } |
---|
518 | else |
---|
519 | { |
---|
520 | if (enumeration == null) listText = HTML.encodeTags(item.toString()); |
---|
521 | } |
---|
522 | } |
---|
523 | else |
---|
524 | { |
---|
525 | listValue = HTML.encodeTags(value == null ? "" : value.toString()); |
---|
526 | if (enumeration == null) listText = listValue; |
---|
527 | } |
---|
528 | %> |
---|
529 | <option value="<%=listValue%>" title="<%=listTitle%>"><%=listText%> |
---|
530 | <% |
---|
531 | } |
---|
532 | %> |
---|
533 | </select> |
---|
534 | <% |
---|
535 | } |
---|
536 | else if (pType instanceof StringParameterType) |
---|
537 | { |
---|
538 | Integer maxLength = ((StringParameterType)pType).getMaxLength(); |
---|
539 | int height = pType.getHeight() <= 0 ? 6 : pType.getHeight(); |
---|
540 | if (height > 20) height = 20; |
---|
541 | boolean isPassword = pType.isMasked(); |
---|
542 | if (maxLength == null || maxLength > 255) |
---|
543 | { |
---|
544 | %> |
---|
545 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Text)<br> |
---|
546 | <table style="width: 100%;"> |
---|
547 | <tr> |
---|
548 | <td> |
---|
549 | <textarea class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
550 | name="<%=fieldName%>" id="<%=fieldName%>" rows="<%=height%>" |
---|
551 | ></textarea> |
---|
552 | </td> |
---|
553 | <td style="width: 20px;"> |
---|
554 | <base:zoom textarea="<%=fieldName%>" title="<%=HTML.encodeTags(param.getLabel()) %>" /> |
---|
555 | </td> |
---|
556 | </tr> |
---|
557 | </table> |
---|
558 | <% |
---|
559 | } |
---|
560 | else |
---|
561 | { |
---|
562 | %> |
---|
563 | <b><%=HTML.encodeTags(param.getLabel())%></b> (String)<br> |
---|
564 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
565 | type="<%=isPassword ? "password": "text"%>" |
---|
566 | name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
567 | maxlength="<%=maxLength%>"> |
---|
568 | <% |
---|
569 | } |
---|
570 | } |
---|
571 | else if (pType instanceof IntegerParameterType) |
---|
572 | { |
---|
573 | IntegerParameterType ipType = (IntegerParameterType)pType; |
---|
574 | Integer minValue = ipType.getLowerLimit(); |
---|
575 | Integer maxValue = ipType.getUpperLimit(); |
---|
576 | String minMax = ""; |
---|
577 | if (minValue != null && maxValue != null) |
---|
578 | { |
---|
579 | minMax = ": " + minValue + " -- " +maxValue; |
---|
580 | } |
---|
581 | else if (minValue != null) |
---|
582 | { |
---|
583 | minMax = " >= "+minValue; |
---|
584 | } |
---|
585 | else if (maxValue != null) |
---|
586 | { |
---|
587 | minMax = " <= "+maxValue; |
---|
588 | } |
---|
589 | %> |
---|
590 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Integer<%=minMax%>)<br> |
---|
591 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
592 | type="text" name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
593 | maxlength="20"> |
---|
594 | <% |
---|
595 | } |
---|
596 | else if (pType instanceof LongParameterType) |
---|
597 | { |
---|
598 | LongParameterType ipType = (LongParameterType)pType; |
---|
599 | Long minValue = ipType.getLowerLimit(); |
---|
600 | Long maxValue = ipType.getUpperLimit(); |
---|
601 | String minMax = ""; |
---|
602 | if (minValue != null && maxValue != null) |
---|
603 | { |
---|
604 | minMax = ": " + minValue + " -- " +maxValue; |
---|
605 | } |
---|
606 | else if (minValue != null) |
---|
607 | { |
---|
608 | minMax = " >= "+minValue; |
---|
609 | } |
---|
610 | else if (maxValue != null) |
---|
611 | { |
---|
612 | minMax = " <= "+maxValue; |
---|
613 | } |
---|
614 | %> |
---|
615 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Long<%=minMax%>)<br> |
---|
616 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
617 | type="text" name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
618 | maxlength="20"> |
---|
619 | <% |
---|
620 | } |
---|
621 | else if (pType instanceof FloatParameterType) |
---|
622 | { |
---|
623 | FloatParameterType ipType = (FloatParameterType)pType; |
---|
624 | Float minValue = ipType.getLowerLimit(); |
---|
625 | Float maxValue = ipType.getUpperLimit(); |
---|
626 | String minMax = ""; |
---|
627 | if (minValue != null && maxValue != null) |
---|
628 | { |
---|
629 | minMax = ": " + minValue + " -- " +maxValue; |
---|
630 | } |
---|
631 | else if (minValue != null) |
---|
632 | { |
---|
633 | minMax = " >= "+minValue; |
---|
634 | } |
---|
635 | else if (maxValue != null) |
---|
636 | { |
---|
637 | minMax = " <= "+maxValue; |
---|
638 | } |
---|
639 | %> |
---|
640 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Float<%=minMax%>)<br> |
---|
641 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
642 | type="text" name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
643 | maxlength="20"> |
---|
644 | <% |
---|
645 | } |
---|
646 | else if (pType instanceof DoubleParameterType) |
---|
647 | { |
---|
648 | DoubleParameterType ipType = (DoubleParameterType)pType; |
---|
649 | Double minValue = ipType.getLowerLimit(); |
---|
650 | Double maxValue = ipType.getUpperLimit(); |
---|
651 | String minMax = ""; |
---|
652 | if (minValue != null && maxValue != null) |
---|
653 | { |
---|
654 | minMax = ": " + minValue + " -- " +maxValue; |
---|
655 | } |
---|
656 | else if (minValue != null) |
---|
657 | { |
---|
658 | minMax = " >= "+minValue; |
---|
659 | } |
---|
660 | else if (maxValue != null) |
---|
661 | { |
---|
662 | minMax = " <= "+maxValue; |
---|
663 | } |
---|
664 | %> |
---|
665 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Double<%=minMax%>)<br> |
---|
666 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
667 | type="text" name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
668 | maxlength="20"> |
---|
669 | <% |
---|
670 | } |
---|
671 | else if (pType instanceof DateParameterType) |
---|
672 | { |
---|
673 | %> |
---|
674 | <table> |
---|
675 | <tr> |
---|
676 | <td> |
---|
677 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Date)<br> |
---|
678 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
679 | type="text" name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
680 | size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>" |
---|
681 | > |
---|
682 | </td> |
---|
683 | <td> |
---|
684 | <br> |
---|
685 | <base:calendar textarea="<%=fieldName%>" title="Value" /> |
---|
686 | </td> |
---|
687 | </tr> |
---|
688 | </table> |
---|
689 | <% |
---|
690 | } |
---|
691 | else if (pType instanceof TimestampParameterType) |
---|
692 | { |
---|
693 | %> |
---|
694 | <table> |
---|
695 | <tr> |
---|
696 | <td> |
---|
697 | <b><%=HTML.encodeTags(param.getLabel())%></b> (Timestamp)<br> |
---|
698 | <input class="text <%=pType.getNotNull() ? "required" : ""%>" |
---|
699 | type="text" name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
700 | size="20" maxlength="20" title="Enter timestamp in format: <%=htmlDateTimeFormat%>" |
---|
701 | > |
---|
702 | </td> |
---|
703 | <td> |
---|
704 | <br> |
---|
705 | <base:calendar textarea="<%=fieldName%>" title="Value" data-use-time="1" |
---|
706 | tooltip="Select a timestamp from a calendar" |
---|
707 | /> |
---|
708 | </td> |
---|
709 | </tr> |
---|
710 | </table> |
---|
711 | <% |
---|
712 | } |
---|
713 | else if (pType instanceof BooleanParameterType) |
---|
714 | { |
---|
715 | %> |
---|
716 | <b><%=HTML.encodeTags(param.getLabel())%></b><br> |
---|
717 | <label><input type="radio" name="<%=fieldName%>" id="<%=fieldName%>:null" value="" checked |
---|
718 | ><i>- not specified -</i></label><br> |
---|
719 | <label><input type="radio" name="<%=fieldName%>" id="<%=fieldName%>:true" value="true" |
---|
720 | >true</label><br> |
---|
721 | <label><input type="radio" name="<%=fieldName%>" id="<%=fieldName%>:false" value="false" |
---|
722 | >false</label> |
---|
723 | <% |
---|
724 | } |
---|
725 | else if (pType instanceof FileParameterType) |
---|
726 | { |
---|
727 | %> |
---|
728 | <b><%=HTML.encodeTags(param.getLabel())%></b><br> |
---|
729 | <table style="width: 100%;"> |
---|
730 | <tr> |
---|
731 | <td style="width: 98%;"><input class="text <%=pType.getNotNull() ? "required" : ""%>" type="text" |
---|
732 | name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
733 | ></td> |
---|
734 | <td><base:button |
---|
735 | id="<%=fieldName+":browse" %>" |
---|
736 | data-field="<%=fieldName%>" |
---|
737 | title="Browse…" |
---|
738 | /></td> |
---|
739 | </tr> |
---|
740 | </table> |
---|
741 | <% |
---|
742 | if (recentFiles != null && recentFiles.size() > 0) |
---|
743 | { |
---|
744 | %> |
---|
745 | <b>Recently used</b><br> |
---|
746 | <select |
---|
747 | id="<%=fieldName%>:recent" |
---|
748 | name="<%=fieldName%>:recent" |
---|
749 | data-field="<%=fieldName %>" |
---|
750 | style="width: 98%;"> |
---|
751 | <option value=""> |
---|
752 | <% |
---|
753 | for (File recent : recentFiles) |
---|
754 | { |
---|
755 | %> |
---|
756 | <option value="<%=recent.getId()%>"><%=HTML.encodeTags(recent.getPath().toString())%> |
---|
757 | <% |
---|
758 | } |
---|
759 | %> |
---|
760 | </select> |
---|
761 | <% |
---|
762 | } |
---|
763 | } |
---|
764 | else if (pType instanceof ItemParameterType) |
---|
765 | { |
---|
766 | Item parameterItemType = Item.fromClass(pType.getParameterClass()); |
---|
767 | BasicItem item = (BasicItem)pcRequest.getCurrentParameterValue(param.getName()); |
---|
768 | if (item == null) |
---|
769 | { |
---|
770 | ItemContext cc = sc.getCurrentContext(parameterItemType, parameterItemType == itemType ? subContext : ""); |
---|
771 | if (cc.getId() != 0) |
---|
772 | { |
---|
773 | try |
---|
774 | { |
---|
775 | item = parameterItemType.getById(dc, cc.getId()); |
---|
776 | } |
---|
777 | catch (Throwable t) |
---|
778 | {} |
---|
779 | } |
---|
780 | } |
---|
781 | if (item != null) |
---|
782 | { |
---|
783 | String display = ""; |
---|
784 | if (item instanceof Nameable) |
---|
785 | { |
---|
786 | Nameable nameable = (Nameable)item; |
---|
787 | display = nameable.getName(); |
---|
788 | } |
---|
789 | else |
---|
790 | { |
---|
791 | display = item.toString(); |
---|
792 | } |
---|
793 | %> |
---|
794 | <b><%=HTML.encodeTags(param.getLabel())%></b><br> |
---|
795 | <input class="text disabled" size="50" |
---|
796 | name="<%=fieldName%>" id="<%=fieldName%>" type="text" disabled |
---|
797 | value="<%=HTML.encodeTags(display)%>"> |
---|
798 | <% |
---|
799 | } |
---|
800 | } |
---|
801 | else if (pType instanceof PathParameterType) |
---|
802 | { |
---|
803 | %> |
---|
804 | <b><%=HTML.encodeTags(param.getLabel())%></b><br> |
---|
805 | <table style="width: 100%;"> |
---|
806 | <tr> |
---|
807 | <td style="width: 98%;"><input type="text" class="text" |
---|
808 | name="<%=fieldName%>" id="<%=fieldName%>" value="" |
---|
809 | ></td> |
---|
810 | <td><base:button |
---|
811 | id="<%=fieldName+":browse" %>" |
---|
812 | data-field="<%=fieldName%>" |
---|
813 | title="Browse…" |
---|
814 | /></td> |
---|
815 | </tr> |
---|
816 | </table> |
---|
817 | <% |
---|
818 | } |
---|
819 | else |
---|
820 | { |
---|
821 | %> |
---|
822 | <b><%=HTML.encodeTags(param.getLabel())%></b><br> |
---|
823 | <% |
---|
824 | } |
---|
825 | String help = param.getDescription(); |
---|
826 | if (help == null || "".equals(help)) help = "<i>No help available for this parameter</i>"; |
---|
827 | %> |
---|
828 | <div class="messagecontainer help" style="margin-left: 0px; margin-right: 0px;"> |
---|
829 | <%=HTML.niceFormat(help)%> |
---|
830 | </div> |
---|
831 | </div> |
---|
832 | <% |
---|
833 | } |
---|
834 | else |
---|
835 | { |
---|
836 | String help = param.getDescription(); |
---|
837 | if (help == null || "".equals(help)) help = "<i>No help available for this parameter</i>"; |
---|
838 | %> |
---|
839 | <div id="<%=fieldName%>:section" style="display: none;" class="messagecontainer help"> |
---|
840 | <%=HTML.niceFormat(help)%> |
---|
841 | </div> |
---|
842 | <% |
---|
843 | } |
---|
844 | } |
---|
845 | } |
---|
846 | } |
---|
847 | %> |
---|
848 | |
---|
849 | </div> |
---|
850 | |
---|
851 | </div> |
---|
852 | |
---|
853 | </div> |
---|
854 | |
---|
855 | </form> |
---|
856 | |
---|
857 | <base:buttongroup subclass="dialogbuttons"> |
---|
858 | <base:button id="btnTestWithFile" title="Test with file…" image="file.png" |
---|
859 | tooltip="Use an uploaded file to create the regular expressions and column mappings" |
---|
860 | visible="<%=options.contains("configure-by-example")%>" /> |
---|
861 | <base:button id="btnNext" title="Next" /> |
---|
862 | <base:button id="close" title="Cancel" /> |
---|
863 | </base:buttongroup> |
---|
864 | </base:body> |
---|
865 | </base:page> |
---|
866 | <% |
---|
867 | } |
---|
868 | finally |
---|
869 | { |
---|
870 | if (dc != null) dc.close(); |
---|
871 | } |
---|
872 | %> |
---|