1 | <%-- $Id: edit_annotationtype.jsp 6728 2015-02-13 08:00:01Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2005 Nicklas Nordborg |
---|
4 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
---|
5 | |
---|
6 | This file is part of BASE - BioArray Software Environment. |
---|
7 | Available at http://base.thep.lu.se/ |
---|
8 | |
---|
9 | BASE is free software; you can redistribute it and/or |
---|
10 | modify it under the terms of the GNU General Public License |
---|
11 | as published by the Free Software Foundation; either version 3 |
---|
12 | of the License, or (at your option) any later version. |
---|
13 | |
---|
14 | BASE is distributed in the hope that it will be useful, |
---|
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
17 | GNU General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU General Public License |
---|
20 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
21 | ------------------------------------------------------------------ |
---|
22 | |
---|
23 | |
---|
24 | @author Nicklas |
---|
25 | @version 2.0 |
---|
26 | --%> |
---|
27 | <%@ page pageEncoding="UTF-8" session="false" |
---|
28 | import="net.sf.basedb.core.SessionControl" |
---|
29 | import="net.sf.basedb.core.DbControl" |
---|
30 | import="net.sf.basedb.core.Item" |
---|
31 | import="net.sf.basedb.core.Type" |
---|
32 | import="net.sf.basedb.core.ItemContext" |
---|
33 | import="net.sf.basedb.core.Include" |
---|
34 | import="net.sf.basedb.core.Permission" |
---|
35 | import="net.sf.basedb.core.AnnotationType" |
---|
36 | import="net.sf.basedb.core.AnnotationTypeCategory" |
---|
37 | import="net.sf.basedb.core.Quantity" |
---|
38 | import="net.sf.basedb.core.Unit" |
---|
39 | import="net.sf.basedb.core.SystemItems" |
---|
40 | import="net.sf.basedb.core.Metadata" |
---|
41 | import="net.sf.basedb.core.ItemQuery" |
---|
42 | import="net.sf.basedb.core.ItemResultList" |
---|
43 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
44 | import="net.sf.basedb.core.query.Orders" |
---|
45 | import="net.sf.basedb.core.query.Hql" |
---|
46 | import="net.sf.basedb.clients.web.Base" |
---|
47 | import="net.sf.basedb.clients.web.util.HTML" |
---|
48 | import="net.sf.basedb.util.Values" |
---|
49 | import="net.sf.basedb.util.formatter.Formatter" |
---|
50 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
51 | import="net.sf.basedb.clients.web.formatter.FormatterSettings" |
---|
52 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
53 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
54 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
55 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
56 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
57 | import="net.sf.basedb.util.json.NameableConverter" |
---|
58 | import="net.sf.basedb.util.json.JsonUtil" |
---|
59 | import="net.sf.basedb.util.json.JsonConverter" |
---|
60 | import="java.util.Date" |
---|
61 | import="java.util.Set" |
---|
62 | import="java.util.List" |
---|
63 | import="java.util.Collections" |
---|
64 | import="org.json.simple.JSONObject" |
---|
65 | import="org.json.simple.JSONArray" |
---|
66 | %> |
---|
67 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
68 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
69 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
70 | <% |
---|
71 | final Item itemType = Item.ANNOTATIONTYPE; |
---|
72 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
73 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
74 | final int itemId = cc.getId(); |
---|
75 | final String ID = sc.getId(); |
---|
76 | final float scale = Base.getScale(sc); |
---|
77 | final DbControl dc = sc.newDbControl(); |
---|
78 | try |
---|
79 | { |
---|
80 | String title = null; |
---|
81 | AnnotationType annotationType = null; |
---|
82 | ItemQuery<AnnotationTypeCategory> categoryQuery = null; |
---|
83 | ItemQuery<Unit> unitQuery = null; |
---|
84 | ItemQuery<Unit> usableUnitsQuery = null; |
---|
85 | Set<Item> enabledForItems = null; |
---|
86 | Type valueType = null; |
---|
87 | boolean readCurrentQuantity = true; |
---|
88 | int currentQuantityId = 0; |
---|
89 | boolean readCurrentUnit = true; |
---|
90 | int currentUnitId = 0; |
---|
91 | |
---|
92 | if (itemId == 0) |
---|
93 | { |
---|
94 | title = "Create annotation type"; |
---|
95 | valueType = Type.valueOf(request.getParameter("value_type")); |
---|
96 | if (valueType.isNumerical()) unitQuery = Unit.getQuery(); |
---|
97 | cc.removeObject("item"); |
---|
98 | int itemCode = Values.getInt(cc.getPropertyValue("@itemTypes"), -1); |
---|
99 | if (itemCode > 0) |
---|
100 | { |
---|
101 | enabledForItems = Collections.singleton(Item.fromValue(itemCode)); |
---|
102 | } |
---|
103 | else |
---|
104 | { |
---|
105 | enabledForItems = Collections.emptySet(); |
---|
106 | } |
---|
107 | } |
---|
108 | else |
---|
109 | { |
---|
110 | annotationType = AnnotationType.getById(dc, itemId); |
---|
111 | annotationType.checkPermission(Permission.WRITE); |
---|
112 | valueType = annotationType.getValueType(); |
---|
113 | enabledForItems = annotationType.getEnabledItems(); |
---|
114 | |
---|
115 | cc.setObject("item", annotationType); |
---|
116 | title = "Edit annotation type -- " + HTML.encodeTags(annotationType.getName()); |
---|
117 | categoryQuery = annotationType.getCategories(); |
---|
118 | categoryQuery.include(Include.ALL); |
---|
119 | categoryQuery.order(Orders.asc(Hql.property("name"))); |
---|
120 | |
---|
121 | usableUnitsQuery = annotationType.getUsableUnits(); |
---|
122 | usableUnitsQuery.include(Include.ALL); |
---|
123 | usableUnitsQuery.order(Orders.asc(Hql.property("referenceFactor"))); |
---|
124 | usableUnitsQuery.order(Orders.asc(Hql.property("name"))); |
---|
125 | |
---|
126 | try |
---|
127 | { |
---|
128 | if (annotationType.getValueType().isNumerical()) |
---|
129 | { |
---|
130 | Quantity quantity = annotationType.getQuantity(); |
---|
131 | if (quantity != null) |
---|
132 | { |
---|
133 | currentQuantityId = quantity.getId(); |
---|
134 | unitQuery = quantity.getUnits(); |
---|
135 | } |
---|
136 | else |
---|
137 | { |
---|
138 | unitQuery = Unit.getQuery(); |
---|
139 | } |
---|
140 | Unit unit = annotationType.getDefaultUnit(); |
---|
141 | if (unit != null) currentUnitId = unit.getId(); |
---|
142 | } |
---|
143 | } |
---|
144 | catch (PermissionDeniedException ex) |
---|
145 | { |
---|
146 | readCurrentQuantity = false; |
---|
147 | readCurrentUnit = false; |
---|
148 | } |
---|
149 | } |
---|
150 | |
---|
151 | JSONArray jsonQuantities = new JSONArray(); |
---|
152 | if (unitQuery != null) |
---|
153 | { |
---|
154 | unitQuery.include(Include.ALL); |
---|
155 | unitQuery.order(Orders.asc(Hql.property("quantity.name"))); |
---|
156 | unitQuery.order(Orders.asc(Hql.property("referenceFactor"))); |
---|
157 | unitQuery.order(Orders.asc(Hql.property("name"))); |
---|
158 | |
---|
159 | Quantity prevQuantity = null; |
---|
160 | JSONArray jsonUnits = null; |
---|
161 | for (Unit unit : unitQuery.list(dc)) |
---|
162 | { |
---|
163 | Quantity quantity = unit.getQuantity(); |
---|
164 | if (!quantity.equals(prevQuantity)) |
---|
165 | { |
---|
166 | prevQuantity = quantity; |
---|
167 | JSONObject jsonQuantity = new JSONObject(); |
---|
168 | jsonUnits = new JSONArray(); |
---|
169 | jsonQuantity.put("id", quantity.getId()); |
---|
170 | jsonQuantity.put("name", quantity.getName()); |
---|
171 | jsonQuantity.put("units", jsonUnits); |
---|
172 | |
---|
173 | jsonQuantities.add(jsonQuantity); |
---|
174 | } |
---|
175 | |
---|
176 | JSONObject jsonUnit = new JSONObject(); |
---|
177 | jsonUnit.put("id", unit.getId()); |
---|
178 | jsonUnit.put("name", unit.getName()); |
---|
179 | jsonUnit.put("symbol", unit.getDisplaySymbol()); |
---|
180 | jsonUnits.add(jsonUnit); |
---|
181 | } |
---|
182 | } |
---|
183 | |
---|
184 | JSONObject jsonUsableUnits = new JSONObject(); |
---|
185 | jsonUsableUnits.put("itemType", "UNIT"); |
---|
186 | if (usableUnitsQuery != null) |
---|
187 | { |
---|
188 | jsonUsableUnits.put("items", JsonUtil.toArray(usableUnitsQuery.iterate(dc), new NameableConverter<Unit>() |
---|
189 | { |
---|
190 | protected void setMore(JSONObject json, Unit unit) |
---|
191 | { |
---|
192 | json.put("name", unit.getName() + " [ " + unit.getDisplaySymbol() + " ]"); |
---|
193 | } |
---|
194 | })); |
---|
195 | } |
---|
196 | |
---|
197 | JSONObject jsonCategories = new JSONObject(); |
---|
198 | jsonCategories.put("itemType", "ANNOTATIONTYPECATEGORY"); |
---|
199 | if (categoryQuery != null) |
---|
200 | { |
---|
201 | jsonCategories.put("items", JsonUtil.toArray(categoryQuery.iterate(dc), new NameableConverter())); |
---|
202 | } |
---|
203 | |
---|
204 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
205 | String dateFormat = FormatterSettings.getDateFormat(sc); |
---|
206 | String jsDateFormat = HTML.javaScriptEncode(dateFormat); |
---|
207 | String htmlDateFormat = HTML.encodeTags(dateFormat); |
---|
208 | |
---|
209 | Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc); |
---|
210 | String dateTimeFormat = FormatterSettings.getDateTimeFormat(sc); |
---|
211 | String jsDateTimeFormat = HTML.javaScriptEncode(dateTimeFormat); |
---|
212 | String htmlDateTimeFormat = HTML.encodeTags(dateTimeFormat); |
---|
213 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), annotationType); |
---|
214 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
215 | %> |
---|
216 | <base:page type="popup" title="<%=title%>" id="edit-page"> |
---|
217 | <base:head scripts="tabcontrol-2.js,linkitems-2.js,~annotationtypes.js" styles="tabcontrol.css"> |
---|
218 | <ext:scripts context="<%=jspContext%>" /> |
---|
219 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
220 | </base:head> |
---|
221 | <base:body> |
---|
222 | <h1><%=title%> <base:help tabcontrol="settings" /></h1> |
---|
223 | |
---|
224 | <div id="page-data" class="datacontainer" |
---|
225 | data-current-quantity="<%=currentQuantityId%>" |
---|
226 | data-current-unit="<%=currentUnitId%>" |
---|
227 | data-units="<%=HTML.encodeTags(jsonQuantities.toJSONString())%>" |
---|
228 | ></div> |
---|
229 | |
---|
230 | <form action="index.jsp?ID=<%=ID%>" method="post" name="annotationType"> |
---|
231 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
232 | <input type="hidden" name="value_type" value="<%=valueType.name()%>"> |
---|
233 | |
---|
234 | <t:tabcontrol id="settings" |
---|
235 | subclass="content dialogtabcontrol" |
---|
236 | position="bottom" remember="<%=annotationType != null%>" |
---|
237 | extensions="<%=invoker%>"> |
---|
238 | <t:tab id="info" title="Annotation type" helpid="annotationtype.edit"> |
---|
239 | <table class="fullform input100"> |
---|
240 | <tr> |
---|
241 | <th>Value type</th> |
---|
242 | <td><%=valueType%></td> |
---|
243 | <td></td> |
---|
244 | </tr> |
---|
245 | <tr> |
---|
246 | <th>Name</th> |
---|
247 | <td><input class="text required auto-init" data-auto-init="<%=annotationType == null ? "focus-select" : "focus" %>" |
---|
248 | type="text" name="name" |
---|
249 | value="<%=HTML.encodeTags(annotationType == null ? |
---|
250 | Values.getString(cc.getPropertyValue("name"), "New "+valueType+" annotation type") : annotationType.getName())%>" |
---|
251 | maxlength="<%=AnnotationType.MAX_NAME_LENGTH%>"></td> |
---|
252 | <td></td> |
---|
253 | </tr> |
---|
254 | <tr> |
---|
255 | <th>External ID</th> |
---|
256 | <td><input class="text" type="text" name="external_id" |
---|
257 | value="<%=HTML.encodeTags(annotationType == null ? |
---|
258 | Values.getString(cc.getPropertyValue("externalId"), "") : annotationType.getExternalId())%>" |
---|
259 | maxlength="<%=AnnotationType.MAX_EXTERNAL_ID_LENGTH%>"></td> |
---|
260 | <td></td> |
---|
261 | </tr> |
---|
262 | <tr> |
---|
263 | <th>Multiplicity</th> |
---|
264 | <td><input class="text auto-init" type="text" name="multiplicity" id="multiplicity" |
---|
265 | data-auto-init="integer-only" |
---|
266 | value="<%=annotationType == null ? Values.getString(cc.getPropertyValue("multiplicity"), "1") : |
---|
267 | Integer.toString(annotationType.getMultiplicity())%>" style="width: 15em;" |
---|
268 | maxlength="10"> |
---|
269 | 0 or empty = unlimited |
---|
270 | </td> |
---|
271 | <td></td> |
---|
272 | </tr> |
---|
273 | <tr class="<%=valueType == Type.TEXT ? "big" : ""%>"> |
---|
274 | <th>Default value</th> |
---|
275 | <td> |
---|
276 | <% |
---|
277 | String defaultValue = annotationType == null ? cc.getPropertyValue("defaultValue") : annotationType.getDefaultValue(); |
---|
278 | boolean hasZoom = false; |
---|
279 | if (valueType == Type.INT || valueType == Type.LONG) |
---|
280 | { |
---|
281 | %> |
---|
282 | <input class="text auto-init" type="text" name="defaultValue" id="defaultValue" |
---|
283 | data-auto-init="integer-only" |
---|
284 | value="<%=HTML.encodeTags(defaultValue)%>" style="width: 15em;" |
---|
285 | maxlength="20"> |
---|
286 | <% |
---|
287 | } |
---|
288 | else if (valueType == Type.FLOAT || valueType == Type.DOUBLE) |
---|
289 | { |
---|
290 | %> |
---|
291 | <input class="text auto-init" type="text" name="defaultValue" id="defaultValue" |
---|
292 | data-auto-init="number-only" |
---|
293 | value="<%=HTML.encodeTags(defaultValue)%>" style="width: 15em;" |
---|
294 | maxlength="20"> |
---|
295 | <% |
---|
296 | } |
---|
297 | else if (valueType == Type.BOOLEAN) |
---|
298 | { |
---|
299 | boolean booleanDefaultValue = Values.getBoolean(defaultValue); |
---|
300 | %> |
---|
301 | <input type="radio" name="defaultValue" id="defaultTrue" value="true" |
---|
302 | <%=booleanDefaultValue ? "checked" : ""%> |
---|
303 | ><label for="defaultTrue">true</label> |
---|
304 | <input type="radio" name="defaultValue" id="defaultFalse" value="false" |
---|
305 | <%=booleanDefaultValue ? "" : "checked"%> |
---|
306 | ><label for="defaultFalse">false</label> |
---|
307 | <% |
---|
308 | } |
---|
309 | else if (valueType == Type.DATE) |
---|
310 | { |
---|
311 | %> |
---|
312 | <table> |
---|
313 | <tr> |
---|
314 | <td> |
---|
315 | <input class="text" type="text" name="defaultValue" id="defaultValue" |
---|
316 | value="<%=HTML.encodeTags(defaultValue)%>" style="width: 15em;" |
---|
317 | maxlength="20" title="Enter date in format: <%=htmlDateFormat%>"> |
---|
318 | </td> |
---|
319 | <td> |
---|
320 | <base:calendar textarea="defaultValue" title="Default value" /> |
---|
321 | </td> |
---|
322 | </tr> |
---|
323 | </table> |
---|
324 | <% |
---|
325 | } |
---|
326 | else if (valueType == Type.TIMESTAMP) |
---|
327 | { |
---|
328 | %> |
---|
329 | <table> |
---|
330 | <tr> |
---|
331 | <td> |
---|
332 | <input class="text" type="text" name="defaultValue" id="defaultValue" |
---|
333 | value="<%=HTML.encodeTags(defaultValue)%>" style="width: 15em;" |
---|
334 | maxlength="30" title="Enter date in format: <%=htmlDateTimeFormat%>"> |
---|
335 | </td> |
---|
336 | <td> |
---|
337 | <base:calendar textarea="defaultValue" title="Default value" |
---|
338 | data-use-time="1" tooltip="Select a date and time from a calendar" /> |
---|
339 | </td> |
---|
340 | </tr> |
---|
341 | </table> |
---|
342 | <% |
---|
343 | } |
---|
344 | else if (valueType == Type.STRING) |
---|
345 | { |
---|
346 | %> |
---|
347 | <input class="text" type="text" name="defaultValue" id="defaultValue" |
---|
348 | value="<%=HTML.encodeTags(defaultValue)%>" |
---|
349 | maxlength="<%=AnnotationType.MAX_DEFAULT_VALUE_LENGTH%>"> |
---|
350 | <% |
---|
351 | } |
---|
352 | else if (valueType == Type.TEXT) |
---|
353 | { |
---|
354 | hasZoom = true; |
---|
355 | %> |
---|
356 | <textarea class="text" rows="4" name="defaultValue" id="defaultValue" |
---|
357 | ><%=HTML.encodeTags(defaultValue)%></textarea> |
---|
358 | <% |
---|
359 | } |
---|
360 | %> |
---|
361 | </td> |
---|
362 | <td> |
---|
363 | <% |
---|
364 | if (hasZoom) |
---|
365 | { |
---|
366 | %> |
---|
367 | <base:zoom textarea="defaultValue" title="Default value" /> |
---|
368 | <% |
---|
369 | } |
---|
370 | %> |
---|
371 | </td> |
---|
372 | </tr> |
---|
373 | <tr> |
---|
374 | <th><label for="required_for_miame">Required for MIAME</label></th> |
---|
375 | <td><input type="checkbox" name="required_for_miame" id="required_for_miame" value="1" |
---|
376 | <%=(annotationType != null && annotationType.isRequiredForMiame()) || |
---|
377 | (annotationType == null && Values.getBoolean(cc.getPropertyValue("requiredForMiame"))) ? "checked" : ""%> |
---|
378 | > |
---|
379 | </td> |
---|
380 | <td></td> |
---|
381 | </tr> |
---|
382 | <tr> |
---|
383 | <th><label for="is_protocol_parameter">Protocol parameter</label></th> |
---|
384 | <td><input type="checkbox" name="is_protocol_parameter" id="is_protocol_parameter" value="1" |
---|
385 | <%=(annotationType != null && annotationType.isProtocolParameter()) || |
---|
386 | (annotationType == null && Values.getBoolean(cc.getPropertyValue("protocolParameter"))) ? "checked" : ""%> |
---|
387 | > |
---|
388 | </td> |
---|
389 | <td></td> |
---|
390 | </tr> |
---|
391 | <tr> |
---|
392 | <th><label for="disable_log">Disable change log</label></th> |
---|
393 | <td><input type="checkbox" name="disable_log" id="disable_log" value="1" |
---|
394 | <%=(annotationType != null && annotationType.getDisableLogOfValues()) || |
---|
395 | (annotationType == null && Values.getBoolean(cc.getPropertyValue("disableLogOfValues"))) ? "checked" : ""%> |
---|
396 | > |
---|
397 | </td> |
---|
398 | <td></td> |
---|
399 | </tr> |
---|
400 | <tr> |
---|
401 | <th><label for="disable_inheritance">Disable inheritance</label></th> |
---|
402 | <td><input type="checkbox" name="disable_inheritance" id="disable_inheritance" value="1" |
---|
403 | <%=(annotationType != null && annotationType.getDisableInheritance()) || |
---|
404 | (annotationType == null && Values.getBoolean(cc.getPropertyValue("disableInheritance"))) ? "checked" : ""%> |
---|
405 | > |
---|
406 | </td> |
---|
407 | <td></td> |
---|
408 | </tr> |
---|
409 | <tr class="dynamic"> |
---|
410 | <th>Description</th> |
---|
411 | <td> |
---|
412 | <textarea class="text" rows="4" name="description" id="description" |
---|
413 | ><%=HTML.encodeTags(annotationType == null ? cc.getPropertyValue("description") : annotationType.getDescription())%></textarea> |
---|
414 | </td> |
---|
415 | <td style="width: 20px;"> |
---|
416 | <base:zoom textarea="description" title="Description" /> |
---|
417 | </td> |
---|
418 | </tr> |
---|
419 | </table> |
---|
420 | </t:tab> |
---|
421 | |
---|
422 | <t:tab id="options" title="Options" helpid="annotationtype.edit.options"> |
---|
423 | <% |
---|
424 | if (valueType == Type.INT || valueType == Type.LONG) |
---|
425 | { |
---|
426 | Long minValue = annotationType == null ? null : annotationType.getMinValueLong(); |
---|
427 | Long maxValue = annotationType == null ? null : annotationType.getMaxValueLong(); |
---|
428 | boolean isEnumeration = annotationType == null ? |
---|
429 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
430 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
431 | %> |
---|
432 | <table class="fullform input100"> |
---|
433 | <tr> |
---|
434 | <th>Interface</th> |
---|
435 | <td> |
---|
436 | <input type="radio" name="interface" id="interfaceBox" value="box" |
---|
437 | <%=!isEnumeration ? "checked" : ""%> |
---|
438 | ><label for="interfaceBox">text box</label> |
---|
439 | <input type="radio" name="interface" id="interfaceList" value="list" |
---|
440 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
441 | ><label for="interfaceList">selection list</label> |
---|
442 | <input type="radio" name="interface" id="interfaceButtons" value="buttons" |
---|
443 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
444 | ><label for="interfaceButtons">radiobuttons/checkboxes</label> |
---|
445 | </td> |
---|
446 | <td></td> |
---|
447 | </tr> |
---|
448 | <tr> |
---|
449 | <th>Min value</th> |
---|
450 | <td> |
---|
451 | <input class="text auto-init" type="text" name="minValue" |
---|
452 | data-auto-init="integer-only" |
---|
453 | value="<%=minValue == null ? "" : minValue.toString()%>" style="width: 15em;" |
---|
454 | maxlength="20"> |
---|
455 | empty = no limit |
---|
456 | </td> |
---|
457 | <td></td> |
---|
458 | </tr> |
---|
459 | <tr> |
---|
460 | <th>Max value</th> |
---|
461 | <td> |
---|
462 | <input class="text auto-init" type="text" name="maxValue" |
---|
463 | data-auto-init="integer-only" |
---|
464 | value="<%=maxValue == null ? "" : maxValue.toString()%>" style="width: 15em;" |
---|
465 | maxlength="20"> |
---|
466 | empty = no limit |
---|
467 | </td> |
---|
468 | <td></td> |
---|
469 | </tr> |
---|
470 | <tr> |
---|
471 | <th>Input box width</th> |
---|
472 | <td> |
---|
473 | <input class="text auto-init" type="text" name="width" style="width: 15em;" |
---|
474 | data-auto-init="integer-only" |
---|
475 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" |
---|
476 | maxlength="10"> |
---|
477 | </td> |
---|
478 | <td></td> |
---|
479 | </tr> |
---|
480 | <tr class="dynamic"> |
---|
481 | <th>Values</th> |
---|
482 | <td> |
---|
483 | <% |
---|
484 | String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); |
---|
485 | %> |
---|
486 | <textarea class="text auto-init" rows="10" name="values" id="values" |
---|
487 | data-auto-init="integer-only"><%=HTML.encodeTags(values)%></textarea><br> |
---|
488 | </td> |
---|
489 | <td style="width: 20px;"> |
---|
490 | <base:zoom textarea="values" title="Values" /> |
---|
491 | </td> |
---|
492 | </tr> |
---|
493 | <tr> |
---|
494 | <th class="subprompt"></th> |
---|
495 | <td>One enumeration value per line</td> |
---|
496 | <td></td> |
---|
497 | </tr> |
---|
498 | </table> |
---|
499 | <% |
---|
500 | } |
---|
501 | else if (valueType == Type.FLOAT || valueType == Type.DOUBLE) |
---|
502 | { |
---|
503 | Double minValue = annotationType == null ? null : annotationType.getMinValueDouble(); |
---|
504 | Double maxValue = annotationType == null ? null : annotationType.getMaxValueDouble(); |
---|
505 | boolean isEnumeration = annotationType == null ? |
---|
506 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
507 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
508 | %> |
---|
509 | <table class="fullform input100"> |
---|
510 | <tr> |
---|
511 | <th>Interface</th> |
---|
512 | <td> |
---|
513 | <input type="radio" name="interface" id="interfaceBox" value="box" |
---|
514 | <%=!isEnumeration ? "checked" : ""%> |
---|
515 | ><label for="interfaceBox">text box</label> |
---|
516 | <input type="radio" name="interface" id="interfaceList" value="list" |
---|
517 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
518 | ><label for="interfaceList">selection list</label> |
---|
519 | <input type="radio" name="interface" id="interfaceButtons" value="buttons" |
---|
520 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
521 | ><label for="interfaceButtons">radiobuttons/checkboxes</label> |
---|
522 | </td> |
---|
523 | <td></td> |
---|
524 | </tr> |
---|
525 | <tr> |
---|
526 | <th>Min value</th> |
---|
527 | <td> |
---|
528 | <input class="text auto-init" type="text" name="minValue" |
---|
529 | data-auto-init="number-only" |
---|
530 | value="<%=minValue == null ? "" : minValue.toString()%>" style="width: 15em;" |
---|
531 | maxlength="20"> |
---|
532 | empty = no limit |
---|
533 | </td> |
---|
534 | <td></td> |
---|
535 | </tr> |
---|
536 | <tr> |
---|
537 | <th>Max value</th> |
---|
538 | <td> |
---|
539 | <input class="text auto-init" type="text" name="maxValue" |
---|
540 | data-auto-init="number-only" |
---|
541 | value="<%=maxValue == null ? "" : maxValue.toString()%>" style="width: 15em;" |
---|
542 | maxlength="20"> |
---|
543 | empty = no limit |
---|
544 | </td> |
---|
545 | <td></td> |
---|
546 | </tr> |
---|
547 | <tr> |
---|
548 | <th>Input box width</th> |
---|
549 | <td> |
---|
550 | <input class="text auto-init" type="text" name="width" |
---|
551 | data-auto-init="integer-only" |
---|
552 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" style="width: 15em;" |
---|
553 | maxlength="10"> |
---|
554 | </td> |
---|
555 | <td></td> |
---|
556 | </tr> |
---|
557 | <tr class="dynamic"> |
---|
558 | <th>Values</th> |
---|
559 | <td> |
---|
560 | <% |
---|
561 | String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); |
---|
562 | %> |
---|
563 | <textarea class="text auto-init" rows="10" name="values" id="values" |
---|
564 | data-auto-init="integer-only"><%=HTML.encodeTags(values)%></textarea> |
---|
565 | </td> |
---|
566 | <td style="width: 20px;"> |
---|
567 | <base:zoom textarea="values" title="Values" /> |
---|
568 | </td> |
---|
569 | </tr> |
---|
570 | <tr> |
---|
571 | <th class="subprompt"></th> |
---|
572 | <td>One enumeration value per line</td> |
---|
573 | <td></td> |
---|
574 | </tr> |
---|
575 | </table> |
---|
576 | <% |
---|
577 | } |
---|
578 | else if (valueType == Type.BOOLEAN) |
---|
579 | { |
---|
580 | %> |
---|
581 | <div style="border: 1px solid transparent;"> |
---|
582 | <div class="messagecontainer help"> |
---|
583 | No options for this type. |
---|
584 | </div> |
---|
585 | </div> |
---|
586 | <% |
---|
587 | } |
---|
588 | else if (valueType == Type.DATE) |
---|
589 | { |
---|
590 | boolean isEnumeration = annotationType == null ? |
---|
591 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
592 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
593 | %> |
---|
594 | <table class="fullform input100"> |
---|
595 | <tr> |
---|
596 | <th>Interface</th> |
---|
597 | <td> |
---|
598 | <input type="radio" name="interface" id="interfaceBox" value="box" |
---|
599 | <%=!isEnumeration ? "checked" : ""%> |
---|
600 | ><label for="interfaceBox">text box</label> |
---|
601 | <input type="radio" name="interface" id="interfaceList" value="list" |
---|
602 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
603 | ><label for="interfaceList">selection list</label> |
---|
604 | <input type="radio" name="interface" id="interfaceButtons" value="buttons" |
---|
605 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
606 | ><label for="interfaceButtons">radiobuttons/checkboxes</label> |
---|
607 | </td> |
---|
608 | <td></td> |
---|
609 | </tr> |
---|
610 | <tr> |
---|
611 | <th>Input box width</th> |
---|
612 | <td> |
---|
613 | <input class="text auto-init" type="text" name="width" |
---|
614 | data-auto-init="integer-only" |
---|
615 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" style="width: 15em;" |
---|
616 | maxlength="10"> |
---|
617 | </td> |
---|
618 | <td></td> |
---|
619 | </tr> |
---|
620 | <tr class="dynamic"> |
---|
621 | <th>Values</th> |
---|
622 | <td> |
---|
623 | <% |
---|
624 | String values = annotationType == null ? "" : |
---|
625 | Values.getString((List<Date>)annotationType.getValues(), "\n", true, dateFormatter); |
---|
626 | %> |
---|
627 | <textarea class="text" rows="10" name="values" id="values" |
---|
628 | ><%=HTML.encodeTags(values)%></textarea> |
---|
629 | </td> |
---|
630 | <td style="width: 20px;"> |
---|
631 | <base:zoom textarea="values" title="Values" /> |
---|
632 | </td> |
---|
633 | </tr> |
---|
634 | <tr> |
---|
635 | <th class="subprompt"></th> |
---|
636 | <td>One date value (<%=htmlDateFormat%>) per line</td> |
---|
637 | <td></td> |
---|
638 | </tr> |
---|
639 | </table> |
---|
640 | <% |
---|
641 | } |
---|
642 | else if (valueType == Type.TIMESTAMP) |
---|
643 | { |
---|
644 | %> |
---|
645 | <table class="fullform input100"> |
---|
646 | <tr> |
---|
647 | <th>Input box width</th> |
---|
648 | <td> |
---|
649 | <input class="text auto-init" type="text" name="width" |
---|
650 | data-auto-init="integer-only" |
---|
651 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" style="width: 15em;" |
---|
652 | maxlength="10"> |
---|
653 | </td> |
---|
654 | </tr> |
---|
655 | <tr class="dynamic"> |
---|
656 | <th class="subprompt"></th> |
---|
657 | <td></td> |
---|
658 | </tr> |
---|
659 | </table> |
---|
660 | <% |
---|
661 | } |
---|
662 | else if (valueType == Type.STRING) |
---|
663 | { |
---|
664 | Integer maxLength = annotationType == null ? null : annotationType.getMaxLength(); |
---|
665 | boolean isEnumeration = annotationType == null ? |
---|
666 | Values.getBoolean(cc.getPropertyValue("enumeration")) : annotationType.isEnumeration(); |
---|
667 | boolean displayAsList = annotationType == null ? false : annotationType.getDisplayAsList(); |
---|
668 | %> |
---|
669 | <table class="fullform input100"> |
---|
670 | <tr> |
---|
671 | <th>Interface</th> |
---|
672 | <td> |
---|
673 | <input type="radio" name="interface" id="interfaceBox" value="box" |
---|
674 | <%=!isEnumeration ? "checked" : ""%> |
---|
675 | ><label for="interfaceBox">text box</label> |
---|
676 | <input type="radio" name="interface" id="interfaceList" value="list" |
---|
677 | <%=isEnumeration && displayAsList ? "checked" : ""%> |
---|
678 | ><label for="interfaceList">selection list</label> |
---|
679 | <input type="radio" name="interface" id="interfaceButtons" value="buttons" |
---|
680 | <%=isEnumeration && !displayAsList ? "checked" : ""%> |
---|
681 | ><label for="interfaceButtons">radiobuttons/checkboxes</label> |
---|
682 | </td> |
---|
683 | <td></td> |
---|
684 | </tr> |
---|
685 | <tr> |
---|
686 | <th>Max length</th> |
---|
687 | <td> |
---|
688 | <input class="text auto-init" type="text" name="maxLength" |
---|
689 | data-auto-init="integer-only" |
---|
690 | value="<%=maxLength == null ? "" : maxLength.toString()%>" style="width: 5em;" |
---|
691 | maxlength="3"> (1-255) |
---|
692 | </td> |
---|
693 | <td></td> |
---|
694 | </tr> |
---|
695 | <tr> |
---|
696 | <th>Input box width</th> |
---|
697 | <td> |
---|
698 | <input class="text auto-init" type="text" name="width" |
---|
699 | data-auto-init="integer-only" |
---|
700 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" style="width: 15em;" |
---|
701 | maxlength="10"> |
---|
702 | </td> |
---|
703 | <td></td> |
---|
704 | </tr> |
---|
705 | <tr class="dynamic"> |
---|
706 | <th>Values</th> |
---|
707 | <td> |
---|
708 | <% |
---|
709 | String values = annotationType == null ? "" : Values.getString(annotationType.getValues(), "\n", true); |
---|
710 | %> |
---|
711 | <textarea class="text" rows="10" name="values" id="values"><%=HTML.encodeTags(values)%></textarea> |
---|
712 | </td> |
---|
713 | <td style="width: 20px;"> |
---|
714 | <base:zoom textarea="values" title="Values" /> |
---|
715 | </td> |
---|
716 | </tr> |
---|
717 | <tr> |
---|
718 | <th class="subprompt"></th> |
---|
719 | <td>One enumeration value per line</td> |
---|
720 | <td></td> |
---|
721 | </tr> |
---|
722 | </table> |
---|
723 | <% |
---|
724 | } |
---|
725 | else if (valueType == Type.TEXT) |
---|
726 | { |
---|
727 | %> |
---|
728 | <table class="fullform input100"> |
---|
729 | <tr> |
---|
730 | <th>Input box width</th> |
---|
731 | <td> |
---|
732 | <input class="text auto-init" type="text" name="width" |
---|
733 | data-auto-init="integer-only" |
---|
734 | value="<%=annotationType == null ? "" : annotationType.getWidth()%>" style="width: 15em;" |
---|
735 | maxlength="10"> |
---|
736 | </td> |
---|
737 | </tr> |
---|
738 | <tr> |
---|
739 | <th>Input box height</th> |
---|
740 | <td> |
---|
741 | <input class="text auto-init" type="text" name="width" |
---|
742 | data-auto-init="integer-only" |
---|
743 | value="<%=annotationType == null ? "" : annotationType.getHeight()%>" style="width: 15em;" |
---|
744 | maxlength="10"> |
---|
745 | </td> |
---|
746 | </tr> |
---|
747 | <tr class="dynamic"> |
---|
748 | <th></th> |
---|
749 | <td></td> |
---|
750 | </tr> |
---|
751 | </table> |
---|
752 | <% |
---|
753 | } |
---|
754 | %> |
---|
755 | </t:tab> |
---|
756 | |
---|
757 | <t:tab id="items" title="Item types" helpid="annotationtype.edit.items"> |
---|
758 | <div style="padding: 2px;"> |
---|
759 | <table style="width: 100%;"> |
---|
760 | <tr> |
---|
761 | <td style="width: 50%;"> |
---|
762 | <b>Enabled for</b><br> |
---|
763 | <select name="enabled" id="enabled" multiple size="14" style="width: calc(100% - 10px);" |
---|
764 | data-to-id="disabled" data-is-sorted="1"> |
---|
765 | <% |
---|
766 | for (Item item : enabledForItems) |
---|
767 | { |
---|
768 | %> |
---|
769 | <option value="<%=item.name()%>"><%=item.toString()%> |
---|
770 | <% |
---|
771 | } |
---|
772 | %> |
---|
773 | </select> |
---|
774 | </td> |
---|
775 | <td style="width: 20px; padding: 2px;"> |
---|
776 | <base:buttongroup vertical="true"> |
---|
777 | <base:button |
---|
778 | id="btnMoveLeft" |
---|
779 | data-from-id="disabled" |
---|
780 | data-to-id="enabled" |
---|
781 | image="move_left.png" |
---|
782 | tooltip="Enable the annotation type for the selected item(s)" |
---|
783 | subclass="square" |
---|
784 | /> |
---|
785 | <base:button |
---|
786 | id="btnMoveRight" |
---|
787 | data-from-id="enabled" |
---|
788 | data-to-id="disabled" |
---|
789 | image="move_right.png" |
---|
790 | subclass="square" |
---|
791 | tooltip="Disable the annotation type for the selected item(s)" |
---|
792 | /> |
---|
793 | </base:buttongroup> |
---|
794 | </td> |
---|
795 | <td style="width: 50%;"> |
---|
796 | <b>Disabled for</b><br> |
---|
797 | <select name="disabled" id="disabled" multiple size="14" style="width: calc(100% - 10px);" |
---|
798 | data-to-id="enabled" data-is-sorted="1"> |
---|
799 | <% |
---|
800 | for (Item item : Metadata.getAnnotatableItems()) |
---|
801 | { |
---|
802 | if (!enabledForItems.contains(item)) |
---|
803 | { |
---|
804 | %> |
---|
805 | <option value="<%=item.name()%>"><%=item.toString()%> |
---|
806 | <% |
---|
807 | } |
---|
808 | } |
---|
809 | %> |
---|
810 | </select> |
---|
811 | </td> |
---|
812 | </tr> |
---|
813 | </table> |
---|
814 | </div> |
---|
815 | </t:tab> |
---|
816 | |
---|
817 | <t:tab id="units" title="Units" |
---|
818 | visible="<%=valueType.isNumerical()%>" helpid="annotationtype.edit.units"> |
---|
819 | |
---|
820 | <table class="fullform input100"> |
---|
821 | <tr> |
---|
822 | <th>Quantity</th> |
---|
823 | <td> |
---|
824 | <select name="quantity_id" id="quantity_id" |
---|
825 | <%=!readCurrentQuantity || (annotationType != null && currentQuantityId != 0) ? |
---|
826 | "disabled readonly class=\"disabled\"" : "class=\"unchangeable selectionlist\""%>> |
---|
827 | <option value="">- do not use units - |
---|
828 | </select> |
---|
829 | </td> |
---|
830 | </tr> |
---|
831 | <tr> |
---|
832 | <th>Default unit</th> |
---|
833 | <td> |
---|
834 | <select name="unit_id" |
---|
835 | <%=!readCurrentQuantity ? "disabled readonly class=\"disabled\"" : "class=\"selectionlist\""%>> |
---|
836 | </select> |
---|
837 | </td> |
---|
838 | </tr> |
---|
839 | <% |
---|
840 | if (annotationType != null) |
---|
841 | { |
---|
842 | %> |
---|
843 | <tr> |
---|
844 | <th class="subprompt"></th> |
---|
845 | <td> |
---|
846 | <div class="messagecontainer help"> |
---|
847 | Changing the default unit triggers a conversion of existing annotation values |
---|
848 | to the new unit. This may result in loss of precision due to rounding or |
---|
849 | truncation. |
---|
850 | </div> |
---|
851 | </td> |
---|
852 | </tr> |
---|
853 | <% |
---|
854 | } |
---|
855 | %> |
---|
856 | <tr class="dynamic"> |
---|
857 | <th></th> |
---|
858 | <td> |
---|
859 | <table style="width: 100%;"> |
---|
860 | <tr> |
---|
861 | <th>Use units</th> |
---|
862 | <td></td> |
---|
863 | <th>Do not use</th> |
---|
864 | </tr> |
---|
865 | <tr> |
---|
866 | <td style="width: 50%;"> |
---|
867 | <select name="usableUnits" id="usableUnits" |
---|
868 | class="auto-init" |
---|
869 | data-auto-init="link-container" |
---|
870 | data-initial-items="[<%=HTML.encodeTags(jsonUsableUnits.toJSONString()) %>]" |
---|
871 | data-remove-to="allUnits" |
---|
872 | size="10" multiple style="width: calc(100% - 10px);" |
---|
873 | title="If no unit is selected, all units can be used" |
---|
874 | > |
---|
875 | </select> |
---|
876 | </td> |
---|
877 | <td style="width: 20px; padding: 2px;"> |
---|
878 | <base:buttongroup vertical="true"> |
---|
879 | <base:button |
---|
880 | id="btnAddUsableUnits" |
---|
881 | image="move_left.png" |
---|
882 | subclass="square" |
---|
883 | tooltip="Enable the annotation type for the selected unit(s)" |
---|
884 | /> |
---|
885 | <base:button |
---|
886 | subclass="square auto-init" |
---|
887 | data-auto-init="remove-link" |
---|
888 | data-list-id="usableUnits" |
---|
889 | data-remove-to="allUnits" |
---|
890 | id="btnRemoveUsableUnits" |
---|
891 | image="move_right.png" |
---|
892 | tooltip="Disable the annotation type for the selected unit(s)" |
---|
893 | /> |
---|
894 | </base:buttongroup> |
---|
895 | </td> |
---|
896 | <td style="width: 50%;"> |
---|
897 | <select name="allUnits" id="allUnits" size="10" multiple style="width: calc(100% - 10px);"> |
---|
898 | </select> |
---|
899 | </td> |
---|
900 | </tr> |
---|
901 | </table> |
---|
902 | </td> |
---|
903 | </table> |
---|
904 | </t:tab> |
---|
905 | |
---|
906 | <t:tab id="categories" title="Categories" |
---|
907 | helpid="annotationtype.edit.categories"> |
---|
908 | <table class="fullform input100"> |
---|
909 | <tr class="dynamic"> |
---|
910 | <th>Categories</th> |
---|
911 | <td> |
---|
912 | <div class="selectionlist"> |
---|
913 | <table> |
---|
914 | <tr> |
---|
915 | <td> |
---|
916 | <select name="categories" id="categories" |
---|
917 | class="auto-init" |
---|
918 | data-auto-init="link-container" |
---|
919 | data-initial-items="[<%=HTML.encodeTags(jsonCategories.toJSONString()) %>]" |
---|
920 | size="14" multiple> |
---|
921 | </select> |
---|
922 | </td> |
---|
923 | <td style="vertical-align: top;"> |
---|
924 | <base:buttongroup vertical="true"> |
---|
925 | <base:button |
---|
926 | subclass="leftaligned auto-init" |
---|
927 | data-auto-init="add-link" |
---|
928 | data-list-id="categories" |
---|
929 | data-item-type="ANNOTATIONTYPECATEGORY" |
---|
930 | style="width: 14em;" |
---|
931 | title="Add categories…" |
---|
932 | tooltip="Add categories to this annotation type" |
---|
933 | /> |
---|
934 | <base:button |
---|
935 | subclass="leftaligned auto-init" |
---|
936 | data-auto-init="remove-link" |
---|
937 | data-list-id="categories" |
---|
938 | style="width: 14em;" |
---|
939 | title="Remove" |
---|
940 | tooltip="Remove the selected categories from this annotation type" |
---|
941 | /> |
---|
942 | </base:buttongroup> |
---|
943 | </td> |
---|
944 | </tr> |
---|
945 | </table> |
---|
946 | </div> |
---|
947 | </td> |
---|
948 | </tr> |
---|
949 | </table> |
---|
950 | </t:tab> |
---|
951 | </t:tabcontrol> |
---|
952 | </form> |
---|
953 | |
---|
954 | <div class="legend"> |
---|
955 | <base:icon image="required.png" />= required information<br> |
---|
956 | <base:icon image="unchangeable.png" />= can't be changed later |
---|
957 | </div> |
---|
958 | |
---|
959 | <base:buttongroup subclass="dialogbuttons"> |
---|
960 | <base:button id="btnSave" title="Save" /> |
---|
961 | <base:button id="close" title="Cancel" /> |
---|
962 | </base:buttongroup> |
---|
963 | </base:body> |
---|
964 | </base:page> |
---|
965 | <% |
---|
966 | } |
---|
967 | finally |
---|
968 | { |
---|
969 | if (dc != null) dc.close(); |
---|
970 | } |
---|
971 | %> |
---|