1 | <%-- $Id: edit_annotationtype.jsp 4510 2008-09-11 20:03:48Z jari $ |
---|
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.SystemItems" |
---|
38 | import="net.sf.basedb.core.Metadata" |
---|
39 | import="net.sf.basedb.core.ItemQuery" |
---|
40 | import="net.sf.basedb.core.ItemResultList" |
---|
41 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
42 | import="net.sf.basedb.core.query.Orders" |
---|
43 | import="net.sf.basedb.core.query.Hql" |
---|
44 | import="net.sf.basedb.clients.web.Base" |
---|
45 | import="net.sf.basedb.clients.web.util.HTML" |
---|
46 | import="net.sf.basedb.util.Values" |
---|
47 | import="net.sf.basedb.util.formatter.Formatter" |
---|
48 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
49 | import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
---|
50 | import="java.util.Date" |
---|
51 | import="java.util.Set" |
---|
52 | import="java.util.List" |
---|
53 | %> |
---|
54 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
55 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
56 | <% |
---|
57 | final Item itemType = Item.ANNOTATIONTYPE; |
---|
58 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
59 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
60 | final int itemId = cc.getId(); |
---|
61 | final String ID = sc.getId(); |
---|
62 | final float scale = Base.getScale(sc); |
---|
63 | final DbControl dc = sc.newDbControl(); |
---|
64 | try |
---|
65 | { |
---|
66 | String title = null; |
---|
67 | AnnotationType annotationType = null; |
---|
68 | ItemQuery<AnnotationTypeCategory> categoryQuery = null; |
---|
69 | Type valueType = null; |
---|
70 | |
---|
71 | if (itemId == 0) |
---|
72 | { |
---|
73 | title = "Create annotation type"; |
---|
74 | valueType = Type.valueOf(request.getParameter("value_type")); |
---|
75 | cc.removeObject("item"); |
---|
76 | } |
---|
77 | else |
---|
78 | { |
---|
79 | annotationType = AnnotationType.getById(dc, itemId); |
---|
80 | annotationType.checkPermission(Permission.WRITE); |
---|
81 | valueType = annotationType.getValueType(); |
---|
82 | cc.setObject("item", annotationType); |
---|
83 | title = "Edit annotation type -- " + HTML.encodeTags(annotationType.getName()); |
---|
84 | categoryQuery = annotationType.getCategories(); |
---|
85 | categoryQuery.include(Include.ALL); |
---|
86 | categoryQuery.order(Orders.asc(Hql.property("name"))); |
---|
87 | } |
---|
88 | |
---|
89 | final String clazz = "class=\"text\""; |
---|
90 | final String requiredClazz = "class=\"text required\""; |
---|
91 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
92 | String dateFormat = FormatterSettings.getDateFormat(sc); |
---|
93 | String jsDateFormat = HTML.javaScriptEncode(dateFormat); |
---|
94 | String htmlDateFormat = HTML.encodeTags(dateFormat); |
---|
95 | %> |
---|
96 | <base:page type="popup" title="<%=title%>"> |
---|
97 | <base:head scripts="tabcontrol.js,linkitems.js" styles="tabcontrol.css"> |
---|
98 | <script language="JavaScript"> |
---|
99 | // Validate the "Annotation type" tab |
---|
100 | function validateAnnotationType() |
---|
101 | { |
---|
102 | var frm = document.forms['annotationType']; |
---|
103 | if (Main.trimString(frm.name.value) == '') |
---|
104 | { |
---|
105 | alert("You must enter a name"); |
---|
106 | frm.name.focus(); |
---|
107 | return false; |
---|
108 | } |
---|
109 | return true; |
---|
110 | } |
---|
111 | |
---|
112 | function validateOptions() |
---|
113 | { |
---|
114 | return true; |
---|
115 | } |
---|
116 | |
---|
117 | function validateItemTypes() |
---|
118 | { |
---|
119 | return true; |
---|
120 | } |
---|
121 | |
---|
122 | function validateCategories() |
---|
123 | { |
---|
124 | return true; |
---|
125 | } |
---|
126 | |
---|
127 | // Submit the form |
---|
128 | function saveSettings() |
---|
129 | { |
---|
130 | var frm = document.forms['annotationType']; |
---|
131 | if (TabControl.validateActiveTab('settings')) |
---|
132 | { |
---|
133 | var enabled = frm.enabled; |
---|
134 | for (var i = 0; i < enabled.length; i++) // > |
---|
135 | { |
---|
136 | enabled.options[i].selected = true; |
---|
137 | } |
---|
138 | frm.addCategories.value = Link.getActionIds(1, 'C').join(','); |
---|
139 | frm.removeCategories.value = Link.getActionIds(-1, 'C').join(','); |
---|
140 | frm.submit(); |
---|
141 | } |
---|
142 | } |
---|
143 | |
---|
144 | function init() |
---|
145 | { |
---|
146 | <% |
---|
147 | if (annotationType == null) |
---|
148 | { |
---|
149 | %> |
---|
150 | var frm = document.forms['annotationType']; |
---|
151 | frm.name.focus(); |
---|
152 | frm.name.select(); |
---|
153 | <% |
---|
154 | } |
---|
155 | %> |
---|
156 | initItemTypes(); |
---|
157 | initCategories(); |
---|
158 | interfaceOnClick(); |
---|
159 | } |
---|
160 | function initItemTypes() |
---|
161 | { |
---|
162 | var frm = document.forms['annotationType']; |
---|
163 | var enabled = frm.enabled; |
---|
164 | var disabled = frm.disabled; |
---|
165 | <% |
---|
166 | Set<Item> items = Metadata.getAnnotatableItems(); |
---|
167 | int itemCode = Values.getInt(cc.getPropertyValue("@itemTypes"), -1); |
---|
168 | for (Item item : items) |
---|
169 | { |
---|
170 | %> |
---|
171 | var option = new Option('<%=item.toString()%>', '<%=item.name()%>'); |
---|
172 | Forms.addListOption(<%=(annotationType == null && itemCode == item.getValue()) || |
---|
173 | (annotationType != null && annotationType.isEnabledForItem(item)) ? "enabled" : "disabled"%>, -1, option); |
---|
174 | <% |
---|
175 | } |
---|
176 | %> |
---|
177 | } |
---|
178 | |
---|
179 | function initCategories() |
---|
180 | { |
---|
181 | var categories = document.forms['annotationType'].categories; |
---|
182 | <% |
---|
183 | if (categoryQuery != null) |
---|
184 | { |
---|
185 | ItemResultList<AnnotationTypeCategory> categories = categoryQuery.list(dc); |
---|
186 | for (AnnotationTypeCategory category : categories) |
---|
187 | { |
---|
188 | %> |
---|
189 | Link.addNewItem(categories, new Item('C', <%=category.getId()%>, '<%=HTML.javaScriptEncode(category.getName())%>')); |
---|
190 | <% |
---|
191 | } |
---|
192 | } |
---|
193 | %> |
---|
194 | } |
---|
195 | function addCategoriesOnClick() |
---|
196 | { |
---|
197 | var categories = Link.getListIds(document.forms['annotationType'].categories, 'C'); |
---|
198 | var url = '../annotationtypecategories/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addCategoryCallback'; |
---|
199 | url += '&exclude='+categories.join(','); |
---|
200 | Main.openPopup(url, 'AddCategories', 1000, 700); |
---|
201 | } |
---|
202 | |
---|
203 | function addCategoryCallback(categoryId, name) |
---|
204 | { |
---|
205 | var item = Link.getItem('C', categoryId); |
---|
206 | if (!item) item = new Item('C', categoryId, name); |
---|
207 | Link.addItem(document.forms['annotationType'].categories, item); |
---|
208 | } |
---|
209 | function removeOnClick() |
---|
210 | { |
---|
211 | Link.removeSelected(document.forms['annotationType'].categories); |
---|
212 | } |
---|
213 | |
---|
214 | // Moves all selected items in list1 to list2 |
---|
215 | function moveBetween(list1, list2) |
---|
216 | { |
---|
217 | var moved = 0; |
---|
218 | for(i=0; i < list1.options.length; i++) // > |
---|
219 | { |
---|
220 | if (list1.options[i].selected) |
---|
221 | { |
---|
222 | moved++; |
---|
223 | list2.options[list2.options.length] = new Option(list1.options[i].text, list1.options[i].value, false, true); |
---|
224 | list1.options[i] = null; |
---|
225 | i--; |
---|
226 | } |
---|
227 | } |
---|
228 | } |
---|
229 | |
---|
230 | function interfaceOnClick() |
---|
231 | { |
---|
232 | var frm = document.forms['annotationType']; |
---|
233 | if (frm['interface']) |
---|
234 | { |
---|
235 | var isEnum = Forms.getCheckedRadio(frm['interface']).value != 'box'; |
---|
236 | if (frm.minValue) frm.minValue.disabled = isEnum; |
---|
237 | if (frm.maxValue) frm.maxValue.disabled = isEnum; |
---|
238 | if (frm.width) frm.width.disabled = isEnum; |
---|
239 | if (frm.maxLength) frm.maxLength.disabled = isEnum; |
---|
240 | if (frm.values) frm.values.disabled = !isEnum; |
---|
241 | } |
---|
242 | } |
---|
243 | </script> |
---|
244 | </base:head> |
---|
245 | <base:body onload="init()"> |
---|
246 | <p> |
---|
247 | <form action="index.jsp?ID=<%=ID%>" method="post" name="annotationType" onsubmit="return false;"> |
---|
248 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
249 | <input type="hidden" name="value_type" value="<%=valueType.name()%>"> |
---|
250 | |
---|
251 | <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> |
---|
252 | <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*300)+"px;"%>" |
---|
253 | position="bottom" remember="<%=annotationType != null%>"> |
---|
254 | <t:tab id="info" title="Annotation type" validate="validateAnnotationType()" helpid="annotationtype.edit"> |
---|
255 | <table class="form" cellspacing=0> |
---|
256 | <tr> |
---|
257 | <td class="prompt">Value type</td> |
---|
258 | <td><%=valueType%></td> |
---|
259 | </tr> |
---|
260 | <tr> |
---|
261 | <td class="prompt">Name</td> |
---|
262 | <td><input <%=requiredClazz%> type="text" name="name" |
---|
263 | value="<%=HTML.encodeTags(annotationType == null ? |
---|
264 | Values.getString(cc.getPropertyValue("name"), "New "+valueType+" annotation type") : annotationType.getName())%>" |
---|
265 | size="40" maxlength="<%=AnnotationType.MAX_NAME_LENGTH%>"></td> |
---|
266 | </tr> |
---|
267 | <tr> |
---|
268 | <td class="prompt">External ID</td> |
---|
269 | <td><input <%=clazz%> type="text" name="external_id" |
---|
270 | value="<%=HTML.encodeTags(annotationType == null ? |
---|
271 | Values.getString(cc.getPropertyValue("externalId"), "") : annotationType.getExternalId())%>" |
---|
272 | size="40" maxlength="<%=AnnotationType.MAX_EXTERNAL_ID_LENGTH%>"></td> |
---|
273 | </tr> |
---|
274 | <tr> |
---|
275 | <td class="prompt">Multiplicity</td> |
---|
276 | <td><input <%=clazz%> type="text" name="multiplicity" |
---|
277 | value="<%=annotationType == null ? Values.getString(cc.getPropertyValue("multiplicity"), "1") : |
---|
278 | Integer.toString(annotationType.getMultiplicity())%>" |
---|
279 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
280 | 0 or empty = unlimited |
---|
281 | </td> |
---|
282 | </tr> |
---|
283 | <tr valign="top"> |
---|
284 | <td class="prompt">Default value</td> |
---|
285 | <td> |
---|
286 | <% |
---|
287 | String defaultValue = annotationType == null ? cc.getPropertyValue("defaultValue") : annotationType.getDefaultValue(); |
---|
288 | if (valueType == Type.INT || valueType == Type.LONG) |
---|
289 | { |
---|
290 | %> |
---|
291 | <input <%=clazz%> type="text" name="defaultValue" |
---|
292 | value="<%=HTML.encodeTags(defaultValue)%>" |
---|
293 | size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"> |
---|
294 | <% |
---|
295 | } |
---|
296 | else if (valueType == Type.FLOAT || valueType == Type.DOUBLE) |
---|
297 | { |
---|
298 | %> |
---|
299 | <input <%=clazz%> type="text" name="defaultValue" |
---|
300 | value="<%=HTML.encodeTags(defaultValue)%>" |
---|
301 | size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"> |
---|
302 | <% |
---|
303 | } |
---|
304 | else if (valueType == Type.BOOLEAN) |
---|
305 | { |
---|
306 | boolean booleanDefaultValue = Values.getBoolean(defaultValue); |
---|
307 | %> |
---|
308 | <input type="radio" name="defaultValue" value="true" |
---|
309 | <%=booleanDefaultValue ? "checked" : ""%> |
---|
310 | >true |
---|
311 | <input type="radio" name="defaultValue" value="false" |
---|
312 | <%=booleanDefaultValue ? "" : "checked"%> |
---|
313 | >false |
---|
314 | <% |
---|
315 | } |
---|
316 | else if (valueType == Type.DATE) |
---|
317 | { |
---|
318 | %> |
---|
319 | <table border="0" cellspacing="0" cellpadding="0"> |
---|
320 | <tr> |
---|
321 | <td> |
---|
322 | <input <%=clazz%> type="text" name="defaultValue" |
---|
323 | value="<%=HTML.encodeTags(defaultValue)%>" |
---|
324 | size="20" maxlength="20 "title="Enter date in format: <%=htmlDateFormat%>"> |
---|
325 | </td> |
---|
326 | <td> |
---|
327 | <base:button |
---|
328 | onclick="<%="Dates.selectDate('Default value', 'annotationType', 'defaultValue', null, '"+jsDateFormat+"')"%>" |
---|
329 | image="calendar.png" |
---|
330 | title="Calendar…" |
---|
331 | tooltip="Select a date from a calendar" |
---|
332 | /> |
---|
333 | </td> |
---|
334 | </tr> |
---|
335 | </table> |
---|
336 | <% |
---|
337 | } |
---|
338 | else if (valueType == Type.STRING) |
---|
339 | { |
---|
340 | %> |
---|
341 | <input <%=clazz%> type="text" name="defaultValue" |
---|
342 | value="<%=HTML.encodeTags(defaultValue)%>" |
---|
343 | size="40" maxlength="<%=AnnotationType.MAX_DEFAULT_VALUE_LENGTH%>"> |
---|
344 | <% |
---|
345 | } |
---|
346 | else if (valueType == Type.TEXT) |
---|
347 | { |
---|
348 | %> |
---|
349 | <textarea <%=clazz%> rows="4" cols="40" name="defaultValue" |
---|
350 | wrap="virtual"><%=HTML.encodeTags(defaultValue)%></textarea> |
---|
351 | <a href="javascript:Main.zoom('Default value', 'annotationType', 'defaultValue')" |
---|
352 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
353 | <% |
---|
354 | } |
---|
355 | %> |
---|
356 | </td> |
---|
357 | </tr> |
---|
358 | <tr> |
---|
359 | <td class="prompt">Required for MIAME</td> |
---|
360 | <td><input type="checkbox" name="required_for_miame" value="1" |
---|
361 | <%=(annotationType != null && annotationType.isRequiredForMiame()) || |
---|
362 | (annotationType == null && Values.getBoolean(cc.getPropertyValue("requiredForMiame"))) ? "checked" : ""%> |
---|
363 | </tr> |
---|
364 | <tr> |
---|
365 | <td class="prompt">Protocol parameter</td> |
---|
366 | <td><input type="checkbox" name="is_protocol_parameter" value="1" |
---|
367 | <%=(annotationType != null && annotationType.isProtocolParameter()) || |
---|
368 | (annotationType == null && Values.getBoolean(cc.getPropertyValue("protocolParameter"))) ? "checked" : ""%> |
---|
369 | </tr> |
---|
370 | <tr valign=top> |
---|
371 | <td class="prompt">Description</td> |
---|
372 | <td nowrap> |
---|
373 | <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual" |
---|
374 | ><%=HTML.encodeTags(annotationType == null ? cc.getPropertyValue("description") : annotationType.getDescription())%></textarea> |
---|
375 | <a href="javascript:Main.zoom('Description', 'annotationType', 'description')" |
---|
376 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
377 | </td> |
---|
378 | </tr> |
---|
379 | </table> |
---|
380 | <div align=right> <i><base:icon image="required.gif" /> = required information</i></div> |
---|
381 | </t:tab> |
---|
382 | |
---|
383 | <t:tab id="options" title="Options" validate="validateOptions()" helpid="annotationtype.edit.options"> |
---|
384 | <table class="form" cellspacing=0> |
---|
385 | <% |
---|
386 | if (valueType == Type.INT || valueType == Type.LONG) |
---|
387 | { |
---|
388 | Long minValue = annotationType == null ? null : annotationType.getMinValueLong(); |
---|
389 | Long maxValue = annotationType == null ? null : annotationType.getMaxValueLong(); |
---|
390 | boolean isEnumeration = annotationType == null ? |
---|
391 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
392 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
393 | %> |
---|
394 | <tr> |
---|
395 | <td class="prompt">Interface</td> |
---|
396 | <td> |
---|
397 | <input type="radio" name="interface" value="box" |
---|
398 | <%=!isEnumeration ? "checked" : ""%> |
---|
399 | onclick="interfaceOnClick()" |
---|
400 | >text box |
---|
401 | <input type="radio" name="interface" value="list" |
---|
402 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
403 | onclick="interfaceOnClick()" |
---|
404 | >selection list |
---|
405 | <input type="radio" name="interface" value="buttons" |
---|
406 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
407 | onclick="interfaceOnClick()" |
---|
408 | >radiobuttons/checkboxes |
---|
409 | </td> |
---|
410 | </tr> |
---|
411 | <tr> |
---|
412 | <td class="prompt">Min value</td> |
---|
413 | <td> |
---|
414 | <input <%=clazz%> type="text" name="minValue" |
---|
415 | value="<%=minValue == null ? "" : minValue.toString()%>" |
---|
416 | size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"> |
---|
417 | empty = no limit |
---|
418 | </td> |
---|
419 | </tr> |
---|
420 | <tr> |
---|
421 | <td class="prompt">Max value</td> |
---|
422 | <td> |
---|
423 | <input <%=clazz%> type="text" name="maxValue" |
---|
424 | value="<%=maxValue == null ? "" : maxValue.toString()%>" |
---|
425 | size="20" maxlength="20" onkeypress="return Numbers.integerOnly(event)"> |
---|
426 | empty = no limit |
---|
427 | </td> |
---|
428 | </tr> |
---|
429 | <tr> |
---|
430 | <td class="prompt">Input box width</td> |
---|
431 | <td> |
---|
432 | <input <%=clazz%> type="text" name="width" |
---|
433 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" |
---|
434 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
435 | </td> |
---|
436 | </tr> |
---|
437 | <tr valign="top"> |
---|
438 | <td class="prompt">Values</td> |
---|
439 | <td nowrap> |
---|
440 | <% |
---|
441 | String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); |
---|
442 | %> |
---|
443 | <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual" |
---|
444 | onkeypress="return Numbers.integerOnly(event)"><%=HTML.encodeTags(values)%></textarea> |
---|
445 | <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" |
---|
446 | title="Edit in larger window"><base:icon image="zoom.gif" /></a><br> |
---|
447 | One enumeration value per line |
---|
448 | </td> |
---|
449 | </tr> |
---|
450 | <% |
---|
451 | } |
---|
452 | else if (valueType == Type.FLOAT || valueType == Type.DOUBLE) |
---|
453 | { |
---|
454 | Double minValue = annotationType == null ? null : annotationType.getMinValueDouble(); |
---|
455 | Double maxValue = annotationType == null ? null : annotationType.getMaxValueDouble(); |
---|
456 | boolean isEnumeration = annotationType == null ? |
---|
457 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
458 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
459 | %> |
---|
460 | <tr> |
---|
461 | <td class="prompt">Interface</td> |
---|
462 | <td> |
---|
463 | <input type="radio" name="interface" value="box" |
---|
464 | <%=!isEnumeration ? "checked" : ""%> |
---|
465 | onclick="interfaceOnClick()" |
---|
466 | >text box |
---|
467 | <input type="radio" name="interface" value="list" |
---|
468 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
469 | onclick="interfaceOnClick()" |
---|
470 | >selection list |
---|
471 | <input type="radio" name="interface" value="buttons" |
---|
472 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
473 | onclick="interfaceOnClick()" |
---|
474 | >radiobuttons/checkboxes |
---|
475 | </td> |
---|
476 | </tr> |
---|
477 | <tr> |
---|
478 | <td class="prompt">Min value</td> |
---|
479 | <td> |
---|
480 | <input <%=clazz%> type="text" name="minValue" |
---|
481 | value="<%=minValue == null ? "" : minValue.toString()%>" |
---|
482 | size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"> |
---|
483 | empty = no limit |
---|
484 | </td> |
---|
485 | </tr> |
---|
486 | <tr> |
---|
487 | <td class="prompt">Max value</td> |
---|
488 | <td> |
---|
489 | <input <%=clazz%> type="text" name="maxValue" |
---|
490 | value="<%=maxValue == null ? "" : maxValue.toString()%>" |
---|
491 | size="20" maxlength="20" onkeypress="return Numbers.numberOnly(event)"> |
---|
492 | empty = no limit |
---|
493 | </td> |
---|
494 | </tr> |
---|
495 | <tr> |
---|
496 | <td class="prompt">Input box width</td> |
---|
497 | <td> |
---|
498 | <input <%=clazz%> type="text" name="width" |
---|
499 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" |
---|
500 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
501 | </td> |
---|
502 | </tr> |
---|
503 | <tr valign="top"> |
---|
504 | <td class="prompt">Values</td> |
---|
505 | <td nowrap> |
---|
506 | <% |
---|
507 | String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); |
---|
508 | %> |
---|
509 | <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual" |
---|
510 | onkeypress="return Numbers.numberOnly(event)"><%=HTML.encodeTags(values)%></textarea> |
---|
511 | <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" |
---|
512 | title="Edit in larger window"><base:icon image="zoom.gif" /></a><br> |
---|
513 | One enumeration value per line |
---|
514 | </td> |
---|
515 | </tr> |
---|
516 | <% |
---|
517 | } |
---|
518 | else if (valueType == Type.BOOLEAN) |
---|
519 | { |
---|
520 | %> |
---|
521 | No options for this type. |
---|
522 | <% |
---|
523 | } |
---|
524 | else if (valueType == Type.DATE) |
---|
525 | { |
---|
526 | boolean isEnumeration = annotationType == null ? |
---|
527 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
528 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
529 | %> |
---|
530 | <tr> |
---|
531 | <td class="prompt">Interface</td> |
---|
532 | <td> |
---|
533 | <input type="radio" name="interface" value="box" |
---|
534 | <%=!isEnumeration ? "checked" : ""%> |
---|
535 | onclick="interfaceOnClick()" |
---|
536 | >text box |
---|
537 | <input type="radio" name="interface" value="list" |
---|
538 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
539 | onclick="interfaceOnClick()" |
---|
540 | >selection list |
---|
541 | <input type="radio" name="interface" value="buttons" |
---|
542 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
543 | onclick="interfaceOnClick()" |
---|
544 | >radiobuttons/checkboxes |
---|
545 | </td> |
---|
546 | </tr> |
---|
547 | <tr> |
---|
548 | <td class="prompt">Input box width</td> |
---|
549 | <td> |
---|
550 | <input <%=clazz%> type="text" name="width" |
---|
551 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" |
---|
552 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
553 | </td> |
---|
554 | </tr> |
---|
555 | <tr valign="top"> |
---|
556 | <td class="prompt">Values</td> |
---|
557 | <td nowrap> |
---|
558 | <% |
---|
559 | String values = annotationType == null ? "" : |
---|
560 | Values.getString((List<Date>)annotationType.getValues(), "\n", true, dateFormatter); |
---|
561 | %> |
---|
562 | <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual" |
---|
563 | ><%=HTML.encodeTags(values)%></textarea> |
---|
564 | <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" title="Edit in larger window"><base:icon image="zoom.gif" /></a><br> |
---|
565 | One date value (<%=htmlDateFormat%>) per line |
---|
566 | </td> |
---|
567 | </tr> |
---|
568 | <% |
---|
569 | } |
---|
570 | else if (valueType == Type.STRING) |
---|
571 | { |
---|
572 | Integer maxLength = annotationType == null ? null : annotationType.getMaxLength(); |
---|
573 | boolean isEnumeration = annotationType == null ? |
---|
574 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
575 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
576 | %> |
---|
577 | <tr> |
---|
578 | <td class="prompt">Interface</td> |
---|
579 | <td> |
---|
580 | <input type="radio" name="interface" value="box" |
---|
581 | <%=!isEnumeration ? "checked" : ""%> |
---|
582 | onclick="interfaceOnClick()" |
---|
583 | >text box |
---|
584 | <input type="radio" name="interface" value="list" |
---|
585 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
586 | onclick="interfaceOnClick()" |
---|
587 | >selection list |
---|
588 | <input type="radio" name="interface" value="buttons" |
---|
589 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
590 | onclick="interfaceOnClick()" |
---|
591 | >radiobuttons/checkboxes |
---|
592 | </td> |
---|
593 | </tr> |
---|
594 | <tr> |
---|
595 | <td class="prompt">Max length</td> |
---|
596 | <td> |
---|
597 | <input <%=clazz%> type="text" name="maxLength" |
---|
598 | value="<%=maxLength == null ? "" : maxLength.toString()%>" |
---|
599 | size="12" maxlength="3" onkeypress="return Numbers.integerOnly(event)"> (1-255) |
---|
600 | </td> |
---|
601 | </tr> |
---|
602 | <tr> |
---|
603 | <td class="prompt">Input box width</td> |
---|
604 | <td> |
---|
605 | <input <%=clazz%> type="text" name="width" |
---|
606 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" |
---|
607 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
608 | </td> |
---|
609 | </tr> |
---|
610 | <tr valign="top"> |
---|
611 | <td class="prompt">Values</td> |
---|
612 | <td nowrap> |
---|
613 | <% |
---|
614 | String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); |
---|
615 | %> |
---|
616 | <textarea <%=clazz%> rows="10" cols="40" name="values" wrap="virtual"><%=HTML.encodeTags(values)%></textarea> |
---|
617 | <a href="javascript:Main.zoom('Values', 'annotationtype', 'values')" |
---|
618 | title="Edit in larger window"><base:icon image="zoom.gif" /></a><br> |
---|
619 | One enumeration value per line |
---|
620 | </td> |
---|
621 | </tr> |
---|
622 | <% |
---|
623 | } |
---|
624 | else if (valueType == Type.TEXT) |
---|
625 | { |
---|
626 | %> |
---|
627 | <tr> |
---|
628 | <td class="prompt">Input box width</td> |
---|
629 | <td> |
---|
630 | <input <%=clazz%> type="text" name="width" |
---|
631 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" |
---|
632 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
633 | </td> |
---|
634 | </tr> |
---|
635 | <tr> |
---|
636 | <td class="prompt">Input box height</td> |
---|
637 | <td> |
---|
638 | <input <%=clazz%> type="text" name="width" |
---|
639 | value="<%=annotationType == null ? "" : annotationType.getHeight()%>" |
---|
640 | size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)"> |
---|
641 | </td> |
---|
642 | </tr> |
---|
643 | <% |
---|
644 | } |
---|
645 | %> |
---|
646 | </table> |
---|
647 | </t:tab> |
---|
648 | |
---|
649 | <t:tab id="items" title="Item types" validate="validateItemTypes()" helpid="annotationtype.edit.items"> |
---|
650 | <table border=0 cellspacing=0 cellpadding=2> |
---|
651 | <tr> |
---|
652 | <td> |
---|
653 | <b>Enabled for</b><br> |
---|
654 | <select name="enabled" multiple size="14" style="width: 12em;" |
---|
655 | ondblclick="moveBetween(document.forms['annotationType'].enabled, document.forms['annotationType'].disabled)"> |
---|
656 | </select> |
---|
657 | </td> |
---|
658 | |
---|
659 | <td> |
---|
660 | <br> |
---|
661 | <base:button |
---|
662 | onclick="moveBetween(document.forms['annotationType'].disabled, document.forms['annotationType'].enabled)" |
---|
663 | title="<img src='../../images/move_left.gif' alt='' style='vertical-align: middle;'>" |
---|
664 | tooltip="Enable the annotation type for the selected item(s)" |
---|
665 | /><p> |
---|
666 | <base:button |
---|
667 | onclick="moveBetween(document.forms['annotationType'].enabled, document.forms['annotationType'].disabled)" |
---|
668 | title="<img src='../../images/move_right.gif' alt='' style='vertical-align: middle;'>" |
---|
669 | tooltip="Disable the annotation type for the selected item(s)" |
---|
670 | /> |
---|
671 | <br> |
---|
672 | </td> |
---|
673 | |
---|
674 | <td> |
---|
675 | <b>Disabled for</b><br> |
---|
676 | <select name="disabled" multiple size="14" style="width: 12em;" |
---|
677 | ondblclick="moveBetween(document.forms['annotationType'].disabled, document.forms['annotationType'].enabled)"> |
---|
678 | </select> |
---|
679 | </td> |
---|
680 | </tr> |
---|
681 | </table> |
---|
682 | </t:tab> |
---|
683 | |
---|
684 | <t:tab id="categories" title="Categories" validate="validateCategories()" |
---|
685 | helpid="annotationtype.edit.categories"> |
---|
686 | <table > |
---|
687 | <tr valign="top"> |
---|
688 | <td> |
---|
689 | <b>Categories</b><br> |
---|
690 | <select name="categories" size="14" multiple |
---|
691 | style="width: 15em;"> |
---|
692 | </select> |
---|
693 | <input type="hidden" name="removeCategories" value=""> |
---|
694 | <input type="hidden" name="addCategories" value=""> |
---|
695 | </td> |
---|
696 | <td> |
---|
697 | <br> |
---|
698 | <table width="150"> |
---|
699 | <tr><td><base:button |
---|
700 | onclick="addCategoriesOnClick()" |
---|
701 | title="Add categories…" |
---|
702 | tooltip="Add categories to this annotation type" |
---|
703 | /></td></tr> |
---|
704 | <tr><td><base:button |
---|
705 | onclick="removeOnClick()" |
---|
706 | title="Remove" |
---|
707 | tooltip="Remove the selected categories from this annotation type" |
---|
708 | /></td></tr> |
---|
709 | </table> |
---|
710 | </td> |
---|
711 | </tr> |
---|
712 | </table> |
---|
713 | </t:tab> |
---|
714 | |
---|
715 | </t:tabcontrol> |
---|
716 | |
---|
717 | <table align="center"> |
---|
718 | <tr> |
---|
719 | <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td> |
---|
720 | <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td> |
---|
721 | </tr> |
---|
722 | </table> |
---|
723 | </form> |
---|
724 | </base:body> |
---|
725 | </base:page> |
---|
726 | <% |
---|
727 | } |
---|
728 | finally |
---|
729 | { |
---|
730 | if (dc != null) dc.close(); |
---|
731 | } |
---|
732 | %> |
---|