source: trunk/www/biomaterials/labels/view_label.jsp @ 2917

Last change on this file since 2917 was 2917, checked in by Nicklas Nordborg, 17 years ago

References #348: Take ownership of items

Implemented on all biomaterial pages

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.3 KB
Line 
1<%-- $Id: view_label.jsp 2917 2006-11-15 10:28:36Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
31  import="net.sf.basedb.core.Include"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.ItemQuery"
35  import="net.sf.basedb.core.ItemResultList"
36  import="net.sf.basedb.core.Permission"
37  import="net.sf.basedb.core.Label"
38  import="net.sf.basedb.core.LabeledExtract"
39  import="net.sf.basedb.core.User"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.PluginDefinition"
42  import="net.sf.basedb.core.plugin.GuiContext"
43  import="net.sf.basedb.core.plugin.Plugin"
44  import="net.sf.basedb.core.query.Orders"
45  import="net.sf.basedb.core.query.Hql"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.PermissionUtil"
48  import="net.sf.basedb.clients.web.util.HTML"
49  import="net.sf.basedb.util.Values"
50  import="java.util.Map"
51%>
52<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
53<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
54<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
55<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
56<%!
57  private static final Item itemType = Item.LABEL;
58  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
59%>
60<%
61final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
62final String ID = sc.getId();
63final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
64final int itemId = cc.getId();
65final float scale = Base.getScale(sc);
66final DbControl dc = sc.newDbControl();
67try
68{
69  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
70
71  String title = null;
72  Label label = Label.getById(dc, itemId);
73 
74  final boolean writePermission = label.hasPermission(Permission.WRITE);
75  final boolean deletePermission = label.hasPermission(Permission.DELETE);
76  final boolean sharePermission = label.hasPermission(Permission.SET_PERMISSION);
77  final boolean usePermission = label.hasPermission(Permission.USE);
78  final boolean setOwnerPermission = label.hasPermission(Permission.SET_OWNER);
79  final boolean isOwner = label.isOwner();
80  %>
81  <base:page title="<%=title%>">
82  <base:head scripts="tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
83    <script language="JavaScript">
84    function editItem()
85    {
86      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
87    }
88    function shareItem()
89    {
90      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareLabel', 500, 400);
91    }
92    function deleteItem()
93    {
94      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
95    }
96    function restoreItem()
97    {
98      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
99    }
100    function takeOwnership()
101    {
102      if (confirm('Are you sure that you want to take ownership of this item? It can\'t be undone.'))
103      {
104        location.replace('index.jsp?ID=<%=ID%>&cmd=TakeOwnershipOfItem&item_id=<%=itemId%>');
105      }
106    }
107    function runPlugin(cmd)
108    {
109      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
110    }
111    function newLabeledExtract()
112    {
113      Main.viewOrEditItem('<%=ID%>', 'LABELEDEXTRACT', 0, true, '&label_id='+<%=itemId%>);
114    }
115    </script>
116  </base:head>
117  <base:body>
118    <p>
119    <p:path>
120      <p:pathelement title="Labels" href="<%="index.jsp?ID="+ID%>" />
121      <p:pathelement title="<%=HTML.encodeTags(label.getName())%>" />
122    </p:path>
123   
124    <t:tabcontrol id="main" active="properties">
125    <t:tab id="properties" title="Properties">
126    <tbl:toolbar
127      >
128      <tbl:button 
129        disabled="<%=writePermission ? false : true%>" 
130        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
131        onclick="editItem()" 
132        title="Edit&hellip;" 
133        tooltip="<%=writePermission ? "Edit this label" : "You do not have permission to edit this label"%>" 
134      />
135      <tbl:button 
136        disabled="<%=deletePermission ? false : true%>" 
137        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
138        onclick="deleteItem()" 
139        title="Delete"
140        visible="<%=!label.isRemoved()%>"
141        tooltip="<%=deletePermission ? "Delete this label" : "You do not have permission to delete this label"%>" 
142      />
143      <tbl:button 
144        disabled="<%=writePermission ? false : true%>" 
145        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
146        onclick="restoreItem()" 
147        title="Restore"
148        visible="<%=label.isRemoved()%>"
149        tooltip="<%=writePermission ? "Restore this label" : "You do not have permission to restore this label"%>" 
150      />
151      <tbl:button 
152        disabled="<%=sharePermission ? false : true%>"
153        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
154        onclick="shareItem()" 
155        title="Share&hellip;" 
156        tooltip="<%=sharePermission ? "Share this label to other user, groups and projects" : "You do not have permission to share this label"%>"
157      />
158      <tbl:button 
159        disabled="<%=setOwnerPermission ? false : true%>"
160        image="<%=setOwnerPermission ? "take_ownership.png" : "take_ownership_disabled.png"%>"
161        onclick="takeOwnership()" 
162        title="Take ownership&hellip;"
163        visible="<%=!isOwner%>"
164        tooltip="<%=setOwnerPermission ? "Take ownership of this item" : "You do not have permission to take ownership of this item"%>"
165      />
166      <tbl:button
167        image="add.png"
168        onclick="newLabeledExtract()"
169        title="New labeled extract&hellip;"
170        tooltip="Create a new labeled extract with this label"
171        visible="<%=sc.hasPermission(Permission.CREATE, Item.LABEL) && usePermission%>" 
172      />
173      <tbl:button 
174        image="import.gif" 
175        onclick="runPlugin('ImportItem')" 
176        title="Import&hellip;" 
177        tooltip="Import data" 
178        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
179      />
180      <tbl:button 
181        image="export.gif" 
182        onclick="runPlugin('ExportItem')" 
183        title="Export&hellip;" 
184        tooltip="Export data" 
185        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
186      />
187      <tbl:button 
188        image="runplugin.gif" 
189        onclick="runPlugin('RunPlugin')" 
190        title="Run plugin&hellip;" 
191        tooltip="Run a plugin" 
192        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
193      />
194      <tbl:button
195        image="help.gif"
196        onclick="<%="Main.openHelp('" + ID +"', 'label.view.properties')"%>"
197        title="Help&hellip;"
198        tooltip="Get help about this page"
199      /> 
200      </tbl:toolbar>
201    <div class="boxedbottom">
202      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(label)%></i></div>
203      <%
204      if (label.isRemoved() || label.isShared())
205      {
206        %>
207        <div class="itemstatus">
208          <base:icon image="deleted.gif" 
209            visible="<%=label.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
210          <base:icon image="shared.gif" 
211            visible="<%=label.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
212        </div>
213        <%
214      }
215      %>
216      <table class="form" cellspacing=0>
217      <tr>
218        <td class="prompt">Name</td>
219        <td><%=HTML.encodeTags(label.getName())%></td>
220      </tr>
221      <tr>
222        <td class="prompt">Owner</td>
223        <td><base:propertyvalue item="<%=label%>" property="owner"/></td>
224      </tr>
225      <tr>
226        <td class="prompt">Description</td>
227        <td><%=HTML.niceFormat(label.getDescription())%></td>
228      </tr>
229      </table>
230
231    </div>
232    </t:tab>
233    </t:tabcontrol>
234
235  </base:body>
236  </base:page>
237  <%
238}
239finally
240{
241  if (dc != null) dc.close();
242}
243
244%>
Note: See TracBrowser for help on using the repository browser.