1 | <%-- $Id: list_plates.jsp 5674 2011-06-27 12:29:52Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | Copyright (C) 2007 Johan Enell, Martin Svensson |
---|
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 | @author Nicklas |
---|
24 | @version 2.0 |
---|
25 | --%> |
---|
26 | <%@ page pageEncoding="UTF-8" session="false" |
---|
27 | import="net.sf.basedb.core.SessionControl" |
---|
28 | import="net.sf.basedb.core.DbControl" |
---|
29 | import="net.sf.basedb.core.Item" |
---|
30 | import="net.sf.basedb.core.AnnotationType" |
---|
31 | import="net.sf.basedb.core.AnnotationSet" |
---|
32 | import="net.sf.basedb.core.Annotation" |
---|
33 | import="net.sf.basedb.core.Plate" |
---|
34 | import="net.sf.basedb.core.PlateGeometry" |
---|
35 | import="net.sf.basedb.core.ItemQuery" |
---|
36 | import="net.sf.basedb.core.Include" |
---|
37 | import="net.sf.basedb.core.Type" |
---|
38 | import="net.sf.basedb.core.ItemResultIterator" |
---|
39 | import="net.sf.basedb.core.ItemResultList" |
---|
40 | import="net.sf.basedb.core.ItemContext" |
---|
41 | import="net.sf.basedb.core.Nameable" |
---|
42 | import="net.sf.basedb.core.Permission" |
---|
43 | import="net.sf.basedb.core.PluginDefinition" |
---|
44 | import="net.sf.basedb.core.query.Hql" |
---|
45 | import="net.sf.basedb.core.query.Restrictions" |
---|
46 | import="net.sf.basedb.core.query.Expressions" |
---|
47 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
48 | import="net.sf.basedb.core.plugin.Plugin" |
---|
49 | import="net.sf.basedb.core.query.Orders" |
---|
50 | import="net.sf.basedb.core.query.Hql" |
---|
51 | import="net.sf.basedb.util.Enumeration" |
---|
52 | import="net.sf.basedb.util.ShareableUtil" |
---|
53 | import="net.sf.basedb.clients.web.Base" |
---|
54 | import="net.sf.basedb.clients.web.ModeInfo" |
---|
55 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
56 | import="net.sf.basedb.clients.web.util.HTML" |
---|
57 | import="net.sf.basedb.util.formatter.Formatter" |
---|
58 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
59 | import="net.sf.basedb.util.Values" |
---|
60 | import="net.sf.basedb.util.formatter.Formatter" |
---|
61 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
62 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
63 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
64 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
65 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
66 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
67 | import="java.util.Date" |
---|
68 | import="java.util.Iterator" |
---|
69 | import="java.util.List" |
---|
70 | import="java.util.Map" |
---|
71 | %> |
---|
72 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
73 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
74 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
75 | <%! |
---|
76 | private static final Item itemType = Item.PLATE; |
---|
77 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.LIST); |
---|
78 | %> |
---|
79 | <% |
---|
80 | final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.DENIED, itemType); |
---|
81 | final String ID = sc.getId(); |
---|
82 | final boolean createPermission = sc.hasPermission(Permission.CREATE, itemType); |
---|
83 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
84 | |
---|
85 | final ModeInfo mode = ModeInfo.get(request.getParameter("mode")); |
---|
86 | final String callback = request.getParameter("callback"); |
---|
87 | final String title = mode.generateTitle("plate", "plates"); |
---|
88 | final DbControl dc = sc.newDbControl(); |
---|
89 | ItemResultIterator<Plate> plates = null; |
---|
90 | ItemResultList<AnnotationType> annotationTypes = null; |
---|
91 | try |
---|
92 | { |
---|
93 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
94 | final ItemQuery<AnnotationType> annotationTypeQuery = Base.getAnnotationTypesQuery(itemType); |
---|
95 | |
---|
96 | final ItemQuery<PlateGeometry> geometryQuery = PlateGeometry.getQuery(); |
---|
97 | geometryQuery.order(Orders.asc(Hql.property("name"))); |
---|
98 | geometryQuery.setCacheResult(true); |
---|
99 | |
---|
100 | // Query for parent plates of the current plate |
---|
101 | final ItemQuery<Plate> parentQuery = Plate.getQuery(); |
---|
102 | parentQuery.include(cc.getInclude()); |
---|
103 | parentQuery.join(Hql.innerJoin("children", "c")); |
---|
104 | parentQuery.restrict(Restrictions.eq(Hql.alias("c"), Expressions.parameter("plate"))); |
---|
105 | parentQuery.order(Orders.asc(Hql.property("name"))); |
---|
106 | |
---|
107 | // Query for child plates of the current plate |
---|
108 | final ItemQuery<Plate> childQuery = Plate.getQuery(); |
---|
109 | childQuery.include(cc.getInclude()); |
---|
110 | childQuery.join(Hql.innerJoin("parents", "p")); |
---|
111 | childQuery.restrict(Restrictions.eq(Hql.index("p", null), Expressions.parameter("plate"))); |
---|
112 | childQuery.order(Orders.asc(Hql.property("name"))); |
---|
113 | |
---|
114 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
115 | annotationTypes = annotationTypeQuery.list(dc); |
---|
116 | try |
---|
117 | { |
---|
118 | final ItemQuery<Plate> query = Base.getConfiguredQuery(dc, cc, true, Plate.getQuery(), mode); |
---|
119 | plates = query.iterate(dc); |
---|
120 | } |
---|
121 | catch (Throwable t) |
---|
122 | { |
---|
123 | cc.setMessage(t.getMessage()); |
---|
124 | t.printStackTrace(); |
---|
125 | } |
---|
126 | int numListed = 0; |
---|
127 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, null); |
---|
128 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
129 | %> |
---|
130 | <base:page title="<%=title==null ? "Plates" : title%>" type="<%=mode.getPageType()%>"> |
---|
131 | <base:head scripts="menu.js,table.js" styles="menu.css,table.css"> |
---|
132 | <ext:scripts context="<%=jspContext%>" /> |
---|
133 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
134 | <script language="JavaScript"> |
---|
135 | var submitPage = 'index.jsp'; |
---|
136 | var formId = 'plates'; |
---|
137 | function newItem() |
---|
138 | { |
---|
139 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', 0, true); |
---|
140 | } |
---|
141 | function editItem(itemId) |
---|
142 | { |
---|
143 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, true); |
---|
144 | } |
---|
145 | function viewItem(itemId) |
---|
146 | { |
---|
147 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', itemId, false); |
---|
148 | } |
---|
149 | function itemOnClick(evt, itemId) |
---|
150 | { |
---|
151 | Table.itemOnClick(formId, evt, itemId, '<%=mode.getName()%>', viewItem, editItem, returnSelected); |
---|
152 | } |
---|
153 | function deleteItems() |
---|
154 | { |
---|
155 | var frm = document.forms[formId]; |
---|
156 | if (Forms.numChecked(frm) == 0) |
---|
157 | { |
---|
158 | alert('Please select at least one item in the list'); |
---|
159 | return; |
---|
160 | } |
---|
161 | frm.action = submitPage; |
---|
162 | frm.cmd.value = 'DeleteItems'; |
---|
163 | frm.submit(); |
---|
164 | } |
---|
165 | function restoreItems() |
---|
166 | { |
---|
167 | var frm = document.forms[formId]; |
---|
168 | if (Forms.numChecked(frm) == 0) |
---|
169 | { |
---|
170 | alert('Please select at least one item in the list'); |
---|
171 | return; |
---|
172 | } |
---|
173 | frm.action = submitPage; |
---|
174 | frm.cmd.value = 'RestoreItems'; |
---|
175 | frm.submit(); |
---|
176 | } |
---|
177 | function deleteItemPermanently(itemId) |
---|
178 | { |
---|
179 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', itemId); |
---|
180 | } |
---|
181 | function setOwner() |
---|
182 | { |
---|
183 | Table.setOwnerOfItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'SetOwnerOfItems'); |
---|
184 | } |
---|
185 | function shareItem(itemId) |
---|
186 | { |
---|
187 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id='+itemId, 'SharePlates', 600, 400); |
---|
188 | } |
---|
189 | function shareItems() |
---|
190 | { |
---|
191 | Table.shareItems(submitPage, '<%=ID%>', formId, '<%=itemType.name()%>', 'ShareItems'); |
---|
192 | } |
---|
193 | function configureColumns() |
---|
194 | { |
---|
195 | Table.configureColumns('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>'); |
---|
196 | } |
---|
197 | function runPlugin(cmd) |
---|
198 | { |
---|
199 | Table.submitToPopup(formId, cmd, 740, 540); |
---|
200 | } |
---|
201 | function returnSelected() |
---|
202 | { |
---|
203 | Table.returnSelected(formId, <%=callback != null ? "window.opener."+callback : "null" %>); |
---|
204 | window.close(); |
---|
205 | } |
---|
206 | function presetOnChange() |
---|
207 | { |
---|
208 | Table.presetOnChange('<%=ID%>', formId, '<%=itemType.name()%>', '<%=(String)cc.getObject("defaultColumns")%>'); |
---|
209 | } |
---|
210 | function mergePlates() |
---|
211 | { |
---|
212 | Main.openPopup('merge_plates.jsp?ID=<%=ID%>', 'MergePlates', 600, 400); |
---|
213 | } |
---|
214 | </script> |
---|
215 | </base:head> |
---|
216 | |
---|
217 | <base:body> |
---|
218 | <% |
---|
219 | if (cc.getMessage() != null) |
---|
220 | { |
---|
221 | %> |
---|
222 | <div class="error"><%=cc.getMessage()%></div> |
---|
223 | <% |
---|
224 | cc.setMessage(null); |
---|
225 | } |
---|
226 | %> |
---|
227 | <tbl:table |
---|
228 | id="plates" |
---|
229 | clazz="itemlist" |
---|
230 | columns="<%=cc.getSetting("columns")%>" |
---|
231 | sortby="<%=cc.getSortProperty()%>" |
---|
232 | direction="<%=cc.getSortDirection()%>" |
---|
233 | title="<%=title%>" |
---|
234 | action="index.jsp" |
---|
235 | sc="<%=sc%>" |
---|
236 | item="<%=itemType%>" |
---|
237 | > |
---|
238 | <tbl:hidden |
---|
239 | name="mode" |
---|
240 | value="<%=mode.getName()%>" |
---|
241 | /> |
---|
242 | <tbl:hidden |
---|
243 | name="callback" |
---|
244 | value="<%=callback%>" |
---|
245 | skip="<%=callback == null%>" |
---|
246 | /> |
---|
247 | <tbl:columndef |
---|
248 | id="name" |
---|
249 | property="name" |
---|
250 | datatype="string" |
---|
251 | title="Name" |
---|
252 | sortable="true" |
---|
253 | filterable="true" |
---|
254 | exportable="true" |
---|
255 | show="always" |
---|
256 | /> |
---|
257 | <tbl:columndef |
---|
258 | id="id" |
---|
259 | clazz="uniquecol" |
---|
260 | property="id" |
---|
261 | datatype="int" |
---|
262 | title="ID" |
---|
263 | sortable="true" |
---|
264 | filterable="true" |
---|
265 | exportable="true" |
---|
266 | /> |
---|
267 | <tbl:columndef |
---|
268 | id="entryDate" |
---|
269 | property="entryDate" |
---|
270 | datatype="date" |
---|
271 | title="Registered" |
---|
272 | sortable="true" |
---|
273 | filterable="true" |
---|
274 | exportable="true" |
---|
275 | formatter="<%=dateFormatter%>" |
---|
276 | /> |
---|
277 | <tbl:columndef |
---|
278 | id="barcode" |
---|
279 | property="barcode" |
---|
280 | datatype="string" |
---|
281 | title="Barcode" |
---|
282 | sortable="true" |
---|
283 | filterable="true" |
---|
284 | exportable="true" |
---|
285 | /> |
---|
286 | <tbl:columndef |
---|
287 | id="destroyed" |
---|
288 | property="destroyed" |
---|
289 | datatype="boolean" |
---|
290 | title="Destroyed" |
---|
291 | sortable="true" |
---|
292 | filterable="true" |
---|
293 | exportable="true" |
---|
294 | /> |
---|
295 | <tbl:columndef |
---|
296 | id="plateType" |
---|
297 | property="plateType.name" |
---|
298 | datatype="string" |
---|
299 | title="Type" |
---|
300 | sortable="true" |
---|
301 | filterable="true" |
---|
302 | exportable="true" |
---|
303 | /> |
---|
304 | <% |
---|
305 | Enumeration<String, String> geometries = new Enumeration<String, String>(); |
---|
306 | ItemResultList<PlateGeometry> plateGeometries = geometryQuery.list(dc); |
---|
307 | for (PlateGeometry pg : plateGeometries) |
---|
308 | { |
---|
309 | geometries.add(Integer.toString(pg.getId()), HTML.encodeTags(pg.getName())); |
---|
310 | } |
---|
311 | %> |
---|
312 | <tbl:columndef |
---|
313 | id="plateGeometry" |
---|
314 | property="plateType.plateGeometry" |
---|
315 | sortproperty="plateType.plateGeometry.name" |
---|
316 | exportproperty="plateType.plateGeometry.name" |
---|
317 | datatype="int" |
---|
318 | enumeration="<%=geometries%>" |
---|
319 | title="Geometry" |
---|
320 | sortable="true" |
---|
321 | filterable="true" |
---|
322 | exportable="true" |
---|
323 | /> |
---|
324 | <tbl:columndef |
---|
325 | id="plateMapping" |
---|
326 | property="plateMapping.name" |
---|
327 | datatype="string" |
---|
328 | title="Plate mapping" |
---|
329 | sortable="true" |
---|
330 | filterable="true" |
---|
331 | exportable="true" |
---|
332 | /> |
---|
333 | <tbl:columndef |
---|
334 | id="parents" |
---|
335 | title="Parents" |
---|
336 | property="&parentSet(name)" |
---|
337 | datatype="string" |
---|
338 | filterable="true" |
---|
339 | /> |
---|
340 | <tbl:columndef |
---|
341 | id="children" |
---|
342 | title="Children" |
---|
343 | property="&children(name)" |
---|
344 | datatype="string" |
---|
345 | filterable="true" |
---|
346 | /> |
---|
347 | <tbl:columndef |
---|
348 | id="owner" |
---|
349 | property="owner.name" |
---|
350 | datatype="string" |
---|
351 | title="Owner" |
---|
352 | sortable="true" |
---|
353 | filterable="true" |
---|
354 | exportable="true" |
---|
355 | /> |
---|
356 | <tbl:columndef |
---|
357 | id="description" |
---|
358 | property="description" |
---|
359 | datatype="string" |
---|
360 | title="Description" |
---|
361 | sortable="true" |
---|
362 | filterable="true" |
---|
363 | exportable="true" |
---|
364 | /> |
---|
365 | <% |
---|
366 | for (AnnotationType at : annotationTypes) |
---|
367 | { |
---|
368 | Formatter formatter = FormatterFactory.getTypeFormatter(sc, at.getValueType()); |
---|
369 | Enumeration<String, String> annotationEnum = null; |
---|
370 | if (at.isEnumeration()) |
---|
371 | { |
---|
372 | annotationEnum = new Enumeration<String, String>(); |
---|
373 | List<?> values = at.getValues(); |
---|
374 | for (Object value : values) |
---|
375 | { |
---|
376 | String encoded = formatter.format(value); |
---|
377 | annotationEnum.add(encoded, encoded); |
---|
378 | } |
---|
379 | } |
---|
380 | %> |
---|
381 | <tbl:columndef |
---|
382 | id="<%="at"+at.getId()%>" |
---|
383 | title="<%=HTML.encodeTags(at.getName())+" [A]"%>" |
---|
384 | property="<%="#"+at.getId()%>" |
---|
385 | annotation="true" |
---|
386 | datatype="<%=at.getValueType().getStringValue()%>" |
---|
387 | enumeration="<%=annotationEnum%>" |
---|
388 | smartenum="<%=at.getDisplayAsList() %>" |
---|
389 | sortable="false" |
---|
390 | filterable="true" |
---|
391 | exportable="true" |
---|
392 | formatter="<%=formatter%>" |
---|
393 | unit="<%=at.getDefaultUnit()%>" |
---|
394 | /> |
---|
395 | <% |
---|
396 | } |
---|
397 | %> |
---|
398 | <tbl:columndef |
---|
399 | id="permission" |
---|
400 | title="Permission" |
---|
401 | /> |
---|
402 | <tbl:columndef |
---|
403 | id="sharedTo" |
---|
404 | title="Shared to" |
---|
405 | filterable="true" |
---|
406 | filterproperty="!sharedTo.name" |
---|
407 | datatype="string" |
---|
408 | /> |
---|
409 | <tbl:toolbar |
---|
410 | visible="<%=mode.hasToolbar()%>" |
---|
411 | > |
---|
412 | <tbl:button |
---|
413 | disabled="<%=createPermission ? false : true%>" |
---|
414 | image="<%=createPermission ? "new.gif" : "new_disabled.gif"%>" |
---|
415 | onclick="mergePlates()" |
---|
416 | title="Merge…" |
---|
417 | tooltip="<%=createPermission ? "Create new plates by merging other plates" : "You do not have permission to create plates"%>" |
---|
418 | /> |
---|
419 | <tbl:button |
---|
420 | image="delete.gif" |
---|
421 | onclick="deleteItems()" |
---|
422 | title="Delete" |
---|
423 | tooltip="Delete the selected items" |
---|
424 | /> |
---|
425 | <tbl:button |
---|
426 | image="restore.gif" |
---|
427 | onclick="restoreItems()" |
---|
428 | title="Restore" |
---|
429 | tooltip="Restore the selected (deleted) items" |
---|
430 | /> |
---|
431 | <tbl:button |
---|
432 | image="share.gif" |
---|
433 | onclick="shareItems()" |
---|
434 | title="Share…" |
---|
435 | tooltip="Share the selected items" |
---|
436 | /> |
---|
437 | <tbl:button |
---|
438 | image="take_ownership.png" |
---|
439 | onclick="setOwner()" |
---|
440 | title="Set owner…" |
---|
441 | tooltip="Change owner of the selected items" |
---|
442 | /> |
---|
443 | <tbl:button |
---|
444 | image="columns.gif" |
---|
445 | onclick="configureColumns()" |
---|
446 | title="Columns…" |
---|
447 | tooltip="Show, hide and re-order columns" |
---|
448 | /> |
---|
449 | <tbl:button |
---|
450 | image="import.gif" |
---|
451 | onclick="runPlugin('ImportItems')" |
---|
452 | title="Import…" |
---|
453 | tooltip="Import data" |
---|
454 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
455 | /> |
---|
456 | <tbl:button |
---|
457 | image="export.gif" |
---|
458 | onclick="runPlugin('ExportItems')" |
---|
459 | title="Export…" |
---|
460 | tooltip="Export data" |
---|
461 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
462 | /> |
---|
463 | <tbl:button |
---|
464 | image="runplugin.gif" |
---|
465 | onclick="runPlugin('RunListPlugin')" |
---|
466 | title="Run plugin…" |
---|
467 | tooltip="Run a plugin" |
---|
468 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
469 | /> |
---|
470 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
471 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
472 | </tbl:toolbar> |
---|
473 | <tbl:navigator |
---|
474 | page="<%=cc.getPage()%>" |
---|
475 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
476 | totalrows="<%=plates == null ? 0 : plates.getTotalCount()%>" |
---|
477 | visible="<%=mode.hasNavigator()%>" |
---|
478 | /> |
---|
479 | <tbl:data> |
---|
480 | <tbl:columns> |
---|
481 | <tbl:presetselector |
---|
482 | clazz="columnheader" |
---|
483 | colspan="3" |
---|
484 | onchange="presetOnChange()" |
---|
485 | /> |
---|
486 | </tbl:columns> |
---|
487 | |
---|
488 | <tr> |
---|
489 | <tbl:header |
---|
490 | clazz="index" |
---|
491 | > </tbl:header> |
---|
492 | <tbl:header |
---|
493 | clazz="check" |
---|
494 | visible="<%=mode.hasCheck()%>" |
---|
495 | ><base:icon |
---|
496 | image="check_uncheck.gif" |
---|
497 | tooltip="Check/uncheck all" |
---|
498 | onclick="Forms.checkUncheck(document.forms[formId])" style="align: left;" |
---|
499 | /></tbl:header> |
---|
500 | <tbl:header |
---|
501 | clazz="check" |
---|
502 | visible="<%=mode.hasRadio()%>" |
---|
503 | > </tbl:header> |
---|
504 | <tbl:header |
---|
505 | clazz="icons" |
---|
506 | visible="<%=mode.hasIcons()%>" |
---|
507 | > </tbl:header> |
---|
508 | <tbl:propertyfilter /> |
---|
509 | </tr> |
---|
510 | |
---|
511 | <tbl:rows> |
---|
512 | <% |
---|
513 | int index = cc.getPage()*cc.getRowsPerPage(); |
---|
514 | int selectedItemId = cc.getId(); |
---|
515 | if (plates != null) |
---|
516 | { |
---|
517 | while (plates.hasNext()) |
---|
518 | { |
---|
519 | Plate item = plates.next(); |
---|
520 | int itemId = item.getId(); |
---|
521 | String openSharePopup = "shareItem("+itemId+")"; |
---|
522 | String deletePermanently = "deleteItemPermanently("+itemId+")"; |
---|
523 | boolean deletePermission = item.hasPermission(Permission.DELETE); |
---|
524 | boolean sharePermission = item.hasPermission(Permission.SET_PERMISSION); |
---|
525 | boolean writePermission = item.hasPermission(Permission.WRITE); |
---|
526 | String tooltip = mode.isSelectionMode() ? |
---|
527 | "Select this item" : "View this item" + (writePermission ? " (use CTRL, ALT or SHIFT to edit)" : ""); |
---|
528 | String name = HTML.encodeTags(item.getName()); |
---|
529 | index++; |
---|
530 | numListed++; |
---|
531 | %> |
---|
532 | <tbl:row> |
---|
533 | <tbl:header |
---|
534 | clazz="index" |
---|
535 | ><%=index%></tbl:header> |
---|
536 | <tbl:header |
---|
537 | clazz="check" |
---|
538 | visible="<%=mode.hasCheck()%>" |
---|
539 | ><input |
---|
540 | type="checkbox" |
---|
541 | name="<%=itemId%>" |
---|
542 | value="<%=itemId%>" |
---|
543 | title="<%=name%>" |
---|
544 | <%=cc.getSelected().contains(itemId) ? "checked" : ""%> |
---|
545 | ></tbl:header> |
---|
546 | <tbl:header |
---|
547 | clazz="check" |
---|
548 | visible="<%=mode.hasRadio()%>" |
---|
549 | ><input |
---|
550 | type="radio" |
---|
551 | name="item_id" |
---|
552 | value="<%=itemId%>" |
---|
553 | title="<%=name%>" |
---|
554 | <%=selectedItemId == itemId ? "checked" : ""%> |
---|
555 | ></tbl:header> |
---|
556 | <tbl:header |
---|
557 | clazz="icons" |
---|
558 | visible="<%=mode.hasIcons()%>" |
---|
559 | ><base:icon |
---|
560 | image="<%=deletePermission ? "deleted.gif" : "deleted_disabled.gif"%>" |
---|
561 | onclick="<%=deletePermission ? deletePermanently : null%>" |
---|
562 | tooltip="This item has been scheduled for deletion" |
---|
563 | visible="<%=item.isRemoved()%>" |
---|
564 | /><base:icon |
---|
565 | image="<%=sharePermission ? "shared.gif" : "shared_disabled.gif"%>" |
---|
566 | onclick="<%=sharePermission ? openSharePopup : null%>" |
---|
567 | tooltip="This item is shared to other users, groups and/or projects" |
---|
568 | visible="<%=item.isShared()%>" |
---|
569 | /> </tbl:header> |
---|
570 | <tbl:cell column="name"><div class="link" |
---|
571 | onclick="itemOnClick(<%=writePermission ? "event" : null%>, <%=itemId%>)" |
---|
572 | title="<%=tooltip%>"><%=name%></div></tbl:cell> |
---|
573 | <tbl:cell column="id"><%=item.getId()%></tbl:cell> |
---|
574 | <tbl:cell column="entryDate" value="<%=item.getEntryDate()%>" /> |
---|
575 | <tbl:cell column="barcode"><%=HTML.encodeTags(item.getBarcode())%></tbl:cell> |
---|
576 | <tbl:cell column="destroyed"><%=item.isDestroyed()%></tbl:cell> |
---|
577 | <tbl:cell column="owner" |
---|
578 | ><base:propertyvalue |
---|
579 | item="<%=item%>" |
---|
580 | property="owner" |
---|
581 | enableEditLink="<%=mode.hasEditLink()%>" |
---|
582 | enablePropertyLink="<%=mode.hasPropertyLink()%>" |
---|
583 | /></tbl:cell> |
---|
584 | <tbl:cell column="plateType" |
---|
585 | ><base:propertyvalue |
---|
586 | item="<%=item%>" |
---|
587 | property="plateType" |
---|
588 | enableEditLink="<%=mode.hasEditLink()%>" |
---|
589 | enablePropertyLink="<%=mode.hasPropertyLink()%>" |
---|
590 | /></tbl:cell> |
---|
591 | <tbl:cell column="plateGeometry" |
---|
592 | ><base:propertyvalue |
---|
593 | item="<%=item%>" |
---|
594 | property="plateType.plateGeometry" |
---|
595 | enableEditLink="<%=mode.hasEditLink()%>" |
---|
596 | enablePropertyLink="<%=mode.hasPropertyLink()%>" |
---|
597 | /></tbl:cell> |
---|
598 | <tbl:cell column="plateMapping" |
---|
599 | ><base:propertyvalue |
---|
600 | item="<%=item%>" |
---|
601 | property="plateMapping" |
---|
602 | enableEditLink="<%=mode.hasEditLink()%>" |
---|
603 | enablePropertyLink="<%=mode.hasPropertyLink()%>" |
---|
604 | /></tbl:cell> |
---|
605 | <tbl:cell column="parents"> |
---|
606 | <% |
---|
607 | parentQuery.setParameter("plate", itemId, Type.INT); |
---|
608 | try |
---|
609 | { |
---|
610 | String separator = ""; |
---|
611 | for (Plate p : parentQuery.list(dc)) |
---|
612 | { |
---|
613 | out.write(separator); |
---|
614 | if (mode.hasPropertyLink()) |
---|
615 | { |
---|
616 | out.write(Base.getLinkedName(ID, p, false, mode.hasEditLink())); |
---|
617 | } |
---|
618 | else |
---|
619 | { |
---|
620 | out.write(HTML.encodeTags(p.getName())); |
---|
621 | } |
---|
622 | separator = ", "; |
---|
623 | } |
---|
624 | } |
---|
625 | catch (Throwable t) |
---|
626 | { |
---|
627 | %> |
---|
628 | <div class="error"><%=t.getMessage()%></div> |
---|
629 | <% |
---|
630 | } |
---|
631 | %> |
---|
632 | </tbl:cell> |
---|
633 | <tbl:cell column="children"> |
---|
634 | <% |
---|
635 | childQuery.setParameter("plate", itemId, Type.INT); |
---|
636 | try |
---|
637 | { |
---|
638 | String separator = ""; |
---|
639 | for (Plate p : childQuery.list(dc)) |
---|
640 | { |
---|
641 | out.write(separator); |
---|
642 | if (mode.hasPropertyLink()) |
---|
643 | { |
---|
644 | out.write(Base.getLinkedName(ID, p, false, mode.hasEditLink())); |
---|
645 | } |
---|
646 | else |
---|
647 | { |
---|
648 | out.write(HTML.encodeTags(p.getName())); |
---|
649 | } |
---|
650 | separator = ", "; |
---|
651 | } |
---|
652 | } |
---|
653 | catch (Throwable t) |
---|
654 | { |
---|
655 | %> |
---|
656 | <div class="error"><%=t.getMessage()%></div> |
---|
657 | <% |
---|
658 | } |
---|
659 | %> |
---|
660 | </tbl:cell> |
---|
661 | <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell> |
---|
662 | <% |
---|
663 | AnnotationSet as = item.isAnnotated() ? item.getAnnotationSet() : null; |
---|
664 | if (as != null) |
---|
665 | { |
---|
666 | for (AnnotationType at : annotationTypes) |
---|
667 | { |
---|
668 | if (as.hasAnnotation(at)) |
---|
669 | { |
---|
670 | Annotation a = as.getAnnotation(at); |
---|
671 | String suffix = a.getUnitSymbol(null); |
---|
672 | if (suffix != null) suffix = " " + suffix; |
---|
673 | %> |
---|
674 | <tbl:cell |
---|
675 | column="<%="at"+at.getId()%>" |
---|
676 | ><tbl:cellvalue |
---|
677 | list="<%=a.getValues(null)%>" |
---|
678 | suffix="<%=suffix%>" |
---|
679 | /></tbl:cell> |
---|
680 | <% |
---|
681 | } |
---|
682 | } |
---|
683 | } |
---|
684 | %> |
---|
685 | <tbl:cell column="permission"><%=PermissionUtil.getShortPermissions(item)%></tbl:cell> |
---|
686 | <tbl:cell column="sharedTo"> |
---|
687 | <% |
---|
688 | Iterator<Nameable> sharees = ShareableUtil.getSharedTo(dc, item).iterator(); |
---|
689 | while(sharees.hasNext()) |
---|
690 | { |
---|
691 | Nameable n = sharees.next(); |
---|
692 | if (mode.hasPropertyLink()) |
---|
693 | { |
---|
694 | out.write(Base.getLinkedName(ID, n, false, mode.hasEditLink())); |
---|
695 | } |
---|
696 | else |
---|
697 | { |
---|
698 | out.write(HTML.encodeTags(n.getName())); |
---|
699 | } |
---|
700 | out.write(sharees.hasNext() ? ", " : ""); |
---|
701 | } |
---|
702 | %> |
---|
703 | </tbl:cell> |
---|
704 | </tbl:row> |
---|
705 | <% |
---|
706 | } |
---|
707 | } |
---|
708 | %> |
---|
709 | </tbl:rows> |
---|
710 | </tbl:data> |
---|
711 | <% |
---|
712 | if (numListed == 0) |
---|
713 | { |
---|
714 | %> |
---|
715 | <tbl:panel><%=plates == null || plates.getTotalCount() == 0 ? "No plates were found" : "No plates on this page. Please select another page!" %></tbl:panel> |
---|
716 | <% |
---|
717 | } |
---|
718 | else |
---|
719 | { |
---|
720 | %> |
---|
721 | <tbl:navigator |
---|
722 | page="<%=cc.getPage()%>" |
---|
723 | rowsperpage="<%=cc.getRowsPerPage()%>" |
---|
724 | totalrows="<%=plates == null ? 0 : plates.getTotalCount()%>" |
---|
725 | visible="<%=mode.hasNavigator()%>" |
---|
726 | locked="true" |
---|
727 | /> |
---|
728 | <% |
---|
729 | } |
---|
730 | %> |
---|
731 | </tbl:table> |
---|
732 | <base:buttongroup align="center" clazz="fixedatbottom"> |
---|
733 | <base:button onclick="returnSelected();" title="Ok" visible="<%=mode.hasOkButton()%>" /> |
---|
734 | <base:button onclick="window.close();" title="Cancel" visible="<%=mode.hasCancelButton()%>" /> |
---|
735 | <base:button onclick="window.close();" title="Close" visible="<%=mode.hasCloseButton()%>" /> |
---|
736 | </base:buttongroup> |
---|
737 | <br><br><br> |
---|
738 | </base:body> |
---|
739 | </base:page> |
---|
740 | <% |
---|
741 | } |
---|
742 | finally |
---|
743 | { |
---|
744 | if (plates != null) plates.close(); |
---|
745 | if (dc != null) dc.close(); |
---|
746 | } |
---|
747 | %> |
---|