source: trunk/www/lims/arrayslides/view_slide.jsp @ 5942

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

References #1655: GUI improvements

Modify lots of boolean taglib parameters.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 13.1 KB
Line 
1<%-- $Id: view_slide.jsp 5942 2012-02-01 14:12:59Z 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.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.AnnotationType"
34  import="net.sf.basedb.core.AnnotationSet"
35  import="net.sf.basedb.core.PhysicalBioAssay"
36  import="net.sf.basedb.core.ArraySlide"
37  import="net.sf.basedb.core.ArrayBatch"
38  import="net.sf.basedb.core.ArrayDesign"
39  import="net.sf.basedb.core.User"
40  import="net.sf.basedb.core.Group"
41  import="net.sf.basedb.core.ItemQuery"
42  import="net.sf.basedb.core.Include"
43  import="net.sf.basedb.core.ItemResultList"
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.ARRAYSLIDE;
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  ArraySlide slide = ArraySlide.getById(dc, itemId);
95 
96  final boolean writePermission = slide.hasPermission(Permission.WRITE);
97  final boolean deletePermission = slide.hasPermission(Permission.DELETE);
98  final boolean sharePermission = slide.hasPermission(Permission.SET_PERMISSION);
99  final boolean setOwnerPermission = slide.hasPermission(Permission.SET_OWNER);
100  final boolean isRemoved = slide.isRemoved();
101  final boolean isUsed = isRemoved && slide.isUsed();
102  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
103  final boolean isOwner = slide.isOwner();
104  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, slide);
105  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
106  %>
107  <base:page title="<%=title%>">
108  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
109    <ext:scripts context="<%=jspContext%>" />
110    <ext:stylesheets context="<%=jspContext%>" />
111    <script language="JavaScript">
112    function editItem()
113    {
114      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
115    }
116    function shareItem()
117    {
118      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareArraySlide', 600, 400);
119    }
120    function deleteItem()
121    {
122      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
123    }
124    function restoreItem()
125    {
126      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
127    }
128    function deleteItemPermanently()
129    {
130      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
131    }
132    function itemDeleted()
133    {
134      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
135    }
136    function showUsingItems()
137    {
138      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
139    }
140    function setOwner()
141    {
142      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
143    }
144    function runPlugin(cmd)
145    {
146      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
147    }
148    function switchTab(tabControlId, tabId)
149    {
150      if (TabControl.isActive(tabControlId, tabId)) return;
151      if ((tabId == 'overview' || tabId == 'history') && tabId != '<%=tab%>')
152      {
153        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
154      }
155      else
156      {
157        TabControl.setActiveTab(tabControlId, tabId);
158      }
159    }
160    </script>
161  </base:head>
162  <base:body>
163    <p>
164    <p:path>
165      <p:pathelement title="Array slides" href="<%="index.jsp?ID="+ID%>" />
166      <p:pathelement title="<%=HTML.encodeTags(slide.getName())%>" />
167    </p:path>
168   
169    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
170    <t:tab id="properties" title="Properties">
171    <tbl:toolbar
172      >
173      <tbl:button 
174        disabled="<%=!writePermission%>" 
175        image="edit.gif" 
176        onclick="editItem()" 
177        title="Edit&hellip;" 
178        tooltip="<%=writePermission ? "Edit this array slide" : "You do not have permission to edit this array slide"%>" 
179      />
180      <tbl:button 
181        disabled="<%=!deletePermission%>" 
182        image="delete.gif" 
183        onclick="deleteItem()" 
184        title="Delete"
185        visible="<%=!slide.isRemoved()%>"
186        tooltip="<%=deletePermission ? "Delete this array slide" : "You do not have permission to delete this array slide"%>" 
187      />
188      <tbl:button 
189        disabled="<%=!writePermission%>" 
190        image="restore.gif" 
191        onclick="restoreItem()" 
192        title="Restore"
193        visible="<%=slide.isRemoved()%>"
194        tooltip="<%=writePermission ? "Restore this array slide" : "You do not have permission to restore this array slide"%>" 
195      />
196      <tbl:button 
197        disabled="<%=!sharePermission%>"
198        image="share.gif"
199        onclick="shareItem()" 
200        title="Share&hellip;" 
201        tooltip="<%=sharePermission ? "Share this array slide to other user, groups and projects" : "You do not have permission to share this array slide"%>"
202      />
203      <tbl:button 
204        disabled="<%=!setOwnerPermission%>"
205        image="take_ownership.png"
206        onclick="setOwner()" 
207        title="Set owner&hellip;"
208        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
209      />
210      <tbl:button 
211        image="import.gif" 
212        onclick="runPlugin('ImportItem')" 
213        title="Import&hellip;" 
214        tooltip="Import data" 
215        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
216      />
217      <tbl:button 
218        image="export.gif" 
219        onclick="runPlugin('ExportItem')" 
220        title="Export&hellip;" 
221        tooltip="Export data" 
222        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
223      />
224      <tbl:button 
225        image="runplugin.gif" 
226        onclick="runPlugin('RunPlugin')" 
227        title="Run plugin&hellip;" 
228        tooltip="Run a plugin" 
229        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
230      />
231      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
232        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
233      <tbl:button
234        image="help.png"
235        onclick="<%="Main.openHelp('" + ID +"', 'arrayslide.view.properties')"%>"
236        title="Help&hellip;"
237        tooltip="Get help about this page"
238      />
239      </tbl:toolbar>
240    <div class="boxedbottom">
241      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(slide)%></i></div>
242      <%
243      if (slide.isRemoved() || slide.isShared())
244      {
245        %>
246        <div class="itemstatus">
247          <base:icon 
248            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
249            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
250            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
251            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
252          <base:icon image="used.gif" 
253            onclick="showUsingItems()"
254            tooltip="Show the items that are using this one"
255            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
256          <base:icon image="shared.gif" 
257            visible="<%=slide.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
258        </div>
259        <%
260      }
261      %>
262      <table class="form" cellspacing="0">
263      <tr>
264        <td class="prompt">Name</td>
265        <td><%=HTML.encodeTags(slide.getName())%></td>
266      </tr>
267      <tr>
268        <td class="prompt">Registered</td>
269        <td><%=dateFormatter.format(slide.getEntryDate())%></td>
270      </tr>
271      <tr>
272        <td class="prompt">Barcode</td>
273        <td><%=HTML.encodeTags(slide.getBarcode())%></td>
274      </tr>
275      <tr>
276        <td class="prompt">Destroyed</td>
277        <td><%=slide.isDestroyed() ? "yes" : "no"%></td>
278      </tr>
279      <tr>
280        <td class="prompt">Physical bioassay</td>
281        <td><base:propertyvalue item="<%=slide%>" property="physicalBioAssay" /></td>
282      </tr>
283      <tr>
284        <td class="prompt">Array batch</td>
285        <td><base:propertyvalue item="<%=slide%>" property="arrayBatch" />
286        (index: <%=slide.getBatchIndex()%>)
287        </td>
288      </tr>
289      <tr>
290        <td class="prompt">Array design</td>
291        <td><base:propertyvalue item="<%=slide%>" property="arrayBatch.arrayDesign" /></td>
292      </tr>
293      <tr>
294        <td class="prompt">Owner</td>
295        <td><base:propertyvalue item="<%=slide%>" property="owner" /></td>
296      </tr>
297      <tr>
298        <td class="prompt">Description</td>
299        <td><%=HTML.niceFormat(slide.getDescription())%></td>
300      </tr>
301      </table>
302      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
303        <jsp:param name="ID" value="<%=ID%>" />
304        <jsp:param name="item_type" value="<%=itemType.name()%>" />
305        <jsp:param name="item_id" value="<%=itemId%>" />
306        <jsp:param name="title" value="Other items related to this slide" />
307      </jsp:include>
308      <jsp:include page="../../common/share/list_share.jsp">
309        <jsp:param name="ID" value="<%=ID%>" />
310        <jsp:param name="item_type" value="<%=itemType.name()%>" />
311        <jsp:param name="item_id" value="<%=itemId%>" />
312        <jsp:param name="title" value="Shared to" />
313      </jsp:include>
314      </div>
315      </t:tab>
316     
317      <t:tab id="annotations" title="Annotations &amp; parameters" 
318        tooltip="View annotation values and protocol parameters" clazz="white">
319        <jsp:include page="../../common/annotations/list_annotations.jsp">
320          <jsp:param name="item_type" value="<%=itemType.name()%>" />
321          <jsp:param name="item_id" value="<%=itemId%>" />
322          <jsp:param name="ID" value="<%=ID%>" />
323        </jsp:include>
324      </t:tab>
325
326      <t:tab id="overview" title="Overview" 
327        tooltip="Display a tree overview of related items">
328        <%
329        if ("overview".equals(tab))
330        {
331          %>
332          <jsp:include page="../../common/overview/overview.jsp">
333            <jsp:param name="item_type" value="<%=itemType.name()%>" />
334            <jsp:param name="item_id" value="<%=itemId%>" />
335            <jsp:param name="ID" value="<%=ID%>" />
336          </jsp:include>
337          <%
338        }
339        %>
340      </t:tab>
341      <t:tab id="history" title="Change history" 
342        tooltip="Displays a log of all modifications made to this item"
343        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
344        <%
345        if ("history".equals(tab))
346        {
347          %>
348          <jsp:include page="../../common/history/frameset.jsp">
349            <jsp:param name="source_type" value="<%=itemType.name()%>" />
350            <jsp:param name="source_id" value="<%=itemId%>" />
351            <jsp:param name="ID" value="<%=ID%>" />
352          </jsp:include>
353          <%
354        }
355        %>
356      </t:tab>
357      </t:tabcontrol>
358
359  </base:body>
360  </base:page>
361  <%
362}
363finally
364{
365  if (dc != null) dc.close();
366}
367
368%>
Note: See TracBrowser for help on using the repository browser.