source: trunk/www/admin/annotationtypes/edit_annotationtype.jsp @ 5425

Last change on this file since 5425 was 5425, checked in by Nicklas Nordborg, 13 years ago

References #1514: Fix character encoding of jsp files

I hope this fixes most of the issues, including the reporter list filtering in many places. Let's keep an eye open for more issues until it is time to release 2.16

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 32.3 KB
Line 
1<%-- $Id: edit_annotationtype.jsp 5425 2010-09-23 13:30:07Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.Type"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Include"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.AnnotationType"
36  import="net.sf.basedb.core.AnnotationTypeCategory"
37  import="net.sf.basedb.core.Quantity"
38  import="net.sf.basedb.core.Unit"
39  import="net.sf.basedb.core.SystemItems"
40  import="net.sf.basedb.core.Metadata"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.ItemResultList"
43  import="net.sf.basedb.core.PermissionDeniedException"
44  import="net.sf.basedb.core.query.Orders"
45  import="net.sf.basedb.core.query.Hql"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.Values"
49  import="net.sf.basedb.util.formatter.Formatter"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="net.sf.basedb.clients.web.formatter.FormatterSettings"
52  import="java.util.Date"
53  import="java.util.Set"
54  import="java.util.List"
55%>
56<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
57<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
58<%
59final Item itemType = Item.ANNOTATIONTYPE;
60final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
61final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
62final int itemId = cc.getId();
63final String ID = sc.getId();
64final float scale = Base.getScale(sc);
65final DbControl dc = sc.newDbControl();
66try
67{
68  String title = null;
69  AnnotationType annotationType = null;
70  ItemQuery<AnnotationTypeCategory> categoryQuery = null;
71  ItemQuery<Unit> unitQuery = null;
72  Type valueType = null;
73  boolean readCurrentQuantity = true;
74  int currentQuantityId = 0;
75  boolean readCurrentUnit = true;
76  int currentUnitId = 0;
77
78  if (itemId == 0)
79  {
80    title = "Create annotation type";
81    valueType = Type.valueOf(request.getParameter("value_type"));
82    if (valueType.isNumerical()) unitQuery = Unit.getQuery(); 
83    cc.removeObject("item");
84  }
85  else
86  {
87    annotationType = AnnotationType.getById(dc, itemId);
88    annotationType.checkPermission(Permission.WRITE);
89    valueType = annotationType.getValueType();
90    cc.setObject("item", annotationType);
91    title = "Edit annotation type -- " + HTML.encodeTags(annotationType.getName());
92    categoryQuery = annotationType.getCategories();
93    categoryQuery.include(Include.ALL);
94    categoryQuery.order(Orders.asc(Hql.property("name")));
95    try
96    {
97      if (annotationType.getValueType().isNumerical())
98      {
99        Quantity quantity = annotationType.getQuantity();
100        if (quantity != null) 
101        {
102          currentQuantityId = quantity.getId();
103          unitQuery = quantity.getUnits();
104        }
105        else
106        {
107          unitQuery = Unit.getQuery();
108        }
109        Unit unit = annotationType.getDefaultUnit();
110        if (unit != null) currentUnitId = unit.getId();
111      }
112    }
113    catch (PermissionDeniedException ex)
114    {
115      readCurrentQuantity = false;
116      readCurrentUnit = false;
117    }
118  }
119
120  if (unitQuery != null)
121  {
122    unitQuery.include(Include.ALL);
123    unitQuery.order(Orders.asc(Hql.property("quantity.name")));
124    unitQuery.order(Orders.asc(Hql.property("referenceFactor")));
125    unitQuery.order(Orders.asc(Hql.property("name")));
126  }
127 
128  final String clazz = "class=\"text\"";
129  final String requiredClazz = "class=\"text required\"";
130  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
131  String dateFormat = FormatterSettings.getDateFormat(sc);
132  String jsDateFormat = HTML.javaScriptEncode(dateFormat);
133  String htmlDateFormat = HTML.encodeTags(dateFormat);
134 
135  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
136  String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc);
137  String jsDateTimeFormat = HTML.javaScriptEncode(dateTimeFormat);
138  String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat);
139  %>
140  <base:page type="popup" title="<%=title%>">
141  <base:head scripts="tabcontrol.js,linkitems.js,units.js" styles="tabcontrol.css">
142    <script language="JavaScript">
143    // Validate the "Annotation type" tab
144    function validateAnnotationType()
145    {
146      var frm = document.forms['annotationType'];
147      if (Main.trimString(frm.name.value) == '')
148      {
149        alert("You must enter a name");
150        frm.name.focus();
151        return false;
152      }
153      return true;
154    }
155   
156    function validateOptions()
157    {
158      return true;
159    }
160   
161    function validateItemTypes()
162    {
163      return true;
164    }
165
166    function validateUnits()
167    {
168      return true;
169    }
170   
171    function validateCategories()
172    {
173      return true;
174    }
175
176    // Submit the form
177    function saveSettings()
178    {
179      var frm = document.forms['annotationType'];
180      if (TabControl.validateActiveTab('settings'))
181      {
182        var enabled = frm.enabled;
183        for (var i = 0; i < enabled.length; i++) // >
184        {
185          enabled.options[i].selected = true;
186        }
187        frm.addCategories.value = Link.getActionIds(1, 'C').join(',');
188        frm.removeCategories.value = Link.getActionIds(-1, 'C').join(',');
189        if (frm.addUsableUnits && frm.removeUsableUnits)
190        {
191          frm.addUsableUnits.value = Link.getActionIds(1, 'U').join(',');
192          frm.removeUsableUnits.value = Link.getActionIds(-1, 'U').join(',');
193        }
194        frm.submit();
195      }
196    }
197   
198    function init()
199    {
200      <%
201      if (annotationType == null)
202      {
203        %>
204        var frm = document.forms['annotationType'];
205        frm.name.focus();
206        frm.name.select();
207        <%
208      }
209      %>
210      initItemTypes();
211      initCategories();
212      initUnits();
213      interfaceOnClick();
214    }
215
216    function initUnits()
217    {
218      var frm = document.forms['annotationType'];
219      var quantityList = frm.quantity_id;
220      var unitList = frm.unit_id;
221      var quantity;
222      <%
223      if (unitQuery != null)
224      {
225        List<Unit> units = unitQuery.list(dc);
226        Quantity prevQuantity = null;
227        for (Unit unit : units)
228        {
229          Quantity quantity = unit.getQuantity();
230          if (!quantity.equals(prevQuantity))
231          {
232            %>
233            quantity = new Quantity(<%=quantity.getId()%>, '<%=HTML.javaScriptEncode(quantity.getName())%>');
234            <%
235            prevQuantity = quantity;
236          }
237          %>
238          quantity.addUnit(<%=unit.getId()%>, '<%=HTML.javaScriptEncode(unit.getName())%>', '<%=HTML.javaScriptEncode(unit.getDisplaySymbol())%>');
239          <%
240        }
241      }
242      %>
243      if (quantityList && unitList)
244      {
245        Quantities.populateLists(quantityList, unitList, <%=currentQuantityId%>, <%=currentUnitId%>);
246        Quantities.updateUnitsList(quantityList[quantityList.selectedIndex].quantity, frm.allUnits);
247        var usableUnits = new Array();
248        <%
249        if (annotationType != null)
250        {
251          ItemQuery<Unit> usableQuery = annotationType.getUsableUnits();
252          usableQuery.include(Include.ALL);
253          usableQuery.order(Orders.asc(Hql.property("referenceFactor")));
254          usableQuery.order(Orders.asc(Hql.property("name")));
255         
256          ItemResultList<Unit> usableUnits = usableQuery.list(dc);
257          for (Unit u : usableUnits)
258          {
259            %>
260            usableUnits['ID<%=u.getId()%>'] = true;
261            <%
262          }
263        }
264        %>
265        addToUsableUnits(usableUnits);
266      }
267    }
268   
269    function quantityOnChange()
270    {
271      var frm = document.forms['annotationType'];
272      var quantityList = frm.quantity_id;
273      var unitList = frm.unit_id;
274      var quantity = quantityList[quantityList.selectedIndex].quantity;
275      Quantities.updateUnitsList(quantity, unitList, <%=currentUnitId%>);
276      Quantities.updateUnitsList(quantity, frm.allUnits);
277    }
278
279    function addToUsableUnits(usableUnits)
280    {
281      var frm = document.forms['annotationType'];
282      for (var i = 0; i < frm.allUnits.length; i++)
283      {
284        var option = frm.allUnits[i];
285        if (option.selected || (usableUnits && usableUnits['ID'+option.value]))
286        {
287          addUsableUnit(option.value, option.text, usableUnits);
288          frm.allUnits[i--] = null;
289        }
290      }
291    }
292
293    function addUsableUnit(unitId, name, asNew)
294    {
295      var item = Link.getItem('U', unitId);
296      if (!item) item = new Item('U', unitId, name);
297      if (asNew)
298      {
299        Link.addNewItem(document.forms['annotationType'].usableUnits, item);
300      }
301      else
302      {
303        Link.addItem(document.forms['annotationType'].usableUnits, item);
304      }
305    }
306    function removeFromUsableUnits()
307    {
308      var frm = document.forms['annotationType'];
309      Link.removeSelected(frm.usableUnits, frm.allUnits);
310    }
311   
312    function initItemTypes()
313    {
314      var frm = document.forms['annotationType'];
315      var enabled = frm.enabled;
316      var disabled = frm.disabled;
317      <%
318      Set<Item> items = Metadata.getAnnotatableItems();
319      int itemCode = Values.getInt(cc.getPropertyValue("@itemTypes"), -1);
320      for (Item item : items)
321      {
322        %>
323        var option = new Option('<%=item.toString()%>', '<%=item.name()%>');
324        Forms.addListOption(<%=(annotationType == null && itemCode == item.getValue()) || 
325          (annotationType != null && annotationType.isEnabledForItem(item)) ? "enabled" : "disabled"%>, -1, option);
326        <%
327      }
328      %>
329    }
330   
331    function initCategories()
332    {
333      var categories = document.forms['annotationType'].categories;
334      <%
335      if (categoryQuery != null)
336      {
337        ItemResultList<AnnotationTypeCategory> categories = categoryQuery.list(dc);
338        for (AnnotationTypeCategory category : categories)
339        {
340          %>
341          Link.addNewItem(categories, new Item('C', <%=category.getId()%>, '<%=HTML.javaScriptEncode(category.getName())%>'));
342          <%
343        }
344      }
345      %>
346    }
347    function addCategoriesOnClick()
348    {
349      var categories = Link.getListIds(document.forms['annotationType'].categories, 'C');
350      var url = '../annotationtypecategories/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addCategoryCallback';
351      url += '&exclude='+categories.join(',');
352      Main.openPopup(url, 'AddCategories', 1000, 700);
353    }
354   
355    function addCategoryCallback(categoryId, name)
356    {
357      var item = Link.getItem('C', categoryId);
358      if (!item) item = new Item('C', categoryId, name);
359      Link.addItem(document.forms['annotationType'].categories, item);
360    }
361    function removeOnClick()
362    {
363      Link.removeSelected(document.forms['annotationType'].categories);
364    }
365   
366    // Moves all selected items in list1 to list2
367    function moveBetween(list1, list2)
368    {
369      var moved = 0;
370      for(i=0; i < list1.options.length; i++) // >
371      {
372        if (list1.options[i].selected)
373        {
374          moved++;
375          list2.options[list2.options.length] = new Option(list1.options[i].text, list1.options[i].value, false, true);
376          list1.options[i] = null;
377          i--;
378        }
379      }
380    }
381   
382    function interfaceOnClick()
383    {
384      var frm = document.forms['annotationType'];
385      if (frm['interface'])
386      {
387        var isEnum = Forms.getCheckedRadio(frm['interface']).value != 'box';
388        if (frm.minValue) frm.minValue.disabled = isEnum;
389        if (frm.maxValue) frm.maxValue.disabled = isEnum;
390        if (frm.width) frm.width.disabled = isEnum;
391        if (frm.maxLength) frm.maxLength.disabled = isEnum;
392        if (frm.values) frm.values.disabled = !isEnum;
393      }
394    }
395    </script>
396  </base:head>
397  <base:body onload="init()">
398    <p>
399    <form action="index.jsp?ID=<%=ID%>" method="post" name="annotationType" onsubmit="return false;">
400    <input type="hidden" name="cmd" value="UpdateItem">
401    <input type="hidden" name="value_type" value="<%=valueType.name()%>">
402
403    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
404    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*300)+"px;"%>" 
405      position="bottom" remember="<%=annotationType != null%>">
406    <t:tab id="info" title="Annotation type" validate="validateAnnotationType()" helpid="annotationtype.edit">
407      <table class="form" cellspacing=0>
408      <tr>
409        <td class="prompt">Value type</td>
410        <td><%=valueType%></td>
411      </tr>
412      <tr>
413        <td class="prompt">Name</td>
414        <td><input <%=requiredClazz%> type="text" name="name" 
415          value="<%=HTML.encodeTags(annotationType == null ? 
416          Values.getString(cc.getPropertyValue("name"), "New "+valueType+" annotation type") : annotationType.getName())%>" 
417          size="40" maxlength="<%=AnnotationType.MAX_NAME_LENGTH%>"></td>
418      </tr>
419      <tr>
420        <td class="prompt">External ID</td>
421        <td><input <%=clazz%> type="text" name="external_id" 
422          value="<%=HTML.encodeTags(annotationType == null ? 
423            Values.getString(cc.getPropertyValue("externalId"), "") : annotationType.getExternalId())%>" 
424          size="40" maxlength="<%=AnnotationType.MAX_EXTERNAL_ID_LENGTH%>"></td>
425      </tr>
426      <tr>
427        <td class="prompt">Multiplicity</td>
428        <td><input <%=clazz%> type="text" name="multiplicity" 
429          value="<%=annotationType == null ? Values.getString(cc.getPropertyValue("multiplicity"), "1") : 
430            Integer.toString(annotationType.getMultiplicity())%>" 
431          size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
432          0 or empty = unlimited
433          </td>
434      </tr>
435      <tr valign="top">
436        <td class="prompt">Default value</td>
437        <td>
438          <%
439          String defaultValue = annotationType == null ? cc.getPropertyValue("defaultValue") : annotationType.getDefaultValue();
440          if (valueType == Type.INT || valueType == Type.LONG)
441          {
442            %>
443            <input <%=clazz%> type="text" name="defaultValue" 
444              value="<%=HTML.encodeTags(defaultValue)%>" 
445              size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)">
446            <%
447          }
448          else if (valueType == Type.FLOAT || valueType == Type.DOUBLE)
449          {
450            %>
451            <input <%=clazz%> type="text" name="defaultValue" 
452              value="<%=HTML.encodeTags(defaultValue)%>" 
453              size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)">
454            <%
455          }
456          else if (valueType == Type.BOOLEAN)
457          {
458            boolean booleanDefaultValue = Values.getBoolean(defaultValue);
459            %>
460            <input type="radio" name="defaultValue" value="true" 
461              <%=booleanDefaultValue ? "checked" : ""%>
462            >true
463            <input type="radio" name="defaultValue" value="false" 
464              <%=booleanDefaultValue ? "" : "checked"%>
465            >false
466            <%
467          }
468          else if (valueType == Type.DATE)
469          {
470            %>
471            <table border="0" cellspacing="0" cellpadding="0">
472            <tr>
473            <td>
474              <input <%=clazz%> type="text" name="defaultValue" 
475                value="<%=HTML.encodeTags(defaultValue)%>" 
476                size="20" maxlength="20 "title="Enter date in format: <%=htmlDateFormat%>">&nbsp;
477            </td>
478            <td>
479              <base:button 
480                onclick="<%="Dates.selectDate('Default value', 'annotationType', 'defaultValue', null, '"+jsDateFormat+"')"%>" 
481                image="calendar.png"
482                title="Calendar&hellip;" 
483                tooltip="Select a date from a calendar" 
484              />
485            </td>
486            </tr>
487            </table>
488            <%
489          }
490          else if (valueType == Type.TIMESTAMP)
491          {
492            %>
493            <table border="0" cellspacing="0" cellpadding="0">
494            <tr>
495            <td>
496              <input <%=clazz%> type="text" name="defaultValue" 
497                value="<%=HTML.encodeTags(defaultValue)%>" 
498                size="30" maxlength="30 "title="Enter date in format: <%=htmlDateTimeFormat%>">&nbsp;
499            </td>
500            <td>
501              <base:button 
502                onclick="<%="Dates.selectDateTime('Default value', 'annotationType', 'defaultValue', null, '"+jsDateTimeFormat+"')"%>" 
503                image="calendar.png"
504                title="Calendar&hellip;" 
505                tooltip="Select a date and time from a calendar" 
506              />
507            </td>
508            </tr>
509            </table>
510            <%
511          }
512          else if (valueType == Type.STRING)
513          {
514            %>
515            <input <%=clazz%> type="text" name="defaultValue" 
516              value="<%=HTML.encodeTags(defaultValue)%>" 
517              size="40" maxlength="<%=AnnotationType.MAX_DEFAULT_VALUE_LENGTH%>">
518          <%
519          }
520          else if (valueType == Type.TEXT)
521          {
522            %>
523            <textarea <%=clazz%> rows="4" cols="40" name="defaultValue" 
524              wrap="virtual"><%=HTML.encodeTags(defaultValue)%></textarea>
525            <a href="javascript:Main.zoom('Default value', 'annotationType', 'defaultValue')" 
526              title="Edit in larger window"><base:icon image="zoom.gif" /></a>
527            <%
528          }
529          %>
530        </td>
531      </tr>
532      <tr>
533        <td class="prompt">Required for MIAME</td>
534        <td><input type="checkbox" name="required_for_miame" value="1" 
535          <%=(annotationType != null && annotationType.isRequiredForMiame()) || 
536            (annotationType == null && Values.getBoolean(cc.getPropertyValue("requiredForMiame"))) ? "checked" : ""%>
537      </tr>
538      <tr>
539        <td class="prompt">Protocol parameter</td>
540        <td><input type="checkbox" name="is_protocol_parameter" value="1" 
541          <%=(annotationType != null && annotationType.isProtocolParameter()) || 
542            (annotationType == null && Values.getBoolean(cc.getPropertyValue("protocolParameter"))) ? "checked" : ""%>
543      </tr>
544      <tr valign=top>
545        <td class="prompt">Description</td>
546        <td nowrap>
547          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
548            ><%=HTML.encodeTags(annotationType == null ? cc.getPropertyValue("description") : annotationType.getDescription())%></textarea>
549          <a href="javascript:Main.zoom('Description', 'annotationType', 'description')"
550            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
551        </td>
552      </tr>
553      </table>
554      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
555    </t:tab>
556   
557    <t:tab id="options" title="Options" validate="validateOptions()" helpid="annotationtype.edit.options">
558      <table class="form" cellspacing=0>
559      <%
560      if (valueType == Type.INT || valueType == Type.LONG)
561      {
562        Long minValue = annotationType == null ? null : annotationType.getMinValueLong();
563        Long maxValue = annotationType == null ? null : annotationType.getMaxValueLong();
564        boolean isEnumeration = annotationType == null ? 
565          Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration();
566        boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList();
567        %>
568        <tr>
569          <td class="prompt">Interface</td>
570          <td>
571            <input type="radio" name="interface" value="box"
572              <%=!isEnumeration ? "checked" : ""%>
573              onclick="interfaceOnClick()"
574            >text box
575            <input type="radio" name="interface" value="list" 
576              <%=isEnumeration && displayAsList ? "checked" : ""%>
577              onclick="interfaceOnClick()"
578            >selection list
579            <input type="radio" name="interface" value="buttons" 
580              <%=isEnumeration && !displayAsList ? "checked" : ""%>
581              onclick="interfaceOnClick()"
582            >radiobuttons/checkboxes
583          </td>
584        </tr>
585        <tr>
586          <td class="prompt">Min value</td>
587          <td>
588            <input <%=clazz%> type="text" name="minValue" 
589              value="<%=minValue == null ? "" : minValue.toString()%>" 
590              size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)">
591            empty = no limit
592          </td>
593        </tr>
594        <tr>
595          <td class="prompt">Max value</td>
596          <td>
597            <input <%=clazz%> type="text" name="maxValue" 
598              value="<%=maxValue == null ? "" : maxValue.toString()%>" 
599              size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)">
600            empty = no limit
601          </td>
602        </tr>
603        <tr>
604          <td class="prompt">Input box width</td>
605          <td>
606            <input <%=clazz%> type="text" name="width" 
607              value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 
608              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
609          </td>
610        </tr>
611        <tr valign="top">
612          <td class="prompt">Values</td>
613          <td nowrap>
614            <%
615            String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true);
616            %>
617            <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual"
618              onkeypress="return Numbers.integerOnly(event)"><%=HTML.encodeTags(values)%></textarea>
619            <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')"
620              title="Edit in larger window"><base:icon image="zoom.gif" /></a><br>
621            One enumeration value per line
622          </td>
623        </tr>
624        <%
625      }
626      else if (valueType == Type.FLOAT || valueType == Type.DOUBLE)
627      {
628        Double minValue = annotationType == null ? null : annotationType.getMinValueDouble();
629        Double maxValue = annotationType == null ? null : annotationType.getMaxValueDouble();
630        boolean isEnumeration = annotationType == null ? 
631          Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration();
632        boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList();
633        %>
634        <tr>
635          <td class="prompt">Interface</td>
636          <td>
637            <input type="radio" name="interface" value="box"
638              <%=!isEnumeration ? "checked" : ""%>
639              onclick="interfaceOnClick()"
640            >text box
641            <input type="radio" name="interface" value="list" 
642              <%=isEnumeration && displayAsList ? "checked" : ""%>
643              onclick="interfaceOnClick()"
644            >selection list
645            <input type="radio" name="interface" value="buttons" 
646              <%=isEnumeration && !displayAsList ? "checked" : ""%>
647              onclick="interfaceOnClick()"
648            >radiobuttons/checkboxes
649          </td>
650        </tr>
651        <tr>
652          <td class="prompt">Min value</td>
653          <td>
654            <input <%=clazz%> type="text" name="minValue" 
655              value="<%=minValue == null ? "" : minValue.toString()%>" 
656              size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)">
657            empty = no limit
658          </td>
659        </tr>
660        <tr>
661          <td class="prompt">Max value</td>
662          <td>
663            <input <%=clazz%> type="text" name="maxValue" 
664              value="<%=maxValue == null ? "" : maxValue.toString()%>" 
665              size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)">
666            empty = no limit
667          </td>
668        </tr>
669        <tr>
670          <td class="prompt">Input box width</td>
671          <td>
672            <input <%=clazz%> type="text" name="width" 
673              value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 
674              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
675          </td>
676        </tr>
677        <tr valign="top">
678          <td class="prompt">Values</td>
679          <td nowrap>
680            <%
681            String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true);
682            %>
683            <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual"
684              onkeypress="return Numbers.numberOnly(event)"><%=HTML.encodeTags(values)%></textarea>
685            <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" 
686              title="Edit in larger window"><base:icon image="zoom.gif" /></a><br>
687            One enumeration value per line
688          </td>
689        </tr>
690        <%
691      }
692      else if (valueType == Type.BOOLEAN)
693      {
694        %>
695        No options for this type.
696        <%
697      }
698      else if (valueType == Type.DATE)
699      {
700        boolean isEnumeration = annotationType == null ? 
701          Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration();
702        boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList();
703        %>
704        <tr>
705          <td class="prompt">Interface</td>
706          <td>
707            <input type="radio" name="interface" value="box"
708              <%=!isEnumeration ? "checked" : ""%>
709              onclick="interfaceOnClick()"
710            >text box
711            <input type="radio" name="interface" value="list" 
712              <%=isEnumeration && displayAsList ? "checked" : ""%>
713              onclick="interfaceOnClick()"
714            >selection list
715            <input type="radio" name="interface" value="buttons" 
716              <%=isEnumeration && !displayAsList ? "checked" : ""%>
717              onclick="interfaceOnClick()"
718            >radiobuttons/checkboxes
719          </td>
720        </tr>
721        <tr>
722          <td class="prompt">Input box width</td>
723          <td>
724            <input <%=clazz%> type="text" name="width" 
725              value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 
726              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
727          </td>
728        </tr>
729        <tr valign="top">
730          <td class="prompt">Values</td>
731          <td nowrap>
732            <%
733            String values = annotationType == null ? "" : 
734              Values.getString((List<Date>)annotationType.getValues(), "\n", true, dateFormatter);
735            %>
736            <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual"
737              ><%=HTML.encodeTags(values)%></textarea>
738            <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" title="Edit in larger window"><base:icon image="zoom.gif" /></a><br>
739            One date value (<%=htmlDateFormat%>) per line
740          </td>
741        </tr>
742        <%
743      }
744      else if (valueType == Type.TIMESTAMP)
745      {
746        %>
747        <tr>
748          <td class="prompt">Input box width</td>
749          <td>
750            <input <%=clazz%> type="text" name="width" 
751              value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 
752              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
753          </td>
754        </tr>
755        <%
756      }
757      else if (valueType == Type.STRING)
758      {
759        Integer maxLength = annotationType == null ? null : annotationType.getMaxLength();
760        boolean isEnumeration = annotationType == null ? 
761          Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration();
762        boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList();
763        %>
764        <tr>
765          <td class="prompt">Interface</td>
766          <td>
767            <input type="radio" name="interface" value="box"
768              <%=!isEnumeration ? "checked" : ""%>
769              onclick="interfaceOnClick()"
770            >text box
771            <input type="radio" name="interface" value="list" 
772              <%=isEnumeration && displayAsList ? "checked" : ""%>
773              onclick="interfaceOnClick()"
774            >selection list
775            <input type="radio" name="interface" value="buttons" 
776              <%=isEnumeration && !displayAsList ? "checked" : ""%>
777              onclick="interfaceOnClick()"
778            >radiobuttons/checkboxes
779          </td>
780        </tr>
781        <tr>
782          <td class="prompt">Max length</td>
783          <td>
784            <input <%=clazz%> type="text" name="maxLength" 
785              value="<%=maxLength == null ? "" : maxLength.toString()%>" 
786              size="12" maxlength="3" onkeypress="return Numbers.integerOnly(event)"> (1-255)
787          </td>
788        </tr>
789        <tr>
790          <td class="prompt">Input box width</td>
791          <td>
792            <input <%=clazz%> type="text" name="width" 
793              value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 
794              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
795          </td>
796        </tr>
797        <tr valign="top">
798          <td class="prompt">Values</td>
799          <td nowrap>
800            <%
801            String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true);
802            %>
803            <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual"><%=HTML.encodeTags(values)%></textarea>
804            <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" 
805              title="Edit in larger window"><base:icon image="zoom.gif" /></a><br>
806            One enumeration value per line
807          </td>
808        </tr>
809        <%
810      }
811      else if (valueType == Type.TEXT)
812      {
813        %>
814        <tr>
815          <td class="prompt">Input box width</td>
816          <td>
817            <input <%=clazz%> type="text" name="width" 
818              value="<%=annotationType == null ? "" : annotationType.getWidth()%>" 
819              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
820          </td>
821        </tr>
822        <tr>
823          <td class="prompt">Input box height</td>
824          <td>
825            <input <%=clazz%> type="text" name="width" 
826              value="<%=annotationType == null ? "" : annotationType.getHeight()%>" 
827              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
828          </td>
829        </tr>
830        <%
831      }
832      %>
833      </table>
834    </t:tab>
835   
836    <t:tab id="items" title="Item types" validate="validateItemTypes()" helpid="annotationtype.edit.items">
837    <table border=0 cellspacing=0 cellpadding=2>
838    <tr>
839      <td>
840        <b>Enabled for</b><br>
841        <select name="enabled" multiple size="14" style="width: 12em;"
842          ondblclick="moveBetween(document.forms['annotationType'].enabled, document.forms['annotationType'].disabled)">
843        </select>
844      </td>
845 
846      <td>
847         <br>
848        <base:button
849          onclick="moveBetween(document.forms['annotationType'].disabled, document.forms['annotationType'].enabled)" 
850          title="<img src='../../images/move_left.gif' alt='' style='vertical-align: middle;'>" 
851          tooltip="Enable the annotation type for the selected item(s)" 
852        /><p>
853        <base:button 
854          onclick="moveBetween(document.forms['annotationType'].enabled, document.forms['annotationType'].disabled)" 
855          title="<img src='../../images/move_right.gif' alt='' style='vertical-align: middle;'>" 
856          tooltip="Disable the annotation type for the selected item(s)" 
857        />
858        <br>
859      </td>
860 
861      <td>
862        <b>Disabled for</b><br>
863        <select name="disabled" multiple size="14" style="width: 12em;" 
864          ondblclick="moveBetween(document.forms['annotationType'].disabled, document.forms['annotationType'].enabled)">
865        </select>
866      </td>
867    </tr>
868    </table>
869    </t:tab>
870   
871    <t:tab id="units" title="Units" validate="validateUnits()" 
872      visible="<%=valueType.isNumerical()%>" helpid="annotationtype.edit.units">
873   
874      <table class="form" cellspacing="0">
875      <tr valign="top">
876        <td class="prompt">Quantity</td>
877        <td>
878          <select name="quantity_id" onchange="quantityOnChange()"
879            <%=!readCurrentQuantity || (annotationType != null && currentQuantityId != 0) ? 
880                "disabled readonly class=\"disabled\"" : "class=\"unchangeable\""%>>
881            <option value="">- do not use units -
882          </select>
883        </td>
884      </tr>
885      <tr valign="top">
886        <td class="prompt">Default unit</td>
887        <td>
888          <select name="unit_id" 
889            <%=!readCurrentQuantity ? "disabled readonly class=\"disabled\"" : ""%>>
890          </select>
891        </td>
892      </tr>
893      </table>
894
895      <base:note type="warning" style="background: #ffffd8;"  visible="<%=annotationType != null %>">
896      Changing the default unit triggers a conversion of existing annotation values
897      to the new unit. This may result in loss of precision due to rounding or
898      truncation.
899      </base:note>
900
901      <table class="form" cellspacing="0">
902      <tr valign="top">
903        <td class="prompt">Use units</td>
904        <td></td>
905        <td class="prompt">Do not use</td>
906      </tr>
907      <tr>
908        <td>
909          <select name="usableUnits" size="5" multiple style="width: 15em;" ondblclick="removeFromUsableUnits()">
910          </select>
911        </td>
912        <td>
913           <br>
914          <base:button
915            onclick="addToUsableUnits()"
916            title="<img src='../../images/move_left.gif' alt='' style='vertical-align: middle;'>" 
917            tooltip="Enable the annotation type for the selected unit(s)" 
918          /><p>
919          <base:button 
920            onclick="removeFromUsableUnits()"
921            title="<img src='../../images/move_right.gif' alt='' style='vertical-align: middle;'>" 
922            tooltip="Disable the annotation type for the selected unit(s)" 
923          />
924          <br>
925        </td>
926        <td>
927          <select name="allUnits" size="5" multiple style="width: 15em;" ondblclick="addToUsableUnits()">
928          </select>
929          <input type="hidden" name="removeUsableUnits" value="">
930          <input type="hidden" name="addUsableUnits" value="">
931        </td>
932      </tr>
933      </table>
934
935      <div align=right>
936        <i><base:icon image="unchangeable.gif" /> = can't be changed later</i>
937      </div>
938
939    </t:tab>
940
941    <t:tab id="categories" title="Categories" validate="validateCategories()" 
942      helpid="annotationtype.edit.categories">
943      <table >
944      <tr valign="top">
945      <td>
946        <b>Categories</b><br>
947        <select name="categories" size="14" multiple 
948          style="width: 15em;">
949        </select>
950        <input type="hidden" name="removeCategories" value="">
951        <input type="hidden" name="addCategories" value="">
952      </td>
953      <td>
954        <br>
955        <table width="150">
956        <tr><td><base:button 
957          onclick="addCategoriesOnClick()" 
958          title="Add&nbsp;categories&hellip;" 
959          tooltip="Add categories to this annotation type"
960          /></td></tr>
961        <tr><td><base:button 
962          onclick="removeOnClick()" 
963          title="Remove" 
964          tooltip="Remove the selected categories from this annotation type"
965        /></td></tr>
966        </table>
967      </td>
968      </tr>
969      </table>
970    </t:tab>
971   
972    </t:tabcontrol>
973
974    <table align="center">
975    <tr>
976      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
977      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
978    </tr>
979    </table>
980    </form>
981  </base:body>
982  </base:page>
983  <%
984}
985finally
986{
987  if (dc != null) dc.close();
988}
989%>
Note: See TracBrowser for help on using the repository browser.