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

Last change on this file since 3852 was 3852, checked in by Nicklas Nordborg, 15 years ago

References #721: Auto-detect function is now aware of FileStoreEnabled? items and automatically
selects a default file for import.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 37.1 KB
Line 
1<%-- $Id: configure.jsp 3852 2007-10-17 07:58:57Z 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(name)
367    {
368      var pp = getSelectedParameter();
369      if (!pp) return;
370   
371      var frm = document.forms['configure'];
372      var valueElement = frm[name];
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    function setDateCallback(frmName, inputName, theDate)
468    {
469      var frm = document.forms[frmName];
470      frm[inputName].value = theDate;
471      valueOnBlur(theDate);
472    }
473    var lastFileInputName;
474    function browseOnClick(inputName)
475    {
476      var frm = document.forms['configure'];
477      var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setFileCallback';
478      lastFileInputName = inputName;
479      Main.openPopup(url, 'SelectFile', 1000, 700);
480    }
481    function setFileCallback(fileId, path)
482    {
483      var frm = document.forms['configure'];
484      frm[lastFileInputName].value = path;
485      valueOnBlur(path);
486    }
487   
488    function recentOnChange(inputName)
489    {
490      var frm = document.forms['configure'];
491      var recentList = frm['recent.'+inputName];
492      var path = recentList[recentList.selectedIndex].text;
493      frm[inputName].value = path;
494      valueOnBlur(path);
495      recentList.selectedIndex = 0;
496    }
497   
498    var lastItemInputName;
499    function selectItemOnClick(inputName, itemType)
500    {
501      lastItemInputName = inputName;
502      Main.selectItem('<%=ID%>', itemType, 'selectone', 'selectItemCallback');
503    }
504    function selectItemCallback(itemId, name)
505    {
506      var frm = document.forms['configure'];
507      frm[lastItemInputName].value = name;
508      setCurrentValue(itemId);
509    }
510    function clearItemOnClick(inputName, itemType)
511    {
512      var frm = document.forms['configure'];
513      frm[inputName].value = '';
514      setCurrentValue();
515    }
516   
517    function saveAsOnClick(inputName)
518    {
519      var frm = document.forms['configure'];
520      var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SaveAs&callback=saveAsCallback';
521      lastFileInputName = inputName;
522      Main.openPopup(url, 'SaveAs', 1000, 700);
523    }
524    function saveAsCallback(path)
525    {
526      var frm = document.forms['configure'];
527      frm[lastFileInputName].value = path;
528      valueOnBlur(path);
529    }
530    function selectDirectoryOnClick(inputName)
531    {
532      var frm = document.forms['configure'];
533      var url = '../../filemanager/directories/index.jsp?ID=<%=ID%>&mode=selectonedirectory&callback=setFileCallback';
534      lastFileInputName = inputName;
535      Main.openPopup(url, 'SelectDirectory', 350, 500);
536    }
537   
538    function hideErrorList()
539    {
540      Main.hide('errorlist');
541      Main.show('showerrorlist');
542    }
543    function showErrorList()
544    {
545      Main.show('errorlist');
546      Main.hide('showerrorlist');
547    }
548   
549    function saveSettings()
550    {
551      var frm = document.forms['configure'];
552      for (var i = 0; i < Parameters.allParameters.length; i++) // > 
553      {
554        var pp = Parameters.allParameters[i];
555        if (pp.required && pp.values.length == 0)
556        {
557          alert('No value entered for parameter '+pp.label);
558          return;
559        }
560      }
561      Parameters.addParameterValuesToForm(frm);
562      //Main.openPopup('', 'SubmitPluginParameters', 100, 100);
563      //frm.target = 'SubmitPluginParameters';
564      frm.submit();
565    }
566   
567    function doCancel()
568    {
569      location = 'index.jsp?ID=<%=ID%>&cmd=CancelWizard';
570    }
571   
572    function testWithFile()
573    {
574      Main.openPopup('test_with_file.jsp?ID=<%=ID%>', 'TestWithFile', 1000, 800);
575    }
576   
577    function getParameterValue(ID)
578    {
579      var param = Parameters.allParameters['ID'+ID];
580      if (param)
581      {
582        return param.values;
583      }
584      else
585      {
586        return '';
587      }
588    }
589   
590    function setParameterValue(ID, value)
591    {
592      var param = Parameters.allParameters['ID'+ID];
593      if (param)
594      {
595        if (value == null || Main.trimString(value) == '')
596        {
597          param.clearValues();
598        }
599        else
600        {
601          var values = new Array();
602          values[values.length] = value;
603          param.setValues(values);
604        }
605        var selected = getSelectedParameter();
606        if (selected && selected.name == param.name)
607        {
608          parametersOnClick(param.name);
609        }
610        updateStyle(param);
611      }
612    }
613    </script>
614  </base:head>
615  <base:body onload="init()">
616    <p>
617    <form action="index.jsp?ID=<%=ID%>" method="post" name="configure" onsubmit="return false;">
618    <input type="hidden" name="cmd" value="SetParameters">
619    <input type="hidden" name="title" value="<%=title%>">
620    <input type="hidden" name="requestId" value="<%=request.getParameter("requestId")%>">
621    <%
622    if (itemType != null)
623    {
624      %>
625      <input type="hidden" name="item_type" value="<%=itemType.name()%>">
626      <%
627    }
628    %>
629    <input type="hidden" name="subcontext" value="<%=subContext%>">
630   
631    <h3 class="docked"><%=title%> <base:help 
632      helpid="<%="runplugin.configure"+(job != null ? "." + plugin.getMainType().name().toLowerCase() : "") %>" /></h3>
633    <div class="boxed">
634   
635      <table class="form">
636      <tr valign="baseline">
637        <td class="prompt">Plugin</td>
638        <td><%=plugin == null ? "<i>- none -</i>" : HTML.encodeTags(plugin.getName())%></td>
639        <td class="prompt">Configuration</td>
640        <td><%=pluginConfig == null ? "<i>- none -</i>" : HTML.encodeTags(pluginConfig.getName())%></td>
641      </tr>
642      </table>
643   
644      <div class="pluginhelp">
645        <%=HTML.niceFormat(ri.getDescription())%>
646      </div>
647
648      <table class="form" cellspacing="0" border="0" cellpadding="0" width="100%">
649      <tr valign="top">
650        <td nowrap style="width: 240px">
651          <div class="parameterlist" style="height: <%=(int)(scale*320)%>px; width:240px;">
652          <%=sb.toString()%>
653          </div>
654          <base:icon image="hasvalues.gif" /> = has value(s), <base:icon image="required.gif" /> = required
655        </td>
656       
657        <td>
658          <%
659          if (errorMessage != null || (errors != null && errors.size() > 0))
660          {
661            %>
662            <div id="errors" style="margin-bottom: 12px;" class="parameterhelp">
663              <div class="error" style="margin: 0px;">
664              <%=errorMessage %>
665              </div>
666              <%
667              if (errors != null && errors.size() > 0)
668              {
669                %>
670                <div id="showerrorlist" style="display: none;">
671                  <base:icon image="bullet.gif" /><a href="javascript:showErrorList()">Show details</a>
672                </div>
673                <div id="errorlist">
674                <ol>
675                <%
676                int i = 0;
677                java.io.PrintWriter pw = new java.io.PrintWriter(out);
678                for (Throwable t : errors)
679                {
680                  ++i;
681                  t.printStackTrace();
682                  StackTraceElement[] st = t.getStackTrace();
683                  %>
684                  <li><%=t.getMessage()%> 
685                    <br>
686                    (<a href="javascript:Main.showHide('stacktrace.<%=i%>')" title="Show/hide stacktrace">+</a>)
687                    <div id="stacktrace.<%=i%>" style="display:none; font-size: smaller;">
688                    <%
689                    out.print("<pre>");
690                    while (t != null)
691                    {
692                      out.println(t.toString());
693                      for (int index = 0; index < st.length; ++index)
694                      {
695                        out.print("...at ");
696                        out.println(st[index].toString());
697                      }
698                      t = t.getCause();
699                      if (t != null) out.print("\nCaused by: ");
700                    }
701                    %>
702                    </pre>
703                    </div>
704                  <%
705                }
706                %>
707                </ol>
708                <base:icon image="bullet.gif" /><a href="javascript:hideErrorList()">Hide details</a>
709                </div>
710                <%
711              }
712              %>
713            </div>
714            <%
715          }
716          %>
717       
718          <div id="valuecontainer" style="display: none;">
719          <table cellspacing="2" border="0" cellpadding="0" cellspacing="0">
720            <tr valign="top">
721            <td>
722              <b>Values</b> <span id="multiplicity"></span><br>
723              <select name="values" size="5" style="width: 20em;"
724                onchange="valuesOnClick()" multiple>
725              </select>
726            </td>
727            <td>&nbsp;</td>
728            <td>
729            <td>
730              <br>
731              <base:button onclick="addOnClick()" title="Add" />
732              <base:button onclick="removeOnClick()" title="Remove" />
733            </td>
734          </table>
735          </div>
736
737          <%
738          if (parameters != null && parameters.size() > 0)
739          {
740            for (PluginParameter<?> param : parameters)
741            {
742              if (!param.isHidden())
743              {
744                ParameterType pType = param.getParameterType();
745                String inputName = "value_"+param.getName();
746                if (pType != null)
747                {
748                  int multiplicity = pType.getMultiplicity();
749                  String select = null;
750                  if (multiplicity == 0)
751                  {
752                    if (pType.getNotNull())
753                    {
754                      select = "Select one or more";
755                    }
756                    else
757                    {
758                      select = "Select zero or more";
759                    }
760                  }
761                  else if (multiplicity == 1)
762                  {
763                    select = "Select one";
764                  }
765                  else
766                  {
767                    if (pType.getNotNull())
768                    {
769                      select = "Select 1 -- " + multiplicity;
770                    }
771                    else
772                    {
773                      select = "Select 0 -- " + multiplicity;
774                    }
775                  }
776                  %>
777                  <div id="<%=inputName%>_div" style="display: none;">
778                  <%
779                  if (pType.isEnumeration())
780                  {
781                    Enumeration<?, String> enumeration = pType.getEnumeration();
782                    List<?> values = pType.getItems();
783                    %>
784                    <b><%=HTML.encodeTags(param.getLabel())%></b> (<%=select%>)<br>
785                    <%
786                    if (multiplicity == 1)
787                    {
788                      %>
789                      <select name="<%=inputName%>"
790                        onchange="setCurrentValue(this[this.selectedIndex].value)">
791                      <%
792                      if (!pType.getNotNull())
793                      {
794                        %>
795                        <option value="" style="font-style: italic;">- not specified -
796                        <%
797                      }
798                    }
799                    else
800                    {
801                      %>
802                      <select name="<%=inputName%>" multiple size="10" style="width: 30em;"
803                        onchange="setEnumValues('<%=inputName%>')">
804                      <%
805                    }
806                    for (int i = 0; i < values.size(); ++i)
807                    {
808                      Object value;
809                      String listValue = "";
810                      String listText = "";
811                      String listTitle = "";
812                      if (enumeration != null)
813                      {
814                        value = enumeration.getKey(i);
815                        listText = HTML.encodeTags(enumeration.getValue(i));
816                      }
817                      else
818                      {
819                        value = values.get(i);
820                      }
821                      if (value instanceof Date) 
822                      {
823                        listValue = Long.toString(((Date)value).getTime());
824                        if (enumeration == null) listText = dateFormatter.format((Date)value);
825                      }
826                      else if (value instanceof BasicItem)
827                      {
828                        BasicItem item = (BasicItem)value;
829                        listValue = Integer.toString(item.getId());
830                        if (item instanceof Nameable)
831                        {
832                          Nameable nameable = (Nameable)item;
833                          if (enumeration == null) listText = HTML.encodeTags(nameable.getName());
834                          listTitle = HTML.encodeTags(nameable.getDescription());
835                        }
836                        else
837                        {
838                          if (enumeration == null) listText = HTML.encodeTags(item.toString());
839                        }
840                      }
841                      else
842                      {
843                        listValue = HTML.encodeTags(value == null ? "" : value.toString());
844                        if (enumeration == null) listText = listValue;
845                      }
846                      %>
847                      <option value="<%=listValue%>" title="<%=listTitle%>"><%=listText%>
848                      <%
849                    }
850                    %>
851                    </select>
852                    <%
853                  }
854                  else if (pType instanceof StringParameterType)
855                  {
856                    Integer maxLength = ((StringParameterType)pType).getMaxLength();
857                    int width = pType.getWidth() <= 0 ? 40 : pType.getWidth();
858                    if (width > 80) width = 80;
859                    int height = pType.getHeight() <= 0 ? 6 : pType.getHeight();
860                    if (height > 20) height = 20;
861                    if (maxLength == null || maxLength > 255)
862                    {
863                      %>
864                      <b><%=HTML.encodeTags(param.getLabel())%></b> (Text)<br>
865                      <textarea <%=pType.getNotNull() ? requiredClazz : clazz%> 
866                        name="<%=inputName%>" rows="<%=height%>" cols="<%=width%>"
867                        onblur="valueOnBlur(this.value)"></textarea>
868                      <a href="javascript:Main.zoom('<%=HTML.javaScriptEncode(param.getLabel())%>', 'configure', '<%=inputName%>')" 
869                        title="Edit in larger window"><base:icon image="zoom.gif" /></a>
870                      <%
871                    }
872                    else
873                    {
874                      %>
875                      <b><%=HTML.encodeTags(param.getLabel())%></b> (String)<br>
876                      <input <%=pType.getNotNull() ? requiredClazz : clazz%> type="text" 
877                        name="<%=inputName%>" value=""
878                        size="<%=width%>" maxlength="<%=maxLength%>"
879                        onblur="valueOnBlur(this.value)">
880                      <%
881                    }
882                  }
883                  else if (pType instanceof IntegerParameterType)
884                  {
885                    IntegerParameterType ipType = (IntegerParameterType)pType;
886                    Integer minValue = ipType.getLowerLimit();
887                    Integer maxValue = ipType.getUpperLimit();
888                    String minMax = "";
889                    if (minValue != null && maxValue != null)
890                    {
891                      minMax = ": " + minValue + " -- " +maxValue;
892                    }
893                    else if (minValue != null)
894                    {
895                      minMax = " >= "+minValue;
896                    }
897                    else if (maxValue != null)
898                    {
899                      minMax = " <= "+maxValue;
900                    }
901                    %>
902                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Integer<%=minMax%>)<br>
903                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
904                      type="text" name="<%=inputName%>" value=""
905                      size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"
906                      onblur="valueOnBlur(this.value)">
907                    <%
908                  }
909                  else if (pType instanceof LongParameterType)
910                  {
911                    LongParameterType ipType = (LongParameterType)pType;
912                    Long minValue = ipType.getLowerLimit();
913                    Long maxValue = ipType.getUpperLimit();
914                    String minMax = "";
915                    if (minValue != null && maxValue != null)
916                    {
917                      minMax = ": " + minValue + " -- " +maxValue;
918                    }
919                    else if (minValue != null)
920                    {
921                      minMax = " >= "+minValue;
922                    }
923                    else if (maxValue != null)
924                    {
925                      minMax = " <= "+maxValue;
926                    }
927                    %>
928                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Long<%=minMax%>)<br>
929                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
930                      type="text" name="<%=inputName%>" value=""
931                      size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"
932                      onblur="valueOnBlur(this.value)">
933                    <%
934                  }
935                  else if (pType instanceof FloatParameterType)
936                  {
937                    FloatParameterType ipType = (FloatParameterType)pType;
938                    Float minValue = ipType.getLowerLimit();
939                    Float maxValue = ipType.getUpperLimit();
940                    String minMax = "";
941                    if (minValue != null && maxValue != null)
942                    {
943                      minMax = ": " + minValue + " -- " +maxValue;
944                    }
945                    else if (minValue != null)
946                    {
947                      minMax = " >= "+minValue;
948                    }
949                    else if (maxValue != null)
950                    {
951                      minMax = " <= "+maxValue;
952                    }
953                    %>
954                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Float<%=minMax%>)<br>
955                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
956                      type="text" name="<%=inputName%>" value=""
957                      size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"
958                      onblur="valueOnBlur(this.value)">
959                    <%
960                  }
961                  else if (pType instanceof DoubleParameterType)
962                  {
963                    DoubleParameterType ipType = (DoubleParameterType)pType;
964                    Double minValue = ipType.getLowerLimit();
965                    Double maxValue = ipType.getUpperLimit();
966                    String minMax = "";
967                    if (minValue != null && maxValue != null)
968                    {
969                      minMax = ": " + minValue + " -- " +maxValue;
970                    }
971                    else if (minValue != null)
972                    {
973                      minMax = " >= "+minValue;
974                    }
975                    else if (maxValue != null)
976                    {
977                      minMax = " <= "+maxValue;
978                    }
979                    %>
980                    <b><%=HTML.encodeTags(param.getLabel())%></b> (Double<%=minMax%>)<br>
981                    <input <%=pType.getNotNull() ? requiredClazz : clazz%>
982                      type="text" name="<%=inputName%>" value=""
983                      size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"
984                      onblur="valueOnBlur(this.value)">
985                    <%
986                  }
987                  else if (pType instanceof DateParameterType)
988                  {
989                    %>
990                    <table>
991                    <tr>
992                    <td>
993                      <b><%=HTML.encodeTags(param.getLabel())%></b> (Date)<br>
994                      <input <%=pType.getNotNull() ? requiredClazz : clazz%>
995                        type="text" name="<%=inputName%>" value=""
996                        size="20" maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"
997                        onblur="valueOnBlur(this.value)">
998                    </td>
999                    <td>
1000                      <br>
1001                      <base:button 
1002                        onclick="<%="Dates.selectDate('Value', 'configure', '"+inputName+"', 'setDateCallback', '"+jsDateFormat+"')"%>" 
1003                        image="calendar.png"
1004                        title="Calendar&hellip;" 
1005                        tooltip="Select a date from a calendar" 
1006                      />
1007                    </td>
1008                    </tr>
1009                    </table>
1010                    <%
1011                  }
1012                  else if (pType instanceof BooleanParameterType)
1013                  {
1014                    %>
1015                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1016                    <input type="radio" name="<%=inputName%>" value="" checked
1017                      onclick="setCurrentValue(null)"><a
1018                      href="javascript:document.forms['configure'].<%=inputName%>[0].click()"><i>- not specified -</i></a><br>
1019                    <input type="radio" name="<%=inputName%>" value="true" 
1020                      onclick="setCurrentValue('true')"><a
1021                      href="javascript:document.forms['configure'].<%=inputName%>[1].click()">true</a><br>
1022                    <input type="radio" name="<%=inputName%>" value="false" 
1023                      onclick="setCurrentValue('false')"><a
1024                      href="javascript:document.forms['configure'].<%=inputName%>[2].click()">false</a>
1025                    <%
1026                  }
1027                  else if (pType instanceof FileParameterType)
1028                  {
1029                    %>
1030                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1031                    <table border="0" cellspacing="0" cellpadding="0">
1032                    <tr>
1033                    <td><input <%=pType.getNotNull() ? requiredClazz : clazz%> type="text" 
1034                      name="<%=inputName%>" value=""
1035                      size="50"
1036                      onblur="valueOnBlur(this.value)">&nbsp;</td>
1037                    <td><base:button 
1038                        title="Browse&hellip;"
1039                        onclick="<%="browseOnClick('"+inputName+"')"%>"
1040                        />
1041                    </td>
1042                    </tr>
1043                    </table>
1044                    <%
1045                    if (recentFiles != null && recentFiles.size() > 0)
1046                    {
1047                      %>
1048                      <b>Recently used</b><br>
1049                      <select name="recent.<%=inputName%>" onchange="recentOnChange('<%=inputName%>')">
1050                      <option value="">
1051                      <%
1052                      for (File recent : recentFiles)
1053                      {
1054                        %>
1055                        <option value="<%=recent.getId()%>"><%=HTML.encodeTags(recent.getPath().toString())%>
1056                        <%
1057                      }
1058                      %>
1059                      </select>
1060                      <%
1061                    }
1062                  }
1063                  else if (pType instanceof ItemParameterType)
1064                  {
1065                    Item parameterItemType = Item.fromClass(pType.getParameterClass());
1066                    BasicItem item = (BasicItem)pcRequest.getCurrentParameterValue(param.getName());
1067                    if (item == null)
1068                    {
1069                      ItemContext cc = sc.getCurrentContext(parameterItemType, parameterItemType == itemType ? subContext : "");
1070                      if (cc.getId() != 0)
1071                      {
1072                        try
1073                        {
1074                          item = parameterItemType.getById(dc, cc.getId());
1075                        }
1076                        catch (Throwable t)
1077                        {}
1078                      }
1079                    }
1080                    if (item != null)
1081                    {
1082                      String display = "";
1083                      if (item instanceof Nameable)
1084                      {
1085                        Nameable nameable = (Nameable)item;
1086                        display = nameable.getName();
1087                      }
1088                      else 
1089                      {
1090                        display = item.toString();
1091                      }
1092                      %>
1093                      <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1094                      <table border="0" cellspacing="2" cellpadding="0">
1095                      <tr>
1096                      <td><input class="text disabled" size="50" 
1097                        name="<%=inputName%>" type="text" disabled
1098                        value="<%=HTML.encodeTags(display)%>"></td>
1099                      <td><base:button title="Select&hellip;"
1100                          onclick="<%="selectItemOnClick('"+inputName+"', '" + parameterItemType.name() + "')"%>"
1101                          visible="false" /></td>
1102                      <td><base:button title="Clear"
1103                          onclick="<%="clearItemOnClick('"+inputName+"', '" + parameterItemType.name() + "')"%>"
1104                          visible="false" /></td>
1105                      </tr>
1106                      </table>
1107                      <%
1108                    }
1109                  }
1110                  else if (pType instanceof PathParameterType)
1111                  {
1112                    PathParameterType ppType = (PathParameterType)pType;
1113                    String browse = "";
1114                    if (ppType.getPathType() == Path.Type.FILE)
1115                    {
1116                      browse = "saveAsOnClick('" + inputName + "')";
1117                    }
1118                    else
1119                    {
1120                      browse = "selectDirectoryOnClick('" + inputName + "')";
1121                    }
1122                    %>
1123                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1124                    <table border="0" cellspacing="0" cellpadding="0">
1125                    <tr>
1126                    <td>
1127                      <input type="text" class="text" name="<%=inputName%>" size="40" value=""
1128                        onblur="valueOnBlur(this.value)">&nbsp;</td>
1129                    <td><base:button 
1130                        title="Browse&hellip;"
1131                        onclick="<%=browse%>"
1132                        />
1133                    </td>
1134                    </tr>
1135                    </table>
1136                    <%
1137                  }
1138                  else
1139                  {
1140                    %>
1141                    <b><%=HTML.encodeTags(param.getLabel())%></b><br>
1142                    <%
1143                  }
1144                  %>
1145                  <br>
1146                  <div class="parameterhelp">
1147                  <%=HTML.niceFormat(param.getDescription())%>
1148                  </div>
1149                  </div>
1150                  <%
1151                }
1152                else
1153                {
1154                  %>
1155                  <div id="<%=inputName%>_div" style="display: none;" class="parameterhelp">
1156                  <%=HTML.niceFormat(param.getDescription())%>
1157                  </div>
1158                  <%
1159                }
1160              }
1161            }
1162          }
1163          %>
1164        </td>
1165      </tr>
1166      </table>
1167      </div>
1168    </form>
1169    <div align="center">
1170    <base:buttongroup>
1171      <base:button onclick="testWithFile()" title="Test with file&hellip;" image="file.gif"
1172        tooltip="Use an uploaded file to create the regular expressions and column mappings"
1173        visible="<%=configureByExample%>" />
1174      <base:button onclick="saveSettings()" title="Next" />
1175      <base:button onclick="doCancel()" title="Cancel" />
1176    </base:buttongroup>
1177    </div>
1178  </base:body>
1179  </base:page>
1180  <%
1181}
1182finally
1183{
1184  if (dc != null) dc.close();
1185}
1186%>
Note: See TracBrowser for help on using the repository browser.