source: trunk/www/common/plugin/configure.jsp @ 7494

Last change on this file since 7494 was 7494, checked in by Nicklas Nordborg, 5 years ago

Merged patch release 3.12.3 to the trunk.

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