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

Last change on this file since 5812 was 5812, checked in by Nicklas Nordborg, 12 years ago

Fixes #1629: Use <label> instead of javascript for text associated with radio buttons

Radio buttons and checkboxes should now be fixed. The exception is checkboxes/radiobuttons in list pages. The reason is that the action depends on the list mode. In most cases the action is to open the view- or edit- page, not to check the radio button or checkbox.

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