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

Last change on this file since 3987 was 3987, checked in by Nicklas Nordborg, 16 years ago

Fixes #832: Button for selecting all values or no values in an enumerated parameter list

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 37.6 KB
Line 
1<%-- $Id: configure.jsp 3987 2007-11-22 07:28:34Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Johan Enell, Jari Hakkinen, 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 2
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 this program; if not, write to the Free Software
22  Foundation, Inc., 59 Temple Place - Suite 330,
23  Boston, MA  02111-1307, USA.
24  ------------------------------------------------------------------
25
26  @author Nicklas
27  @version 2.0
28--%>
29<%@ page session="false"
30  import="net.sf.basedb.core.SessionControl"
31  import="net.sf.basedb.core.DbControl"
32  import="net.sf.basedb.core.BasicItem"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.Item"
35  import="net.sf.basedb.core.File"
36  import="net.sf.basedb.core.Nameable"
37  import="net.sf.basedb.core.Job"
38  import="net.sf.basedb.core.PluginDefinition"
39  import="net.sf.basedb.core.PluginConfiguration"
40  import="net.sf.basedb.core.PluginConfigurationRequest"
41  import="net.sf.basedb.core.RequestInformation"
42  import="net.sf.basedb.core.PluginParameter"
43  import="net.sf.basedb.core.ParameterType"
44  import="net.sf.basedb.core.StringParameterType"
45  import="net.sf.basedb.core.IntegerParameterType"
46  import="net.sf.basedb.core.LongParameterType"
47  import="net.sf.basedb.core.FloatParameterType"
48  import="net.sf.basedb.core.DoubleParameterType"
49  import="net.sf.basedb.core.ItemParameterType"
50  import="net.sf.basedb.core.DateParameterType"
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.clients.web.Base"
58  import="net.sf.basedb.clients.web.WebException"
59  import="net.sf.basedb.clients.web.util.HTML"
60  import="net.sf.basedb.util.formatter.Formatter"
61  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
62  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
63  import="net.sf.basedb.util.Values"
64  import="java.util.Date"
65  import="java.util.List"
66  import="java.util.Arrays"
67  import="java.util.Collections"
68%>
69<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
70<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
71<%
72final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
73final String ID = sc.getId();
74final float scale = Base.getScale(sc);
75final String clazz = "class=\"text\"";
76final String requiredClazz = "class=\"text required\"";
77
78final Item itemType = request.getParameter("item_type") == null ? null : Item.valueOf(request.getParameter("item_type"));
79final String subContext = Values.getString(request.getParameter("subcontext"), "");
80final ItemContext currentContext = itemType == null ? null : sc.getCurrentContext(itemType, subContext);
81DbControl dc = null;
82try
83{
84  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
85  String dateFormat = FormatterSettings.getDateFormat(sc);
86  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
87  String htmlDateFormat = HTML.encodeTags(dateFormat);
88
89  dc = sc.newDbControl();
90  PluginConfigurationRequest pcRequest = (PluginConfigurationRequest)sc.getSessionSetting("plugin.configure.request");
91  if (pcRequest == null) throw new WebException("popup", "No request information found", "No request information found");
92 
93  PluginDefinition plugin = (PluginDefinition)sc.getSessionSetting("plugin.configure.plugin");
94  Job job = (Job)sc.getSessionSetting("plugin.configure.job");
95  dc.reattachItem(plugin);
96  boolean configureByExample = false;
97  PluginConfiguration pluginConfig = (PluginConfiguration)sc.getSessionSetting("plugin.configure.config");
98  String errorMessage = (String)sc.getSessionSetting("plugin.configure.errors.message");
99  List<Throwable> errors = (List<Throwable>)sc.getSessionSetting("plugin.configure.errors.list");
100 
101  RequestInformation ri = pcRequest.getRequestInformation();
102  List<PluginParameter<?>> parameters =  ri.getParameters();
103  String title = HTML.encodeTags(ri.getTitle());
104  String jobName = Values.getString(request.getParameter("job_name"), title);
105  StringBuilder sb = new StringBuilder();
106 
107  List<File> recentFiles = null;
108  %>
109
110  <base:page type="popup" title="<%=title%>">
111  <base:head scripts="plugin.js,parameters.js" styles="parameters.css">
112    <script language="JavaScript">
113    function init()
114    {
115      var width = Main.getWindowWidth();
116      var height = Main.getWindowHeight();
117      if (height < 600) height = 600;
118      if (width < 800) width = 800; // >
119      window.resizeTo(width, height);
120      <%
121      if (parameters != null && parameters.size() > 0)
122      {
123        for (PluginParameter<?> param : parameters)
124        {
125          ParameterType pType = param.getParameterType();
126          String name = param.getName();
127          if ("parserSection".equals(name)) 
128          {
129            configureByExample = plugin.supports("net.sf.basedb.util.parser.ConfigureByExample");
130          }
131          String label = HTML.encodeTags(Values.trimString(param.getLabel(), 30));
132          String fullLabel = HTML.encodeTags(param.getLabel());
133          if (pType != null)
134          {
135            // Get the current values... First we look in the http request object...
136            String[] requestValues = request.getParameterValues("parameter:"+param.getName());
137            // ...or in the current values from the job / plugin configuration
138            List values = requestValues != null ? Arrays.asList(requestValues) : pcRequest.getCurrentParameterValues(param.getName());
139            // Then, we check the parameters default value
140            if ((values == null || values.size() == 0) && param.getDefaultValue() != null)
141            {
142              values = Collections.singletonList(param.getDefaultValue());
143            }
144            // Item and File parameters will also look in the current context unless they are enumerated
145            if ((values == null || values.size() == 0) && 
146              !pType.isEnumeration() &&
147              (pType instanceof ItemParameterType || pType instanceof FileParameterType))
148            {
149              Item parameterItemType = Item.fromClass(pType.getParameterClass());
150              ItemContext cc = sc.getCurrentContext(parameterItemType, parameterItemType == itemType ? subContext : "");
151              if (cc.getId() != 0 && pType.getMultiplicity() == 1)
152              {
153                values = new java.util.ArrayList();
154                if (pType instanceof FileParameterType)
155                {
156                  try
157                  {
158                    values.add(File.getById(dc, cc.getId()).getPath().toString());
159                  }
160                  catch (Throwable t)
161                  {}
162                  if (currentContext != null && recentFiles == null)
163                  {
164                    recentFiles = (List<File>)currentContext.getRecent(dc, Item.FILE);
165                  }
166                }
167                else
168                {
169                  values.add(cc.getId());
170                }
171              }
172              else if (cc.getSelected().size() > 0 && pType.getMultiplicity() != 1)
173              {
174                values = new java.util.ArrayList(cc.getSelected());
175              }
176            }
177            // Finally, if the parameter has multiplicity=1, is requried and has a list of enumeration values
178            if ((values == null || values.size() == 0) && pType.getNotNull() && 
179              pType.getMultiplicity() == 1 && pType.getItems() != null && pType.getItems().size() > 0)
180            {
181              values = Collections.singletonList(pType.getItems().get(0)); 
182            }
183            String icon = "";
184            if (values != null && values.size() > 0)
185            {
186              icon = pType.getNotNull() ? "required_values.gif" : "notrequired_values.gif";
187            }
188            else
189            {
190              icon = pType.getNotNull() ? "required_novalues.gif" : "notrequired_novalues.gif";
191            }
192            if (!param.isHidden())
193            {
194              icon = "<span class=\"icon\"><img id=\"icon_"+name+"\" src=\"../../images/"+icon+"\"></span>";
195              sb.append("<div class=\"param\" id=\"prompt_"+name+"\" onclick=\"parametersOnClick('"+name+"')\"");
196              sb.append(" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\" title=\""+fullLabel+"\">");
197              sb.append(icon+"<span class=\"label\">"+label+"</span></div>\n");
198            }
199            %>
200            var values = new Array();
201            <%
202            if (values != null && values.size() > 0)
203            {
204              for (Object value : values)
205              {
206                if (value instanceof Date) 
207                {
208                  if (pType.isEnumeration())
209                  {
210                    value = ((Date)value).getTime();
211                  }
212                  else
213                  {
214                    value = dateFormatter.format((Date)value);
215                  }
216                }
217                else if (value instanceof File && pType instanceof FileParameterType)
218                {
219                  File file = File.getById(dc, ((File)value).getId());
220                  value = file.getPath().toString();
221                }
222                else if (value instanceof BasicItem)
223                {
224                  value = ((BasicItem)value).getId();
225                }
226                %>
227                values[values.length] = '<%=HTML.javaScriptEncode(value == null ? "" : value.toString())%>';
228                <%
229              }
230            }
231            %>
232            new Parameter('<%=name%>', '<%=HTML.javaScriptEncode(param.getLabel())%>', <%=pType.getMultiplicity()%>, <%=pType.isEnumeration()%>, <%=pType.getNotNull()%>, values);
233            <%
234          }
235          else
236          {
237            sb.append("<h4 class=\"param\" id=\"prompt_"+name+"\" title=\""+fullLabel+"\" onclick=\"parametersOnClick('"+name+"')\" onmouseover=\"Main.addClass(this, 'hover')\" onmouseout=\"Main.removeClass(this, 'hover')\">"+label+"</h4>");
238            %>
239            new Parameter('<%=name%>', '[<%=HTML.javaScriptEncode(param.getLabel())%>]', 1, 0, 0, {});
240            <%
241          }
242        }
243      }
244      %>
245    }
246   
247    var oldValueDiv;
248    function parametersOnClick(parameterId)
249    {
250      var frm = document.forms['configure'];
251      if (oldValueDiv) Main.hide(oldValueDiv);
252     
253      var pp = Parameters.allParameters['ID'+parameterId];
254      setSelectedParameter(pp, parameterId);
255      oldValueDiv = 'value_'+pp.name+'_div'
256      Main.show(oldValueDiv);
257      var valueElement = frm['value_'+pp.name];
258      if (valueElement.focus && !valueElement.disabled) valueElement.focus();
259      if (pp.enumeration)
260      {
261        Main.hide('valuecontainer');
262        var numSelected;
263        if (valueElement.type && valueElement.type.search('select') != -1)
264        {
265          numSelected = Forms.selectListOptions(valueElement, pp.values);
266        }
267        else if (pp.multiplicity == 1)
268        {
269          // radio buttons
270          numSelected = Forms.checkRadio(valueElement, pp.values[0]) == -1 ? 0 : 1;
271        }
272        else
273        {
274          // check boxes
275          numSelected = Forms.checkCheckBoxes(valueElement, pp.values);
276        }
277        if (numSelected == 0)
278        {
279          pp.values.length = 0;
280          updateSelectedStyle();
281        }
282      }
283      else if (pp.multiplicity == 1)
284      {
285        Main.hide('valuecontainer');
286        var currentValue = pp.values.length > 0 ? pp.values[0] : '';
287        if (valueElement.length) // ie. radio buttons for boolean parameter
288        {
289          Forms.checkRadio(valueElement, currentValue);
290        }
291        else if (!valueElement.disabled)
292        {
293          valueElement.value = currentValue;
294        }
295      }
296      else
297      {
298        var values = frm.values;
299        values.length = 0;
300        for (var i = 0; i < pp.values.length; i++) // >
301        {
302          var value = Main.cutString(pp.values[i].replace(/\n/g, ' '), 40);
303          values[values.length] = new Option(value);
304        }
305        var mult = document.getElementById('multiplicity');
306        mult.innerHTML = pp.multiplicity == 0 ? '' : '(Max '+pp.multiplicity+' values)';
307        Main.show('valuecontainer');
308      }
309    }
310   
311    var selectedPluginParameter = null;
312    var selectedPluginParameterId = null;
313    function getSelectedParameter()
314    {
315      return selectedPluginParameter;
316    }
317   
318    function setSelectedParameter(pluginParameter, parameterId)
319    {
320      if (selectedPluginParameter != null)
321      {
322        Main.removeClass(document.getElementById('prompt_'+selectedPluginParameter.name), 'selected');
323      }
324      selectedPluginParameter = pluginParameter;
325      selectedPluginParameterId = parameterId;
326      if (selectedPluginParameter != null)
327      {
328        Main.addClass(document.getElementById('prompt_'+selectedPluginParameter.name), 'selected');
329      }
330    }
331
332    function updateStyle(pp)
333    {
334      var icon = document.getElementById('icon_'+pp.name);
335      var gif = getRoot()+'images/';
336      if (pp.values.length == 0)
337      {
338        gif += pp.required ? 'required_novalues.gif' : 'notrequired_novalues.gif';
339      }
340      else
341      {
342        gif += pp.required ? 'required_values.gif' : 'notrequired_values.gif';
343      }
344      icon.src = gif;
345    }
346
347    function updateSelectedStyle()
348    {
349      updateStyle(getSelectedParameter());
350    }
351   
352    function setCurrentValue(value)
353    {
354      var pp = getSelectedParameter();
355      if (value == null || value == '')
356      {
357        pp.removeValue(0);
358      }
359      else
360      {
361        pp.updateValue(0, value);
362      }
363      updateSelectedStyle();
364    }
365   
366    function setEnumValues(inputName)
367    {
368      var pp = getSelectedParameter();
369      if (!pp) return;
370   
371      var frm = document.forms['configure'];
372      var valueElement = frm[inputName];
373      var values = new Array();
374      for (var i = 0; i < valueElement.length; i++) // >
375      {
376        if (valueElement[i].checked || valueElement[i].selected)
377        {
378          values[values.length] = valueElement[i].value;
379        }
380      }
381      pp.setValues(values);
382      updateSelectedStyle();
383    }
384
385    var lastValueIndex = -1;
386    function valuesOnClick()
387    {
388      var frm = document.forms['configure'];
389      var pp = getSelectedParameter();
390      lastValueIndex = frm.values.selectedIndex;
391      if (lastValueIndex >= 0)
392      {
393        frm['value_'+pp.name].value = pp.values[lastValueIndex];
394      }
395    }
396
397    function valueOnBlur(value)
398    {
399      var pp = getSelectedParameter();
400      if (!pp) return;
401      if (pp.multiplicity == 1)
402      {
403        setCurrentValue(value);
404      }
405      else
406      {
407        if (lastValueIndex < 0) return; // >
408        var frm = document.forms['configure'];
409        if (value == '' || value == null)
410        {
411          pp.removeValue(lastValueIndex);
412          frm.values[lastValueIndex] = null;
413        }
414        else
415        {
416          pp.updateValue(lastValueIndex, value);
417          frm.values[lastValueIndex].text = value;
418        }
419      }
420    }
421    function addOnClick()
422    {
423      var pp = getSelectedParameter();
424      if (!pp) return;
425      var frm = document.forms['configure'];
426      var valueElement = frm['value_'+pp.name];
427      if (frm.values.selectedIndex < 0 && valueElement.value != '') // >
428      {
429        if (pp.addValue(valueElement.value))
430        {
431          lastValueIndex = frm.values.length;
432          frm.values[lastValueIndex] = new Option(valueElement.value, '', false, false);
433          valueElement.value = '';
434          lastValueIndex = -1;
435        }
436      }
437      else
438      {
439        if (pp.addValue(''))
440        {
441          lastValueIndex = frm.values.length;
442          frm.values[lastValueIndex] = new Option('<new>', '', false, true);
443          valueElement.value = '';
444        }
445      }
446      valueElement.focus();
447      updateSelectedStyle();
448    }
449    function removeOnClick()
450    {
451      var pp = getSelectedParameter();
452      if (!pp) return;
453     
454      var frm = document.forms['configure'];
455      var values = frm.values;
456      for (var i = 0; i < values.length; i++) // >
457      {
458        if (values[i].selected)
459        {
460          pp.removeValue(i);
461          values[i] = null;
462          i--;
463        }
464      }
465      updateSelectedStyle();
466    }
467   
468    function selectAll(inputName)
469    {
470      var frm = document.forms['configure'];
471      var list = frm[inputName];
472      if (list.length == 0) return;
473      var select = !list[0].selected;;
474      for (var i = 0; i < list.length; i++)
475      {
476        list[i].selected = select;
477      }
478      setEnumValues(inputName);
479    }
480   
481    function setDateCallback(frmName, inputName, theDate)
482    {
483      var frm = document.forms[frmName];
484      frm[inputName].value = theDate;
485      valueOnBlur(theDate);
486    }
487    var lastFileInputName;
488    function browseOnClick(inputName)
489    {
490      var frm = document.forms['configure'];
491      var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setFileCallback';
492      lastFileInputName = inputName;
493      Main.openPopup(url, 'SelectFile', 1000, 700);
494    }
495    function setFileCallback(fileId, path)
496    {
497      var frm = document.forms['configure'];
498      frm[lastFileInputName].value = path;
499      valueOnBlur(path);
500    }
501   
502    function recentOnChange(inputName)
503    {
504      var frm = document.forms['configure'];
505      var recentList = frm['recent.'+inputName];
506      var path = recentList[recentList.selectedIndex].text;
507      frm[inputName].value = path;
508      valueOnBlur(path);
509      recentList.selectedIndex = 0;
510    }
511   
512    var lastItemInputName;
513    function selectItemOnClick(inputName, itemType)
514    {
515      lastItemInputName = inputName;
516      Main.selectItem('<%=ID%>', itemType, 'selectone', 'selectItemCallback');
517    }
518    function selectItemCallback(itemId, name)
519    {
520      var frm = document.forms['configure'];
521      frm[lastItemInputName].value = name;
522      setCurrentValue(itemId);
523    }
524    function clearItemOnClick(inputName, itemType)
525    {
526      var frm = document.forms['configure'];
527      frm[inputName].value = '';
528      setCurrentValue();
529    }
530   
531    function saveAsOnClick(inputName)
532    {
533      var frm = document.forms['configure'];
534      var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SaveAs&callback=saveAsCallback';
535      lastFileInputName = inputName;
536      Main.openPopup(url, 'SaveAs', 1000, 700);
537    }
538    function saveAsCallback(path)
539    {
540      var frm = document.forms['configure'];
541      frm[lastFileInputName].value = path;
542      valueOnBlur(path);
543    }
544    function selectDirectoryOnClick(inputName)
545    {
546      var frm = document.forms['configure'];
547      var url = '../../filemanager/directories/index.jsp?ID=<%=ID%>&mode=selectonedirectory&callback=setFileCallback';
548      lastFileInputName = inputName;
549      Main.openPopup(url, 'SelectDirectory', 350, 500);
550    }
551   
552    function hideErrorList()
553    {
554      Main.hide('errorlist');
555      Main.show('showerrorlist');
556    }
557    function showErrorList()
558    {
559      Main.show('errorlist');
560      Main.hide('showerrorlist');
561    }
562   
563    function saveSettings()
564    {
565      var frm = document.forms['configure'];
566      for (var i = 0; i < Parameters.allParameters.length; i++) // > 
567      {
568        var pp = Parameters.allParameters[i];
569        if (pp.required && pp.values.length == 0)
570        {
571          alert('No value entered for parameter '+pp.label);
572          return;
573        }
574      }
575      Parameters.addParameterValuesToForm(frm);
576      //Main.openPopup('', 'SubmitPluginParameters', 100, 100);
577      //frm.target = 'SubmitPluginParameters';
578      frm.submit();
579    }
580   
581    function doCancel()
582    {
583      location = 'index.jsp?ID=<%=ID%>&cmd=CancelWizard';
584    }
585   
586    function testWithFile()
587    {
588      Main.openPopup('test_with_file.jsp?ID=<%=ID%>', 'TestWithFile', 1000, 800);
589    }
590   
591    function getParameterValue(ID)
592    {
593      var param = Parameters.allParameters['ID'+ID];
594      if (param)
595      {
596        return param.values;
597      }
598      else
599      {
600        return '';
601      }
602    }
603   
604    function setParameterValue(ID, value)
605    {
606      var param = Parameters.allParameters['ID'+ID];
607      if (param)
608      {
609        if (value == null || Main.trimString(value) == '')
610        {
611          param.clearValues();
612        }
613        else
614        {
615          var values = new Array();
616          values[values.length] = value;
617          param.setValues(values);
618        }
619        var selected = getSelectedParameter();
620        if (selected && selected.name == param.name)
621        {
622          parametersOnClick(param.name);
623        }
624        updateStyle(param);
625      }
626    }
627    </script>
628  </base:head>
629  <base:body onload="init()">
630    <p>
631    <form action="index.jsp?ID=<%=ID%>" method="post" name="configure" onsubmit="return false;">
632    <input type="hidden" name="cmd" value="SetParameters">
633    <input type="hidden" name="title" value="<%=title%>">
634    <input type="hidden" name="requestId" value="<%=request.getParameter("requestId")%>">
635    <%
636    if (itemType != null)
637    {
638      %>
639      <input type="hidden" name="item_type" value="<%=itemType.name()%>">
640      <%
641    }
642    %>
643    <input type="hidden" name="subcontext" value="<%=subContext%>">
644   
645    <h3 class="docked"><%=title%> <base:help 
646      helpid="<%="runplugin.configure"+(job != null ? "." + plugin.getMainType().name().toLowerCase() : "") %>" /></h3>
647    <div class="boxed">
648   
649      <table class="form">
650      <tr valign="baseline">
651        <td class="prompt">Plugin</td>
652        <td><%=plugin == null ? "<i>- none -</i>" : HTML.encodeTags(plugin.getName())%></td>
653        <td class="prompt">Configuration</td>
654        <td><%=pluginConfig == null ? "<i>- none -</i>" : HTML.encodeTags(pluginConfig.getName())%></td>
655      </tr>
656      </table>
657   
658      <div class="pluginhelp">
659        <%=HTML.niceFormat(ri.getDescription())%>
660      </div>
661
662      <table class="form" cellspacing="0" border="0" cellpadding="0" width="100%">
663      <tr valign="top">
664        <td nowrap style="width: 240px">
665          <div class="parameterlist" style="height: <%=(int)(scale*320)%>px; width:240px;">
666          <%=sb.toString()%>
667          </div>
668          <base:icon image="hasvalues.gif" /> = has value(s), <base:icon image="required.gif" /> = required
669        </td>
670       
671        <td>
672          <%
673          if (errorMessage != null || (errors != null && errors.size() > 0))
674          {
675            %>
676            <div id="errors" style="margin-bottom: 12px;" class="parameterhelp">
677              <div class="error" style="margin: 0px;">
678              <%=errorMessage %>
679              </div>
680              <%
681              if (errors != null && errors.size() > 0)
682              {
683                %>
684                <div id="showerrorlist" style="display: none;">
685                  <base:icon image="bullet.gif" /><a href="javascript:showErrorList()">Show details</a>
686                </div>
687                <div id="errorlist">
688                <ol>
689                <%
690                int i = 0;
691                java.io.PrintWriter pw = new java.io.PrintWriter(out);
692                for (Throwable t : errors)
693                {
694                  ++i;
695                  t.printStackTrace();
696                  StackTraceElement[] st = t.getStackTrace();
697                  %>
698                  <li><%=t.getMessage()%> 
699                    <br>
700                    (<a href="javascript:Main.showHide('stacktrace.<%=i%>')" title="Show/hide stacktrace">+</a>)
701                    <div id="stacktrace.<%=i%>" style="display:none; font-size: smaller;">
702                    <%
703                    out.print("<pre>");
704                    while (t != null)
705                    {
706                      out.println(t.toString());
707                      for (int index = 0; index < st.length; ++index)
708                      {
709                        out.print("...at ");
710                        out.println(st[index].toString());
711                      }
712                      t = t.getCause();
713                      if (t != null) out.print("\nCaused by: ");
714                    }
715                    %>
716                    </pre>
717                    </div>
718                  <%
719                }
720                %>
721                </ol>
722                <base:icon image="bullet.gif" /><a href="javascript:hideErrorList()">Hide details</a>
723                </div>
724                <%
725              }
726              %>
727            </div>
728            <%
729          }
730          %>
731       
732          <div id="valuecontainer" style="display: none;">
733          <table cellspacing="2" border="0" cellpadding="0" cellspacing="0">
734            <tr valign="top">
735            <td>
736              <b>Values</b> <span id="multiplicity"></span><br>
737              <select name="values" size="5" style="width: 20em;"
738                onchange="valuesOnClick()" multiple>
739              </select>
740            </td>
741            <td>&nbsp;</td>
742            <td>
743            <td>
744              <br>
745              <base:button onclick="addOnClick()" title="Add" />
746              <base:button onclick="removeOnClick()" title="Remove" />
747            </td>
748          </table>
749          </div>
750
751          <%
752          if (parameters != null && parameters.size() > 0)
753          {
754            for (PluginParameter<?> param : parameters)
755            {
756              if (!param.isHidden())
757              {
758                ParameterType pType = param.getParameterType();
759                String inputName = "value_"+param.getName();
760                if (pType != null)
761                {
762                  int multiplicity = pType.getMultiplicity();
763                  String select = null;
764                  if (multiplicity == 0)
765                  {
766                    if (pType.getNotNull())
767                    {
768                      select = "Select one or more";
769                    }
770                    else
771                    {
772                      select = "Select zero or more";
773                    }
774                  }
775                  else if (multiplicity == 1)
776                  {
777                    select = "Select one";
778                  }
779                  else
780                  {
781                    if (pType.getNotNull())
782                    {
783                      select = "Select 1 -- " + multiplicity;
784                    }
785                    else
786                    {
787                      select = "Select 0 -- " + multiplicity;
788                    }
789                  }
790                  %>
791                  <div id="<%=inputName%>_div" style="display: none;">
792                  <%
793                  if (pType.isEnumeration())
794                  {
795                    Enumeration<?, String> enumeration = pType.getEnumeration();
796                    List<?> values = pType.getItems();
797                    %>
798                    <b><%=HTML.encodeTags(param.getLabel())%></b> (<%=select%>)
799                    <%
800                    if (multiplicity != 1)
801                    {
802                      %>
803                      <base:icon image="check_uncheck.gif" 
804                        tooltip="Select/deselect all" onclick="<%="selectAll('" + inputName + "')"%>"/>
805                      <%
806                    }
807                    %>
808                    <br>
809                    <%
810                    if (multiplicity == 1)
811                    {
812                      %>
813                      <select name="<%=inputName%>"
814                        onchange="setCurrentValue(this[this.selectedIndex].value)">
815                      <%
816                      if (!pType.getNotNull())
817                      {
818                        %>
819                        <option value="" style="font-style: italic;">- not specified -
820                        <%
821                      }
822                    }
823                    else
824                    {
825                      %>
826                      <select name="<%=inputName%>" multiple size="10" style="width: 30em;"
827                        onchange="setEnumValues('<%=inputName%>')">
828                      <%
829                    }
830                    for (int i = 0; i < values.size(); ++i)
831                    {
832                      Object value;
833                      String listValue = "";
834                      String listText = "";
835                      String listTitle = "";
836                      if (enumeration != null)
837                      {
838                        value = enumeration.getKey(i);
839                        listText = HTML.encodeTags(enumeration.getValue(i));
840                      }
841                      else
842                      {
843                        value = values.get(i);
844                      }
845                      if (value instanceof Date) 
846                      {
847                        listValue = Long.toString(((Date)value).getTime());
848                        if (enumeration == null) listText = dateFormatter.format((Date)value);
849                      }
850                      else if (value instanceof BasicItem)
851                      {
852                        BasicItem item = (BasicItem)value;
853                        listValue = Integer.toString(item.getId());
854                        if (item instanceof Nameable)
855                        {
856                          Nameable nameable = (Nameable)item;
857                          if (enumeration == null) listText = HTML.encodeTags(nameable.getName());
858                          listTitle = HTML.encodeTags(nameable.getDescription());
859                        }
860                        else
861                        {
862                          if (enumeration == null) listText = HTML.encodeTags(item.toString());
863                        }
864                      }
865                      else
866                      {
867                        listValue = HTML.encodeTags(value == null ? "" : value.toString());
868                        if (enumeration == null) listText = listValue;
869                      }
870                      %>
871                      <option value="<%=listValue%>" title="<%=listTitle%>"><%=listText%>
872                      <%
873                    }
874                    %>
875                    </select>
876                    <%
877                  }
878                  else if (pType instanceof StringParameterType)
879                  {
880                    Integer maxLength = ((StringParameterType)pType).getMaxLength();
881                    int width = pType.getWidth() <= 0 ? 40 : pType.getWidth();
882                    if (width > 80) width = 80;
883                    int height = pType.getHeight() <= 0 ? 6 : pType.getHeight();
884                    if (height > 20) height = 20;
885                    if (maxLength == null || maxLength > 255)
886                    {
887                      %>
888                      <b><%=HTML.encodeTags(param.getLabel())%></b> (Text)<br>
889                      <textarea <%=pType.getNotNull() ? requiredClazz : clazz%> 
890                        name="<%=inputName%>" rows="<%=height%>" cols="<%=width%>"
891                        onblur="valueOnBlur(this.value)"></textarea>
892                      <a href="javascript:Main.zoom('<%=HTML.javaScriptEncode(param.getLabel())%>', 'configure', '<%=inputName%>')" 
893                        title="Edit in larger window"><base:icon image="zoom.gif" /></a>
894                      <%
895                    }
896                    else
897                    {
898                      %>
899                      <b><%=HTML.encodeTags(param.getLabel())%></b> (String)<br>
900                      <input <%=pType.getNotNull() ? requiredClazz : clazz%> type="text" 
901                        name="<%=inputName%>" value=""
902                        size="<%=width%>" maxlength="<%=maxLength%>"
903                        onblur="valueOnBlur(this.value)">
904                      <%
905                    }
906                  }
907                  else if (pType instanceof IntegerParameterType)
908                  {
909                    IntegerParameterType ipType = (IntegerParameterType)pType;
910                    Integer minValue = ipType.getLowerLimit();
911                    Integer maxValue = ipType.getUpperLimit();
912                    String minMax = "";
913                    if (minValue != null && maxValue != null)
914                    {
915                      minMax = ": " + minValue + " -- " +maxValue;
916                    }
917                    else if (minValue != null)
918                    {
919                      minMax = " >= "+minValue;
920                    }
921                    else if (maxValue != null)
922                    {
923                      minMax = " <= "+maxValue;
924                    }
925                    %>
926                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Integer<%=minMax%>)<br>
927                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
928                      type="text" name="<%=inputName%>" value=""
929                      size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"
930                      onblur="valueOnBlur(this.value)">
931                    <%
932                  }
933                  else if (pType instanceof LongParameterType)
934                  {
935                    LongParameterType ipType = (LongParameterType)pType;
936                    Long minValue = ipType.getLowerLimit();
937                    Long maxValue = ipType.getUpperLimit();
938                    String minMax = "";
939                    if (minValue != null && maxValue != null)
940                    {
941                      minMax = ": " + minValue + " -- " +maxValue;
942                    }
943                    else if (minValue != null)
944                    {
945                      minMax = " >= "+minValue;
946                    }
947                    else if (maxValue != null)
948                    {
949                      minMax = " <= "+maxValue;
950                    }
951                    %>
952                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Long<%=minMax%>)<br>
953                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
954                      type="text" name="<%=inputName%>" value=""
955                      size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"
956                      onblur="valueOnBlur(this.value)">
957                    <%
958                  }
959                  else if (pType instanceof FloatParameterType)
960                  {
961                    FloatParameterType ipType = (FloatParameterType)pType;
962                    Float minValue = ipType.getLowerLimit();
963                    Float maxValue = ipType.getUpperLimit();
964                    String minMax = "";
965                    if (minValue != null && maxValue != null)
966                    {
967                      minMax = ": " + minValue + " -- " +maxValue;
968                    }
969                    else if (minValue != null)
970                    {
971                      minMax = " >= "+minValue;
972                    }
973                    else if (maxValue != null)
974                    {
975                      minMax = " <= "+maxValue;
976                    }
977                    %>
978                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Float<%=minMax%>)<br>
979                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
980                      type="text" name="<%=inputName%>" value=""
981                      size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"
982                      onblur="valueOnBlur(this.value)">
983                    <%
984                  }
985                  else if (pType instanceof DoubleParameterType)
986                  {
987                    DoubleParameterType ipType = (DoubleParameterType)pType;
988                    Double minValue = ipType.getLowerLimit();
989                    Double maxValue = ipType.getUpperLimit();
990                    String minMax = "";
991                    if (minValue != null && maxValue != null)
992                    {
993                      minMax = ": " + minValue + " -- " +maxValue;
994                    }
995                    else if (minValue != null)
996                    {
997                      minMax = " >= "+minValue;
998                    }
999                    else if (maxValue != null)
1000                    {
1001                      minMax = " <= "+maxValue;
1002                    }
1003                    %>
1004                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Double<%=minMax%>)<br>
1005                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
1006                      type="text" name="<%=inputName%>" value=""
1007                      size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"
1008                      onblur="valueOnBlur(this.value)">
1009                    <%
1010                  }
1011                  else if (pType instanceof DateParameterType)
1012                  {
1013                    %>
1014                    <table>
1015                    <tr>
1016                    <td>
1017                      <b><%=HTML.encodeTags(param.getLabel())%></b> (Date)<br>
1018                      <input <%=pType.getNotNull() ? requiredClazz : clazz%>
1019                        type="text" name="<%=inputName%>" value=""
1020                        size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"
1021                        onblur="valueOnBlur(this.value)">
1022                    </td>
1023                    <td>
1024                      <br>
1025                      <base:button 
1026                        onclick="<%="Dates.selectDate('Value', 'configure', '"+inputName+"', 'setDateCallback', '"+jsDateFormat+"')"%>" 
1027                        image="calendar.png"
1028                        title="Calendar&hellip;" 
1029                        tooltip="Select a date from a calendar" 
1030                      />
1031                    </td>
1032                    </tr>
1033                    </table>
1034                    <%
1035                  }
1036                  else if (pType instanceof BooleanParameterType)
1037                  {
1038                    %>
1039                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1040                    <input type="radio" name="<%=inputName%>" value="" checked
1041                      onclick="setCurrentValue(null)"><a
1042                      href="javascript:document.forms['configure'].<%=inputName%>[0].click()"><i>- not specified -</i></a><br>
1043                    <input type="radio" name="<%=inputName%>" value="true" 
1044                      onclick="setCurrentValue('true')"><a
1045                      href="javascript:document.forms['configure'].<%=inputName%>[1].click()">true</a><br>
1046                    <input type="radio" name="<%=inputName%>" value="false" 
1047                      onclick="setCurrentValue('false')"><a
1048                      href="javascript:document.forms['configure'].<%=inputName%>[2].click()">false</a>
1049                    <%
1050                  }
1051                  else if (pType instanceof FileParameterType)
1052                  {
1053                    %>
1054                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1055                    <table border="0" cellspacing="0" cellpadding="0">
1056                    <tr>
1057                    <td><input <%=pType.getNotNull() ? requiredClazz : clazz%> type="text" 
1058                      name="<%=inputName%>" value=""
1059                      size="50"
1060                      onblur="valueOnBlur(this.value)">&nbsp;</td>
1061                    <td><base:button 
1062                        title="Browse&hellip;"
1063                        onclick="<%="browseOnClick('"+inputName+"')"%>"
1064                        />
1065                    </td>
1066                    </tr>
1067                    </table>
1068                    <%
1069                    if (recentFiles != null && recentFiles.size() > 0)
1070                    {
1071                      %>
1072                      <b>Recently used</b><br>
1073                      <select name="recent.<%=inputName%>" onchange="recentOnChange('<%=inputName%>')">
1074                      <option value="">
1075                      <%
1076                      for (File recent : recentFiles)
1077                      {
1078                        %>
1079                        <option value="<%=recent.getId()%>"><%=HTML.encodeTags(recent.getPath().toString())%>
1080                        <%
1081                      }
1082                      %>
1083                      </select>
1084                      <%
1085                    }
1086                  }
1087                  else if (pType instanceof ItemParameterType)
1088                  {
1089                    Item parameterItemType = Item.fromClass(pType.getParameterClass());
1090                    BasicItem item = (BasicItem)pcRequest.getCurrentParameterValue(param.getName());
1091                    if (item == null)
1092                    {
1093                      ItemContext cc = sc.getCurrentContext(parameterItemType, parameterItemType == itemType ? subContext : "");
1094                      if (cc.getId() != 0)
1095                      {
1096                        try
1097                        {
1098                          item = parameterItemType.getById(dc, cc.getId());
1099                        }
1100                        catch (Throwable t)
1101                        {}
1102                      }
1103                    }
1104                    if (item != null)
1105                    {
1106                      String display = "";
1107                      if (item instanceof Nameable)
1108                      {
1109                        Nameable nameable = (Nameable)item;
1110                        display = nameable.getName();
1111                      }
1112                      else 
1113                      {
1114                        display = item.toString();
1115                      }
1116                      %>
1117                      <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1118                      <table border="0" cellspacing="2" cellpadding="0">
1119                      <tr>
1120                      <td><input class="text disabled" size="50" 
1121                        name="<%=inputName%>" type="text" disabled
1122                        value="<%=HTML.encodeTags(display)%>"></td>
1123                      <td><base:button title="Select&hellip;"
1124                          onclick="<%="selectItemOnClick('"+inputName+"', '" + parameterItemType.name() + "')"%>"
1125                          visible="false" /></td>
1126                      <td><base:button title="Clear"
1127                          onclick="<%="clearItemOnClick('"+inputName+"', '" + parameterItemType.name() + "')"%>"
1128                          visible="false" /></td>
1129                      </tr>
1130                      </table>
1131                      <%
1132                    }
1133                  }
1134                  else if (pType instanceof PathParameterType)
1135                  {
1136                    PathParameterType ppType = (PathParameterType)pType;
1137                    String browse = "";
1138                    if (ppType.getPathType() == Path.Type.FILE)
1139                    {
1140                      browse = "saveAsOnClick('" + inputName + "')";
1141                    }
1142                    else
1143                    {
1144                      browse = "selectDirectoryOnClick('" + inputName + "')";
1145                    }
1146                    %>
1147                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1148                    <table border="0" cellspacing="0" cellpadding="0">
1149                    <tr>
1150                    <td>
1151                      <input type="text" class="text" name="<%=inputName%>" size="40" value=""
1152                        onblur="valueOnBlur(this.value)">&nbsp;</td>
1153                    <td><base:button 
1154                        title="Browse&hellip;"
1155                        onclick="<%=browse%>"
1156                        />
1157                    </td>
1158                    </tr>
1159                    </table>
1160                    <%
1161                  }
1162                  else
1163                  {
1164                    %>
1165                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1166                    <%
1167                  }
1168                  %>
1169                  <br>
1170                  <div class="parameterhelp">
1171                  <%=HTML.niceFormat(param.getDescription())%>
1172                  </div>
1173                  </div>
1174                  <%
1175                }
1176                else
1177                {
1178                  %>
1179                  <div id="<%=inputName%>_div" style="display: none;" class="parameterhelp">
1180                  <%=HTML.niceFormat(param.getDescription())%>
1181                  </div>
1182                  <%
1183                }
1184              }
1185            }
1186          }
1187          %>
1188        </td>
1189      </tr>
1190      </table>
1191      </div>
1192    </form>
1193    <div align="center">
1194    <base:buttongroup>
1195      <base:button onclick="testWithFile()" title="Test with file&hellip;" image="file.gif"
1196        tooltip="Use an uploaded file to create the regular expressions and column mappings"
1197        visible="<%=configureByExample%>" />
1198      <base:button onclick="saveSettings()" title="Next" />
1199      <base:button onclick="doCancel()" title="Cancel" />
1200    </base:buttongroup>
1201    </div>
1202  </base:body>
1203  </base:page>
1204  <%
1205}
1206finally
1207{
1208  if (dc != null) dc.close();
1209}
1210%>
Note: See TracBrowser for help on using the repository browser.