source: trunk/www/biomaterials/bioplates/view_bioplate.jsp @ 4882

Last change on this file since 4882 was 4882, checked in by Nicklas Nordborg, 13 years ago

References #1271: Add extension points to all toolbars

Added code for displaying extensions to all biomaterial pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 14.1 KB
Line 
1<%-- $Id: view_bioplate.jsp 4882 2009-04-03 10:53:42Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Hakkinen, 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 Martin
24  @version 2.10
25--%>
26<%@ page 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.BioPlate"
37  import="net.sf.basedb.core.PlateGeometry"
38  import="net.sf.basedb.core.User"
39  import="net.sf.basedb.core.ItemQuery"
40  import="net.sf.basedb.core.Include"
41  import="net.sf.basedb.core.ItemResultIterator"
42  import="net.sf.basedb.core.ItemResultList"
43  import="net.sf.basedb.core.MultiPermissions"
44  import="net.sf.basedb.core.PermissionDeniedException"
45  import="net.sf.basedb.core.PluginDefinition"
46  import="net.sf.basedb.core.plugin.GuiContext"
47  import="net.sf.basedb.core.plugin.Plugin"
48  import="net.sf.basedb.core.Project"
49  import="net.sf.basedb.core.query.Orders"
50  import="net.sf.basedb.core.query.Hql"
51  import="net.sf.basedb.clients.web.Base"
52  import="net.sf.basedb.clients.web.PermissionUtil"
53  import="net.sf.basedb.clients.web.util.HTML"
54  import="net.sf.basedb.util.Values"
55  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
56  import="net.sf.basedb.clients.web.extensions.JspContext"
57  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
58  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
59  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
60  import="java.util.Collections"
61  import="java.util.Date"
62  import="java.util.Map"
63  import="java.util.Set"
64  import="java.util.List"
65%>
66<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
67<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
68<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
69<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
70<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
71<%!
72  private static final Item itemType = Item.BIOPLATE;
73  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
74%>
75<%
76final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
77final String ID = sc.getId();
78final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
79final int itemId = cc.getId();
80final String tab = Values.getString(request.getParameter("tab"), "properties");
81final float scale = Base.getScale(sc);
82final DbControl dc = sc.newDbControl();
83try
84{
85  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
86
87  String title = null;
88  BioPlate bioplate = BioPlate.getById(dc, itemId);
89 
90  final boolean writePermission = bioplate.hasPermission(Permission.WRITE);
91  final boolean deletePermission = bioplate.hasPermission(Permission.DELETE);
92  final boolean sharePermission = bioplate.hasPermission(Permission.SET_PERMISSION);
93  final boolean setOwnerPermission = bioplate.hasPermission(Permission.SET_OWNER);
94  final boolean isRemoved = bioplate.isRemoved();
95  final boolean isUsed = isRemoved && bioplate.isUsed();
96  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
97  final boolean isOwner = bioplate.isOwner();
98  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, bioplate);
99  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
100  %>
101  <base:page title="<%=title%>">
102  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
103    <ext:scripts context="<%=jspContext%>" />
104    <ext:stylesheets context="<%=jspContext%>" />
105    <script language="JavaScript">
106    function editItem()
107    {
108      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
109    }
110    function shareItem()
111    {
112      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'SharePlate', 600, 400);
113    }
114    function deleteItem()
115    {
116      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
117    }
118    function restoreItem()
119    {
120      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
121    }
122    function deleteItemPermanently()
123    {
124      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
125    }
126    function itemDeleted()
127    {
128      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
129    }
130    function showUsingItems()
131    {
132      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
133    }
134    function setOwner()
135    {
136      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 150);
137    }
138    function runPlugin(cmd)
139    {
140      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
141    }
142    function viewWells()
143    {
144      location.href = 'wells/index.jsp?ID=<%=ID%>&bioplate_id=<%=itemId%>';
145    }
146    function switchTab(tabControlId, tabId)
147    {
148      if (tabId == 'wells')
149      {
150        viewWells();
151      }
152      else
153      {
154        TabControl.setActiveTab(tabControlId, tabId);
155      }
156    }
157    </script>
158  </base:head>
159  <base:body>
160    <p>
161    <p:path>
162      <p:pathelement title="Bioplates" href="<%="index.jsp?ID="+ID%>" />
163      <p:pathelement title="<%=HTML.encodeTags(bioplate.getName())%>" />
164    </p:path>
165   
166    <t:tabcontrol id="main" active="<%=tab%>" switch="switchTab">
167    <t:tab id="properties" title="Properties">
168    <tbl:toolbar
169      >
170      <tbl:button 
171        disabled="<%=writePermission ? false : true%>" 
172        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
173        onclick="editItem()" 
174        title="Edit&hellip;" 
175        tooltip="<%=writePermission ? "Edit this bioplate" : "You do not have permission to edit this bioplate"%>" 
176      />
177      <tbl:button 
178        disabled="<%=deletePermission ? false : true%>" 
179        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
180        onclick="deleteItem()" 
181        title="Delete"
182        visible="<%=!bioplate.isRemoved()%>"
183        tooltip="<%=deletePermission ? "Delete this bioplate" : "You do not have permission to delete this bioplate"%>" 
184      />
185      <tbl:button 
186        disabled="<%=writePermission ? false : true%>" 
187        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
188        onclick="restoreItem()" 
189        title="Restore"
190        visible="<%=bioplate.isRemoved()%>"
191        tooltip="<%=writePermission ? "Restore this bioplate" : "You do not have permission to restore this bioplate"%>" 
192      />
193      <tbl:button 
194        disabled="<%=sharePermission ? false : true%>"
195        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
196        onclick="shareItem()" 
197        title="Share&hellip;" 
198        tooltip="<%=sharePermission ? "Share this bioplate to other user, groups and projects" : "You do not have permission to share this bioplate"%>"
199      />
200      <tbl:button 
201        disabled="<%=setOwnerPermission ? false : true%>"
202        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
203        onclick="setOwner()" 
204        title="Set owner&hellip;"
205        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
206      />
207      <tbl:button 
208        image="import.gif" 
209        onclick="runPlugin('ImportItem')" 
210        title="Import&hellip;" 
211        tooltip="Import data" 
212        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
213      />
214      <tbl:button 
215        image="export.gif" 
216        onclick="runPlugin('ExportItem')" 
217        title="Export&hellip;" 
218        tooltip="Export data" 
219        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
220      />
221      <tbl:button 
222        image="runplugin.gif" 
223        onclick="runPlugin('RunPlugin')" 
224        title="Run plugin&hellip;" 
225        tooltip="Run a plugin" 
226        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
227      />
228      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
229        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
230      <tbl:button
231        image="help.gif"
232        onclick="<%="Main.openHelp('" + ID +"', 'plate.view.properties')"%>"
233        title="Help&hellip;"
234        tooltip="Get help about this page"
235      />
236      </tbl:toolbar>
237    <div class="boxedbottom">
238      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(bioplate)%></i></div>
239      <%
240      if (bioplate.isRemoved() || bioplate.isShared())
241      {
242        %>
243        <div class="itemstatus">
244          <base:icon 
245            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
246            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
247            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
248            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
249          <base:icon image="used.gif" 
250            onclick="showUsingItems()"
251            tooltip="Show the items that are using this one"
252            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
253          <base:icon image="shared.gif" 
254            visible="<%=bioplate.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
255        </div>
256        <%
257      }
258      %>
259      <table class="form" cellspacing="0">
260      <tr>
261        <td class="prompt">Name</td>
262        <td><%=HTML.encodeTags(bioplate.getName())%></td>
263      </tr>
264      <tr>
265        <td class="prompt">Barcode</td>
266        <td><%=HTML.encodeTags(bioplate.getBarcode())%></td>
267      </tr>
268      <tr>
269        <td class="prompt">Geometry</td>
270        <td><base:propertyvalue item="<%=bioplate%>" property="plateGeometry" /></td>
271      </tr>
272      <tr>
273        <td class="prompt">Freezer</td>
274        <td><base:propertyvalue item="<%=bioplate%>" property="freezer"></base:propertyvalue>
275      </tr>
276      <tr>
277        <td class="prompt">Owner</td>
278        <td><base:propertyvalue item="<%=bioplate%>" property="owner" /></td>
279      </tr>
280      <tr>
281        <td class="prompt">Description</td>
282        <td><%=HTML.niceFormat(bioplate.getDescription())%></td>
283      </tr>
284      </table>
285     
286      <%
287     
288      // Tables with users/groups/projects that this item is shared to
289      MultiPermissions mp = new MultiPermissions(Collections.singleton(bioplate));
290      ItemResultIterator<User> users = mp.getUsers().iterate(dc);
291      ItemResultIterator<Group> groups = mp.getGroups().iterate(dc);
292      ItemResultIterator<Project> projects = mp.getProjects().iterate(dc);
293     
294      if (users.hasNext() || groups.hasNext() || projects.hasNext())
295      {
296        %>
297        <h4 class="docked">Shared to</h4>
298        <tbl:table 
299          id="itemsSharedTo"
300          clazz="itemlist"
301          columns="all"
302        >
303          <tbl:columndef 
304            id="itemType"
305            title="Item type"
306          />
307          <tbl:columndef 
308            id="name"
309            title="Name"
310          />
311          <tbl:columndef 
312            id="permissions"
313            title="Permissions"
314          />
315          <tbl:data>
316            <tbl:columns>
317            </tbl:columns>
318            <tbl:rows>
319            <%
320            while(projects.hasNext())
321            {
322              Project project = projects.next();
323              Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
324              %>     
325              <tbl:row>
326                <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
327                <tbl:cell column="name"><base:icon 
328                  image="deleted.gif" 
329                  tooltip="This item has been scheduled for deletion" 
330                  visible="<%=project.isRemoved()%>"
331                /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
332                <tbl:cell column="permissions">
333                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
334                </tbl:cell>
335              </tbl:row>
336              <%
337            }
338            while(groups.hasNext())
339            {
340              Group group = groups.next();
341              Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
342              %>
343              <tbl:row>             
344                <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
345                <tbl:cell column="name"><base:icon 
346                  image="deleted.gif" 
347                  tooltip="This item has been scheduled for deletion" 
348                  visible="<%=group.isRemoved()%>"
349                /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
350                <tbl:cell column="permissions">
351                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
352                </tbl:cell>
353              </tbl:row>
354              <% 
355            }
356            while (users.hasNext())
357            {
358              User user = users.next();
359              Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
360              %>
361              <tbl:row>             
362                <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
363                <tbl:cell column="name"><base:icon 
364                  image="deleted.gif" 
365                  tooltip="This item has been scheduled for deletion" 
366                  visible="<%=user.isRemoved()%>"
367                /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
368                <tbl:cell column="permissions">
369                  <%=PermissionUtil.translatePermissionsToString(permissions)%>
370                </tbl:cell>
371              </tbl:row>
372              <%
373            }
374            %>
375            </tbl:rows>
376          </tbl:data>
377        </tbl:table>
378        <%
379      }
380      else
381      {
382        %>
383        <h4>Shared to</h4>
384        This bioplate is not shared
385        (or, you don't have permission to view the ones it is shared to).
386        <%
387      }
388      %>
389
390
391    </div>
392      </t:tab>
393     
394      <t:tab id="annotations" title="Annotations" >
395        <div class="boxed">
396        <jsp:include page="../../common/annotations/list_annotations.jsp">
397          <jsp:param name="item_type" value="<%=itemType.name()%>" />
398          <jsp:param name="item_id" value="<%=itemId%>" />
399          <jsp:param name="ID" value="<%=ID%>" />
400        </jsp:include>
401        </div>
402      </t:tab>
403      <t:tab id="wells" title="Wells" />
404      </t:tabcontrol>
405  </base:body>
406  </base:page>
407  <%
408}
409finally
410{
411  if (dc != null) dc.close();
412}
413%>
Note: See TracBrowser for help on using the repository browser.