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