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