source: trunk/www/lims/plates/events/view_event.jsp @ 5943

Last change on this file since 5943 was 5943, checked in by Nicklas Nordborg, 11 years ago

References #1655: GUI improvements

Plate section of Array LIMS.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.1 KB
Line 
1<%-- $Id: view_event.jsp 5943 2012-02-01 14:49:04Z 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<%
65final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
66final String ID = sc.getId();
67final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
68final int itemId = cc.getId();
69final float scale = Base.getScale(sc);
70final DbControl dc = sc.newDbControl();
71try
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:path><p:pathelement
121      title="Plates" href="<%="../index.jsp?ID="+ID%>" 
122      /><p:pathelement 
123        title="<%=HTML.encodeTags(plate.getName())%>" 
124        href="<%="index.jsp?ID="+ID+"&plate_id="+plateId%>" 
125      /><p:pathelement title="<%="Event: "+Base.getEncodedName(currentEventType, !readCurrentEventType)%>" 
126      /></p:path>
127   
128    <t:tabcontrol
129      id="main" 
130      subclass="content mastertabcontrol" 
131      active="properties" switch="switchTab">
132    <t:tab id="properties" title="Properties">
133      <div>
134      <table class="fullform bottomborder">
135      <tr>
136        <th class="itemstatus"></th>
137        <td style="padding: 0px;">
138          <tbl:toolbar subclass="bottomborder">
139            <tbl:button 
140              disabled="<%=!writePermission%>" 
141              image="edit.gif" 
142              onclick="editItem()" 
143              title="Edit&hellip;" 
144              tooltip="<%=writePermission ? "Edit this event" : "You do not have permission to edit this event"%>" 
145            />
146            <tbl:button 
147              disabled="<%=!deletePermission%>" 
148              image="delete.gif" 
149              onclick="deleteItem()" 
150              title="Delete"
151              tooltip="<%=deletePermission ? "Delete this event" : "You do not have permission to event this event"%>" 
152            />
153            <tbl:button 
154              image="import.gif" 
155              onclick="runPlugin('ImportItem')" 
156              title="Import&hellip;" 
157              tooltip="Import data" 
158              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
159            />
160            <tbl:button 
161              image="export.gif" 
162              onclick="runPlugin('ExportItem')" 
163              title="Export&hellip;" 
164              tooltip="Export data" 
165              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
166            />
167            <tbl:button 
168              image="runplugin.gif" 
169              onclick="runPlugin('RunPlugin')" 
170              title="Run plugin&hellip;" 
171              tooltip="Run a plugin" 
172              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
173            />
174            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
175              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
176            <tbl:button
177              image="help.png"
178              onclick="<%="Main.openHelp('" + ID +"', 'plateevent.view.properties')"%>"
179              title="Help&hellip;"
180              tooltip="Get help about this page"
181            />
182          </tbl:toolbar>
183        </td>
184      </tr>
185      <tr>
186        <th>User</th>
187        <td><base:propertyvalue item="<%=event%>" property="user" /></td>
188      </tr>
189      <tr>
190        <th>Event date</th>
191        <td><%=dateFormatter.format(event.getEventDate())%></td>
192      </tr>
193      <tr>
194        <th>Registration date</th>
195        <td><%=dateFormatter.format(event.getEntryDate())%></td>
196      </tr>
197      <tr>
198        <th>Event type</th>
199        <td>
200          <%=currentEventType != null ? currentEventType.getOrdinal() + ". " : ""%>
201          <%=Base.getLinkedName(ID, currentEventType, !readCurrentEventType, true)%>
202        </td>
203      </tr>
204      <tr>
205        <th>Protocol</th>
206        <td><base:propertyvalue item="<%=event%>" property="protocol" /></td>
207      </tr>
208      <tr>
209        <th>Hardware</th>
210        <td><base:propertyvalue item="<%=event%>" property="hardware" /></td>
211      </tr>
212      <tr>
213        <th>Permissions</th>
214        <td><%=PermissionUtil.getFullPermissionNames(event)%></td>
215      </tr>
216      <tr>
217        <th>Comment</th>
218        <td><%=HTML.niceFormat(event.getComment())%></td>
219      </tr>
220      </table>
221      </div>
222   
223      <jsp:include page="../../../common/anytoany/list_anytoany.jsp">
224        <jsp:param name="ID" value="<%=ID%>" />
225        <jsp:param name="item_type" value="<%=itemType.name()%>" />
226        <jsp:param name="item_id" value="<%=itemId%>" />
227        <jsp:param name="title" value="Other items related to this event" />
228      </jsp:include>
229    </t:tab>
230    </t:tabcontrol>
231  </base:body>
232  </base:page>
233  <%
234}
235finally
236{
237  if (dc != null) dc.close();
238}
239
240%>
Note: See TracBrowser for help on using the repository browser.