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