1 | <%-- $Id: view_event.jsp 5942 2012-02-01 14:12:59Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 3 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
21 | |
---|
22 | @author Nicklas |
---|
23 | @version 2.0 |
---|
24 | --%> |
---|
25 | <%@ page pageEncoding="UTF-8" session="false" |
---|
26 | import="net.sf.basedb.core.SessionControl" |
---|
27 | import="net.sf.basedb.core.DbControl" |
---|
28 | import="net.sf.basedb.core.SystemItems" |
---|
29 | import="net.sf.basedb.core.Item" |
---|
30 | import="net.sf.basedb.core.ItemContext" |
---|
31 | import="net.sf.basedb.core.Permission" |
---|
32 | import="net.sf.basedb.core.Plate" |
---|
33 | import="net.sf.basedb.core.PlateEvent" |
---|
34 | import="net.sf.basedb.core.PlateEventType" |
---|
35 | import="net.sf.basedb.core.Protocol" |
---|
36 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
37 | import="net.sf.basedb.core.PluginDefinition" |
---|
38 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
39 | import="net.sf.basedb.core.plugin.Plugin" |
---|
40 | import="net.sf.basedb.clients.web.Base" |
---|
41 | import="net.sf.basedb.clients.web.PermissionUtil" |
---|
42 | import="net.sf.basedb.clients.web.util.HTML" |
---|
43 | import="net.sf.basedb.util.Values" |
---|
44 | import="net.sf.basedb.util.formatter.Formatter" |
---|
45 | import="net.sf.basedb.clients.web.formatter.FormatterFactory" |
---|
46 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
47 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
48 | import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
---|
49 | import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
---|
50 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
51 | import="java.util.Date" |
---|
52 | import="java.util.Map" |
---|
53 | import="java.util.Set" |
---|
54 | %> |
---|
55 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
56 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
57 | <%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
---|
58 | <%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
---|
59 | <%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
---|
60 | <%! |
---|
61 | private static final Item itemType = Item.PLATEEVENT; |
---|
62 | private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
---|
63 | %> |
---|
64 | <% |
---|
65 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
66 | final String ID = sc.getId(); |
---|
67 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
68 | final int itemId = cc.getId(); |
---|
69 | final float scale = Base.getScale(sc); |
---|
70 | final DbControl dc = sc.newDbControl(); |
---|
71 | try |
---|
72 | { |
---|
73 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
74 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
75 | |
---|
76 | String title = null; |
---|
77 | final PlateEvent event = PlateEvent.getById(dc, itemId); |
---|
78 | final Plate plate = event.getPlate(); |
---|
79 | final int plateId = plate.getId(); |
---|
80 | |
---|
81 | PlateEventType currentEventType = null; |
---|
82 | boolean readCurrentEventType = true; |
---|
83 | try |
---|
84 | { |
---|
85 | currentEventType = event.getPlateEventType(); |
---|
86 | } |
---|
87 | catch (PermissionDeniedException ex) |
---|
88 | { |
---|
89 | readCurrentEventType = false; |
---|
90 | } |
---|
91 | |
---|
92 | final boolean writePermission = event.hasPermission(Permission.WRITE); |
---|
93 | final boolean deletePermission = event.hasPermission(Permission.DELETE); |
---|
94 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, event); |
---|
95 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
96 | %> |
---|
97 | <base:page title="<%=title%>"> |
---|
98 | <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
---|
99 | <ext:scripts context="<%=jspContext%>" /> |
---|
100 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
101 | <script language="JavaScript"> |
---|
102 | function editItem() |
---|
103 | { |
---|
104 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
105 | } |
---|
106 | function deleteItem() |
---|
107 | { |
---|
108 | if (confirm('This can\'t be undone. Continue?')) |
---|
109 | { |
---|
110 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&plate_id=<%=plateId%>&item_id=<%=itemId%>'); |
---|
111 | } |
---|
112 | } |
---|
113 | function runPlugin(cmd) |
---|
114 | { |
---|
115 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&plate_id=<%=plateId%>&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500); |
---|
116 | } |
---|
117 | </script> |
---|
118 | </base:head> |
---|
119 | <base:body> |
---|
120 | <p> |
---|
121 | <p:path> |
---|
122 | <p:pathelement title="Plates" href="<%="../index.jsp?ID="+ID%>" /> |
---|
123 | <p:pathelement |
---|
124 | title="<%=HTML.encodeTags(plate.getName())%>" |
---|
125 | href="<%="index.jsp?ID="+ID+"&plate_id="+plateId%>" /> |
---|
126 | <p:pathelement title="<%="Event: "+Base.getEncodedName(currentEventType, !readCurrentEventType)%>" /> |
---|
127 | </p:path> |
---|
128 | |
---|
129 | <t:tabcontrol id="main" active="properties" switch="switchTab"> |
---|
130 | <t:tab id="properties" title="Properties"> |
---|
131 | |
---|
132 | <tbl:toolbar |
---|
133 | > |
---|
134 | <tbl:button |
---|
135 | disabled="<%=!writePermission%>" |
---|
136 | image="edit.gif" |
---|
137 | onclick="editItem()" |
---|
138 | title="Edit…" |
---|
139 | tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>" |
---|
140 | /> |
---|
141 | <tbl:button |
---|
142 | disabled="<%=!deletePermission%>" |
---|
143 | image="delete.gif" |
---|
144 | onclick="deleteItem()" |
---|
145 | title="Delete" |
---|
146 | tooltip="<%=deletePermission ? "Delete this event" : "You do not have permission to event this event"%>" |
---|
147 | /> |
---|
148 | <tbl:button |
---|
149 | image="import.gif" |
---|
150 | onclick="runPlugin('ImportItem')" |
---|
151 | title="Import…" |
---|
152 | tooltip="Import data" |
---|
153 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
154 | /> |
---|
155 | <tbl:button |
---|
156 | image="export.gif" |
---|
157 | onclick="runPlugin('ExportItem')" |
---|
158 | title="Export…" |
---|
159 | tooltip="Export data" |
---|
160 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
161 | /> |
---|
162 | <tbl:button |
---|
163 | image="runplugin.gif" |
---|
164 | onclick="runPlugin('RunPlugin')" |
---|
165 | title="Run plugin…" |
---|
166 | tooltip="Run a plugin" |
---|
167 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
168 | /> |
---|
169 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
170 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
171 | <tbl:button |
---|
172 | image="help.png" |
---|
173 | onclick="<%="Main.openHelp('" + ID +"', 'plateevent.view.properties')"%>" |
---|
174 | title="Help…" |
---|
175 | tooltip="Get help about this page" |
---|
176 | /> |
---|
177 | </tbl:toolbar> |
---|
178 | |
---|
179 | <div class="boxedbottom"> |
---|
180 | <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(event)%></i></div> |
---|
181 | <table class="form" cellspacing=0> |
---|
182 | <tr> |
---|
183 | <td class="prompt">User</td> |
---|
184 | <td><base:propertyvalue item="<%=event%>" property="user" /></td> |
---|
185 | </tr> |
---|
186 | <tr> |
---|
187 | <td class="prompt">Event date</td> |
---|
188 | <td><%=dateFormatter.format(event.getEventDate())%></td> |
---|
189 | </tr> |
---|
190 | <tr> |
---|
191 | <td class="prompt">Registration date</td> |
---|
192 | <td><%=dateFormatter.format(event.getEntryDate())%></td> |
---|
193 | </tr> |
---|
194 | <tr> |
---|
195 | <td class="prompt">Event type</td> |
---|
196 | <td> |
---|
197 | <%=currentEventType != null ? currentEventType.getOrdinal() + ". " : ""%> |
---|
198 | <%=Base.getLinkedName(ID, currentEventType, !readCurrentEventType, true)%> |
---|
199 | </td> |
---|
200 | </tr> |
---|
201 | <tr> |
---|
202 | <td class="prompt">Protocol</td> |
---|
203 | <td><base:propertyvalue item="<%=event%>" property="protocol" /></td> |
---|
204 | </tr> |
---|
205 | <tr> |
---|
206 | <td class="prompt">Hardware</td> |
---|
207 | <td><base:propertyvalue item="<%=event%>" property="hardware" /></td> |
---|
208 | </tr> |
---|
209 | <tr> |
---|
210 | <td class="prompt">Comment</td> |
---|
211 | <td><%=HTML.niceFormat(event.getComment())%></td> |
---|
212 | </tr> |
---|
213 | </table> |
---|
214 | <jsp:include page="../../../common/anytoany/list_anytoany.jsp"> |
---|
215 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
216 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
217 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
218 | <jsp:param name="title" value="Other items related to this event" /> |
---|
219 | </jsp:include> |
---|
220 | </div> |
---|
221 | </t:tab> |
---|
222 | </t:tabcontrol> |
---|
223 | |
---|
224 | </base:body> |
---|
225 | </base:page> |
---|
226 | <% |
---|
227 | } |
---|
228 | finally |
---|
229 | { |
---|
230 | if (dc != null) dc.close(); |
---|
231 | } |
---|
232 | |
---|
233 | %> |
---|