source: trunk/www/lims/arraybatches/view_batch.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: 15.2 KB
Line 
1<%-- $Id: view_batch.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.ArrayBatch"
36  import="net.sf.basedb.core.ArraySlide"
37  import="net.sf.basedb.core.ArrayDesign"
38  import="net.sf.basedb.core.Protocol"
39  import="net.sf.basedb.core.Hardware"
40  import="net.sf.basedb.core.User"
41  import="net.sf.basedb.core.Group"
42  import="net.sf.basedb.core.ItemQuery"
43  import="net.sf.basedb.core.Include"
44  import="net.sf.basedb.core.ItemResultList"
45  import="net.sf.basedb.core.ItemResultList"
46  import="net.sf.basedb.core.MultiPermissions"
47  import="net.sf.basedb.core.PermissionDeniedException"
48  import="net.sf.basedb.core.PluginDefinition"
49  import="net.sf.basedb.core.plugin.GuiContext"
50  import="net.sf.basedb.core.plugin.Plugin"
51  import="net.sf.basedb.core.Project"
52  import="net.sf.basedb.core.query.Orders"
53  import="net.sf.basedb.core.query.Hql"
54  import="net.sf.basedb.clients.web.Base"
55  import="net.sf.basedb.clients.web.ChangeHistoryUtil"
56  import="net.sf.basedb.clients.web.PermissionUtil"
57  import="net.sf.basedb.clients.web.util.HTML"
58  import="net.sf.basedb.util.Values"
59  import="net.sf.basedb.util.formatter.Formatter"
60  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
61  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
62  import="net.sf.basedb.clients.web.extensions.JspContext"
63  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
64  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
65  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
66  import="java.util.Collections"
67  import="java.util.Date"
68  import="java.util.Map"
69  import="java.util.Set"
70  import="java.util.List"
71%>
72<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
73<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
74<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
75<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
76<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
77<%!
78  private static final Item itemType = Item.ARRAYBATCH;
79  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
80%>
81<%
82final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
83final String ID = sc.getId();
84final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
85final int itemId = cc.getId();
86final String tab = Values.getString(request.getParameter("tab"), "properties");
87final float scale = Base.getScale(sc);
88final DbControl dc = sc.newDbControl();
89try
90{
91  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
92  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
93
94  String title = null;
95  ArrayBatch batch = ArrayBatch.getById(dc, itemId);
96 
97  final boolean usePermission = batch.hasPermission(Permission.USE);
98  final boolean writePermission = batch.hasPermission(Permission.WRITE);
99  final boolean deletePermission = batch.hasPermission(Permission.DELETE);
100  final boolean sharePermission = batch.hasPermission(Permission.SET_PERMISSION);
101  final boolean setOwnerPermission = batch.hasPermission(Permission.SET_OWNER);
102  final boolean isRemoved = batch.isRemoved();
103  final boolean isUsed = isRemoved && batch.isUsed();
104  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
105  final boolean isOwner = batch.isOwner();
106  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, batch);
107  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
108  %>
109  <base:page title="<%=title%>">
110  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
111    <ext:scripts context="<%=jspContext%>" />
112    <ext:stylesheets context="<%=jspContext%>" />
113    <script language="JavaScript">
114    function editItem()
115    {
116      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
117    }
118    function shareItem()
119    {
120      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareArrayBatch', 600, 400);
121    }
122    function deleteItem()
123    {
124      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
125    }
126    function restoreItem()
127    {
128      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
129    }
130    function deleteItemPermanently()
131    {
132      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
133    }
134    function itemDeleted()
135    {
136      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
137    }
138    function showUsingItems()
139    {
140      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
141    }
142    function setOwner()
143    {
144      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
145    }
146    function runPlugin(cmd)
147    {
148      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
149    }
150    function newSlide()
151    {
152      Main.viewOrEditItem('<%=ID%>', 'ARRAYSLIDE', 0, true, '&arraybatch_id=<%=itemId%>');
153    }
154    function multipleNewSlides()
155    {     
156      Main.openPopup('../arrayslides/index.jsp?ID=<%=ID%>&cmd=NewItems&arraybatch_id=<%=itemId%>', 'NewArraySlides', 750, 500);
157    }
158    function switchTab(tabControlId, tabId)
159    {
160      if (TabControl.isActive(tabControlId, tabId)) return;
161      if ((tabId == 'overview' || tabId == 'history') && tabId != '<%=tab%>')
162      {
163        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
164      }
165      else
166      {
167        TabControl.setActiveTab(tabControlId, tabId);
168      }
169    }
170    </script>
171  </base:head>
172  <base:body>
173    <p>
174    <p:path>
175      <p:pathelement title="Array batches" href="<%="index.jsp?ID="+ID%>" />
176      <p:pathelement title="<%=HTML.encodeTags(batch.getName())%>" />
177    </p:path>
178   
179    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab" remember="false">
180    <t:tab id="properties" title="Properties">
181    <tbl:toolbar
182      >
183      <tbl:button 
184        disabled="<%=!writePermission%>" 
185        image="edit.gif" 
186        onclick="editItem()" 
187        title="Edit&hellip;" 
188        tooltip="<%=writePermission ? "Edit this array batch" : "You do not have permission to edit this array batch"%>" 
189      />
190      <tbl:button 
191        disabled="<%=!deletePermission%>" 
192        image="delete.gif" 
193        onclick="deleteItem()" 
194        title="Delete"
195        visible="<%=!batch.isRemoved()%>"
196        tooltip="<%=deletePermission ? "Delete this array batch" : "You do not have permission to delete this array batch"%>" 
197      />
198      <tbl:button 
199        disabled="<%=!writePermission%>" 
200        image="restore.gif" 
201        onclick="restoreItem()" 
202        title="Restore"
203        visible="<%=batch.isRemoved()%>"
204        tooltip="<%=writePermission ? "Restore this array batch" : "You do not have permission to restore this array batch"%>" 
205      />
206      <tbl:button
207        image="add.png"
208        onclick="newSlide()"
209        title="New slide&hellip;"
210        tooltip="Create a new array slide in this batch"
211        visible="<%=sc.hasPermission(Permission.CREATE, Item.ARRAYSLIDE) && usePermission%>"
212      />
213      <tbl:button
214        image="new_wizard.gif"
215        onclick="multipleNewSlides()"
216        title="Create slides&hellip;"
217        tooltip="Create multiple new array slides in this batch using a wizard" 
218        visible="<%=sc.hasPermission(Permission.CREATE, Item.ARRAYSLIDE) && usePermission%>"
219      />
220      <tbl:button 
221        disabled="<%=!sharePermission%>"
222        image="share.gif"
223        onclick="shareItem()" 
224        title="Share&hellip;" 
225        tooltip="<%=sharePermission ? "Share this array batch to other user, groups and projects" : "You do not have permission to share this array batch"%>"
226      />
227      <tbl:button 
228        disabled="<%=!setOwnerPermission%>"
229        image="take_ownership.png"
230        onclick="setOwner()" 
231        title="Set owner&hellip;"
232        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
233      />
234      <tbl:button 
235        image="import.gif" 
236        onclick="runPlugin('ImportItem')" 
237        title="Import&hellip;" 
238        tooltip="Import data" 
239        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
240      />
241      <tbl:button 
242        image="export.gif" 
243        onclick="runPlugin('ExportItem')" 
244        title="Export&hellip;" 
245        tooltip="Export data" 
246        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
247      />
248      <tbl:button 
249        image="runplugin.gif" 
250        onclick="runPlugin('RunPlugin')" 
251        title="Run plugin&hellip;" 
252        tooltip="Run a plugin" 
253        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
254      />
255      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
256        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
257      <tbl:button
258        image="help.png"
259        onclick="<%="Main.openHelp('" + ID +"', 'arraybatch.view.properties')"%>"
260        title="Help&hellip;"
261        tooltip="Get help about this page"
262      />
263      </tbl:toolbar>
264    <div class="boxedbottom">
265      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(batch)%></i></div>
266      <%
267      if (batch.isRemoved() || batch.isShared())
268      {
269        %>
270        <div class="itemstatus">
271          <base:icon 
272            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
273            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
274            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
275            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
276          <base:icon image="used.gif" 
277            onclick="showUsingItems()"
278            tooltip="Show the items that are using this one"
279            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
280          <base:icon image="shared.gif" 
281            visible="<%=batch.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
282        </div>
283        <%
284      }
285      %>
286      <table class="form" cellspacing="0">
287      <tr>
288        <td class="prompt">Name</td>
289        <td><%=HTML.encodeTags(batch.getName())%></td>
290      </tr>
291      <tr>
292        <td class="prompt">Registered</td>
293        <td><%=dateFormatter.format(batch.getEntryDate())%></td>
294      </tr>
295      <tr>
296        <td class="prompt">Array design</td>
297        <td><base:propertyvalue item="<%=batch%>" property="arrayDesign" /></td>
298      </tr>
299      <tr>
300        <td class="prompt">Print robot</td>
301        <td><base:propertyvalue item="<%=batch%>" property="printRobot" /></td>
302      </tr>
303      <tr>
304        <td class="prompt">Protocol</td>
305        <td><base:propertyvalue item="<%=batch%>" property="protocol" /></td>
306      </tr>
307      <tr>
308        <td class="prompt">Owner</td>
309        <td><base:propertyvalue item="<%=batch%>" property="owner" /></td>
310      </tr>
311      <tr>
312        <td class="prompt">Description</td>
313        <td><%=HTML.niceFormat(batch.getDescription())%></td>
314      </tr>
315      </table>
316     
317      <%
318      ItemQuery<ArraySlide> slideQuery = batch.getArraySlides();
319      slideQuery.include(Include.ALL);
320      slideQuery.order(Orders.asc(Hql.property("name")));
321      ItemResultList<ArraySlide> slides = slideQuery.list(dc);
322      if (slides.size() == 0)
323      {
324        %>
325        <h4>Array slides</h4>
326        No slides exists in this batch
327        (or, you don't have permission to view them).
328        <%
329      }
330      else
331      {
332        %>
333        <base:section 
334          id="batchSection" 
335          title="<%="Array slides (" + slides.size() + ")"%>"
336          context="<%=cc %>"
337          >
338          <tbl:table
339            id="batches"
340           
341            columns="all"
342            >
343          <tbl:columndef 
344            id="name"
345            title="Name"
346          />
347          <tbl:columndef
348            id="hybridization"
349            title="Hybridization"
350          />
351          <tbl:columndef 
352            id="description"
353            title="Description"
354          />
355          <tbl:data>
356            <tbl:columns>
357            </tbl:columns>
358            <tbl:rows>
359            <%
360            for (ArraySlide item : slides)
361            {
362              %>
363              <tbl:row>
364                <tbl:cell column="name"><base:icon 
365                    image="deleted.gif" 
366                    tooltip="This item has been scheduled for deletion" 
367                    visible="<%=item.isRemoved()%>"
368                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
369                <tbl:cell column="hybridization"><base:propertyvalue item="<%=item%>" property="hybridization" /></tbl:cell>
370                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
371              </tbl:row>
372              <%
373            }
374            %>
375            </tbl:rows>
376          </tbl:data>
377          </tbl:table>
378        </base:section>
379        <%
380      }     
381      %>
382      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
383        <jsp:param name="ID" value="<%=ID%>" />
384        <jsp:param name="item_type" value="<%=itemType.name()%>" />
385        <jsp:param name="item_id" value="<%=itemId%>" />
386        <jsp:param name="title" value="Other items related to this batch" />
387      </jsp:include>
388      <jsp:include page="../../common/share/list_share.jsp">
389        <jsp:param name="ID" value="<%=ID%>" />
390        <jsp:param name="item_type" value="<%=itemType.name()%>" />
391        <jsp:param name="item_id" value="<%=itemId%>" />
392        <jsp:param name="title" value="Shared to" />
393      </jsp:include>
394      </div>
395      </t:tab>
396     
397      <t:tab id="annotations" title="Annotations &amp; parameters" 
398        tooltip="View annotation values and protocol parameters" clazz="white">
399        <jsp:include page="../../common/annotations/list_annotations.jsp">
400          <jsp:param name="item_type" value="<%=itemType.name()%>" />
401          <jsp:param name="item_id" value="<%=itemId%>" />
402          <jsp:param name="ID" value="<%=ID%>" />
403        </jsp:include>
404      </t:tab>
405
406      <t:tab id="overview" title="Overview" 
407        tooltip="Display a tree overview of related items">
408        <%
409        if ("overview".equals(tab))
410        {
411          %>
412          <jsp:include page="../../common/overview/overview.jsp">
413            <jsp:param name="item_type" value="<%=itemType.name()%>" />
414            <jsp:param name="item_id" value="<%=itemId%>" />
415            <jsp:param name="ID" value="<%=ID%>" />
416          </jsp:include>
417          <%
418        }
419        %>
420      </t:tab>
421      <t:tab id="history" title="Change history" 
422        tooltip="Displays a log of all modifications made to this item"
423        visible="<%=ChangeHistoryUtil.showChangeHistoryTab(sc)%>">
424        <%
425        if ("history".equals(tab))
426        {
427          %>
428          <jsp:include page="../../common/history/frameset.jsp">
429            <jsp:param name="source_type" value="<%=itemType.name()%>" />
430            <jsp:param name="source_id" value="<%=itemId%>" />
431            <jsp:param name="ID" value="<%=ID%>" />
432          </jsp:include>
433          <%
434        }
435        %>
436      </t:tab>
437      </t:tabcontrol>
438
439  </base:body>
440  </base:page>
441  <%
442}
443finally
444{
445  if (dc != null) dc.close();
446}
447%>
Note: See TracBrowser for help on using the repository browser.