source: trunk/www/lims/plates/view_plate.jsp @ 5935

Last change on this file since 5935 was 5935, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • More changes to table and section taglibs. Simple item lists should now display ok (after using a different set of tags for the header row)
  • Hidable sections have been re-designed and should now look a bit better. However, in many of the places we use a section it is only used when there is data to list. The section should be used in all cases so we need to move the conditional test inside.
  • The code for listing "Shared to" information for items have been moved to an "include" page and the old code has been replaced in a lot of pages (may still be missing some).
  • The "Annotations & parameter" tab have been fixed with the new design.
  • The biosource, sample, extract and tag view pages have also been fixed.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 16.7 KB
Line 
1<%-- $Id: view_plate.jsp 5935 2012-01-26 15:22:21Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 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.SystemItems"
30  import="net.sf.basedb.core.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.AnnotationType"
35  import="net.sf.basedb.core.AnnotationSet"
36  import="net.sf.basedb.core.Plate"
37  import="net.sf.basedb.core.PlateType"
38  import="net.sf.basedb.core.PlateGeometry"
39  import="net.sf.basedb.core.PlateMapping"
40  import="net.sf.basedb.core.User"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.Include"
43  import="net.sf.basedb.core.ItemResultIterator"
44  import="net.sf.basedb.core.ItemResultList"
45  import="net.sf.basedb.core.MultiPermissions"
46  import="net.sf.basedb.core.PermissionDeniedException"
47  import="net.sf.basedb.core.PluginDefinition"
48  import="net.sf.basedb.core.plugin.GuiContext"
49  import="net.sf.basedb.core.plugin.Plugin"
50  import="net.sf.basedb.core.Project"
51  import="net.sf.basedb.core.query.Orders"
52  import="net.sf.basedb.core.query.Hql"
53  import="net.sf.basedb.clients.web.Base"
54  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
55  import="net.sf.basedb.clients.web.PermissionUtil"
56  import="net.sf.basedb.clients.web.util.HTML"
57  import="net.sf.basedb.util.Values"
58  import="net.sf.basedb.util.formatter.Formatter"
59  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
60  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
61  import="net.sf.basedb.clients.web.extensions.JspContext"
62  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
63  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
64  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
65  import="java.util.Collections"
66  import="java.util.Date"
67  import="java.util.Map"
68  import="java.util.Set"
69  import="java.util.List"
70%>
71<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
72<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
73<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
74<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
75<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
76<%!
77  private static final Item itemType = Item.PLATE;
78  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
79%>
80<%
81final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
82final String ID = sc.getId();
83final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
84final int itemId = cc.getId();
85final String tab = Values.getString(request.getParameter("tab"), "properties");
86final float scale = Base.getScale(sc);
87final DbControl dc = sc.newDbControl();
88try
89{
90  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
91  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
92
93  String title = null;
94  Plate plate = Plate.getById(dc, itemId);
95 
96  PlateMapping currentPlateMapping = null;
97  try
98  {
99    currentPlateMapping = plate.getPlateMapping();
100  }
101  catch (PermissionDeniedException ex)
102  {}
103 
104  final boolean writePermission = plate.hasPermission(Permission.WRITE);
105  final boolean deletePermission = plate.hasPermission(Permission.DELETE);
106  final boolean sharePermission = plate.hasPermission(Permission.SET_PERMISSION);
107  final boolean setOwnerPermission = plate.hasPermission(Permission.SET_OWNER);
108  final boolean isRemoved = plate.isRemoved();
109  final boolean isUsed = isRemoved && plate.isUsed();
110  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
111  final boolean isOwner = plate.isOwner();
112  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, plate);
113  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
114  %>
115  <base:page title="<%=title%>">
116  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
117    <ext:scripts context="<%=jspContext%>" />
118    <ext:stylesheets context="<%=jspContext%>" />
119    <script language="JavaScript">
120    function editItem()
121    {
122      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
123    }
124    function shareItem()
125    {
126      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlate', 600, 400);
127    }
128    function deleteItem()
129    {
130      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
131    }
132    function restoreItem()
133    {
134      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
135    }
136    function deleteItemPermanently()
137    {
138      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
139    }
140    function itemDeleted()
141    {
142      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
143    }
144    function showUsingItems()
145    {
146      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
147    }
148    function setOwner()
149    {
150      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
151    }
152    function runPlugin(cmd)
153    {
154      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
155    }
156    function viewWells()
157    {
158      location.href = 'wells/index.jsp?ID=<%=ID%>&plate_id=<%=itemId%>';
159    }
160    function viewEvents()
161    {
162      location.href = 'events/index.jsp?ID=<%=ID%>&plate_id=<%=itemId%>';
163    }
164    function switchTab(tabControlId, tabId)
165    {
166      if (tabId == 'history' && tabId != '<%=tab%>')
167      {
168        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
169      }
170      else if (tabId == 'events')
171      {
172        viewEvents();
173      }
174      else if (tabId == 'wells')
175      {
176        viewWells();
177      }
178      else
179      {
180        TabControl.setActiveTab(tabControlId, tabId);
181      }
182    }
183    </script>
184  </base:head>
185  <base:body>
186    <p>
187    <p:path>
188      <p:pathelement title="Plates" href="<%="index.jsp?ID="+ID%>" />
189      <p:pathelement title="<%=HTML.encodeTags(plate.getName())%>" />
190    </p:path>
191   
192    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
193    <t:tab id="properties" title="Properties">
194    <tbl:toolbar
195      >
196      <tbl:button 
197        disabled="<%=writePermission ? false : true%>" 
198        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
199        onclick="editItem()" 
200        title="Edit&hellip;" 
201        tooltip="<%=writePermission ? "Edit this plate" : "You do not have permission to edit this plate"%>" 
202      />
203      <tbl:button 
204        disabled="<%=deletePermission ? false : true%>" 
205        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
206        onclick="deleteItem()" 
207        title="Delete"
208        visible="<%=!plate.isRemoved()%>"
209        tooltip="<%=deletePermission ? "Delete this plate" : "You do not have permission to delete this plate"%>" 
210      />
211      <tbl:button 
212        disabled="<%=writePermission ? false : true%>" 
213        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
214        onclick="restoreItem()" 
215        title="Restore"
216        visible="<%=plate.isRemoved()%>"
217        tooltip="<%=writePermission ? "Restore this plate" : "You do not have permission to restore this plate"%>" 
218      />
219      <tbl:button 
220        disabled="<%=sharePermission ? false : true%>"
221        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
222        onclick="shareItem()" 
223        title="Share&hellip;" 
224        tooltip="<%=sharePermission ? "Share this plate to other user, groups and projects" : "You do not have permission to share this plate"%>"
225      />
226      <tbl:button 
227        disabled="<%=setOwnerPermission ? false : true%>"
228        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
229        onclick="setOwner()" 
230        title="Set owner&hellip;"
231        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
232      />
233      <tbl:button 
234        image="import.gif" 
235        onclick="runPlugin('ImportItem')" 
236        title="Import&hellip;" 
237        tooltip="Import data" 
238        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
239      />
240      <tbl:button 
241        image="export.gif" 
242        onclick="runPlugin('ExportItem')" 
243        title="Export&hellip;" 
244        tooltip="Export data" 
245        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
246      />
247      <tbl:button 
248        image="runplugin.gif" 
249        onclick="runPlugin('RunPlugin')" 
250        title="Run plugin&hellip;" 
251        tooltip="Run a plugin" 
252        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
253      />
254      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
255        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
256      <tbl:button
257        image="help.png"
258        onclick="<%="Main.openHelp('" + ID +"', 'plate.view.properties')"%>"
259        title="Help&hellip;"
260        tooltip="Get help about this page"
261      />
262      </tbl:toolbar>
263    <div class="boxedbottom">
264      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(plate)%></i></div>
265      <%
266      if (plate.isRemoved() || plate.isShared())
267      {
268        %>
269        <div class="itemstatus">
270          <base:icon 
271            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
272            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
273            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
274            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
275          <base:icon image="used.gif" 
276            onclick="showUsingItems()"
277            tooltip="Show the items that are using this one"
278            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
279          <base:icon image="shared.gif" 
280            visible="<%=plate.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
281        </div>
282        <%
283      }
284      %>
285      <table class="form" cellspacing="0">
286      <tr>
287        <td class="prompt">Name</td>
288        <td><%=HTML.encodeTags(plate.getName())%></td>
289      </tr>
290      <tr>
291        <td class="prompt">Registered</td>
292        <td><%=dateFormatter.format(plate.getEntryDate())%></td>
293      </tr>
294      <tr>
295        <td class="prompt">Barcode</td>
296        <td><%=HTML.encodeTags(plate.getBarcode())%></td>
297      </tr>
298      <tr>
299        <td class="prompt">Destroyed</td>
300        <td><%=plate.isDestroyed() ? "yes" : "no"%></td>
301      </tr>
302      <tr>
303        <td class="prompt">Type</td>
304        <td><base:propertyvalue item="<%=plate%>" property="plateType" /></td>
305      </tr>
306      <tr>
307        <td class="prompt">Geometry</td>
308        <td><base:propertyvalue item="<%=plate%>" property="plateType.plateGeometry" /></td>
309      </tr>
310      <tr >
311        <td class="prompt">Merge mapping</td>
312        <td><%
313          if (currentPlateMapping != null && currentPlateMapping.getImage() != null)
314          {
315            %>
316            <img id="mappingImage" src="../../images/platemappings/<%=currentPlateMapping.getImage()%>" align="right">
317            <%
318          }
319          %>
320          <base:propertyvalue item="<%=plate%>" property="plateMapping" />
321        </td>
322      </tr>
323      <tr>
324        <td class="prompt">Owner</td>
325        <td><base:propertyvalue item="<%=plate%>" property="owner" /></td>
326      </tr>
327      <tr>
328        <td class="prompt">Description</td>
329        <td><%=HTML.niceFormat(plate.getDescription())%></td>
330      </tr>
331      </table>
332     
333      <%
334      ItemQuery<Plate> parentPlatesQuery = plate.getParentPlates();
335      parentPlatesQuery.include(Include.ALL);
336      parentPlatesQuery.order(Orders.asc(Hql.property("name")));
337      ItemResultList<Plate> parentPlates = parentPlatesQuery.list(dc);
338      if (parentPlates.size() == 0)
339      {
340        %>
341        <h4>Parent plates</h4>
342        This plate doesn't have any parents (or, you don't have permission to view them).
343        <%
344      }
345      else
346      {
347        %>
348        <base:section
349          id="parents"
350          title="<%="Parent plates (" + parentPlates.size() + ")"%>"
351          context="<%=cc%>"
352          >
353          <tbl:table
354            id="parentplates"
355           
356            columns="all"
357            >
358          <tbl:columndef 
359            id="name"
360            title="Name"
361          />
362          <tbl:columndef 
363            id="index"
364            title="Index"
365          />
366          <tbl:columndef 
367            id="description"
368            title="Description"
369          />
370          <tbl:data>
371            <tbl:columns>
372            </tbl:columns>
373            <tbl:rows>
374            <%
375            for (Plate item : parentPlates)
376            {
377              %>
378              <tbl:row>
379                <tbl:cell column="name"><base:icon 
380                    image="deleted.gif" 
381                    tooltip="This item has been scheduled for deletion" 
382                    visible="<%=item.isRemoved()%>"
383                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
384                <tbl:cell column="index"><%=plate.getSourceIndex(item)+1%></tbl:cell>
385                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
386              </tbl:row>
387              <%
388            }
389            %>
390            </tbl:rows>
391          </tbl:data>
392          </tbl:table>
393        </base:section>
394        <%
395      }
396      %>
397      <%
398      ItemQuery<Plate> childPlatesQuery = plate.getChildPlates();
399      childPlatesQuery.include(Include.ALL);
400      childPlatesQuery.order(Orders.asc(Hql.property("name")));
401      ItemResultList<Plate> childPlates = childPlatesQuery.list(dc);
402      if (childPlates.size() == 0)
403      {
404        %>
405        <h4>Child plates</h4>
406        This plate doesn't have any children (or, you don't have permission to view them).
407        <%
408      }
409      else
410      {
411        %>
412        <base:section
413          id="children"
414          title="<%="Child plates (" + childPlates.size() + ")"%>"
415          context="<%=cc%>"
416          >
417          <tbl:table
418            id="childplates"
419           
420            columns="all"
421            >
422          <tbl:columndef 
423            id="name"
424            title="Name"
425          />
426          <tbl:columndef
427            id="mapping"
428            title="Mapping"
429          />
430          <tbl:columndef 
431            id="index"
432            title="Index"
433          />
434          <tbl:columndef 
435            id="description"
436            title="Description"
437          />
438          <tbl:data>
439            <tbl:columns>
440            </tbl:columns>
441            <tbl:rows>
442            <%
443            for (Plate item : childPlates)
444            {
445              %>
446              <tbl:row>
447                <tbl:cell column="name"><base:icon 
448                    image="deleted.gif" 
449                    tooltip="This item has been scheduled for deletion" 
450                    visible="<%=item.isRemoved()%>"
451                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
452                <tbl:cell column="mapping"><base:propertyvalue item="<%=item%>" property="plateMapping" /></tbl:cell>
453                <tbl:cell column="index"><%=item.getSourceIndex(plate) + 1%></tbl:cell>
454                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
455              </tbl:row>
456              <%
457            }
458            %>
459            </tbl:rows>
460          </tbl:data>
461          </tbl:table>
462        </base:section>
463        <%
464      }
465      %>
466      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
467        <jsp:param name="ID" value="<%=ID%>" />
468        <jsp:param name="item_type" value="<%=itemType.name()%>" />
469        <jsp:param name="item_id" value="<%=itemId%>" />
470        <jsp:param name="title" value="Other items related to this plate" />
471      </jsp:include>
472      <jsp:include page="../../common/share/list_share.jsp">
473        <jsp:param name="ID" value="<%=ID%>" />
474        <jsp:param name="item_type" value="<%=itemType.name()%>" />
475        <jsp:param name="item_id" value="<%=itemId%>" />
476        <jsp:param name="title" value="Shared to" />
477      </jsp:include>
478      </div>
479      </t:tab>
480     
481      <t:tab id="annotations" title="Annotations" 
482        tooltip="View annotation values" clazz="white">
483        <jsp:include page="../../common/annotations/list_annotations.jsp">
484          <jsp:param name="item_type" value="<%=itemType.name()%>" />
485          <jsp:param name="item_id" value="<%=itemId%>" />
486          <jsp:param name="ID" value="<%=ID%>" />
487        </jsp:include>
488      </t:tab>
489
490     
491      <t:tab id="events" title="Events" />
492      <t:tab id="wells" title="Wells" />
493      <t:tab id="history" title="Change history" 
494        tooltip="Displays a log of all modifications made to this item"
495        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
496        <%
497        if ("history".equals(tab))
498        {
499          %>
500          <jsp:include page="../../common/history/frameset.jsp">
501            <jsp:param name="source_type" value="<%=itemType.name()%>" />
502            <jsp:param name="source_id" value="<%=itemId%>" />
503            <jsp:param name="ID" value="<%=ID%>" />
504          </jsp:include>
505          <%
506        }
507        %>
508      </t:tab>
509      </t:tabcontrol>
510
511  </base:body>
512  </base:page>
513  <%
514}
515finally
516{
517  if (dc != null) dc.close();
518}
519
520%>
Note: See TracBrowser for help on using the repository browser.