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

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

Fixes #404: Replace deprecated Values class with the new one in all JSP pages

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.7 KB
Line 
1<%-- $Id: view_label.jsp 2753 2006-10-20 11:04: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 
79  boolean readCurrentOwner = true;
80  User currentOwner = null;
81  try
82  {
83    currentOwner = label.getOwner();
84  }
85  catch (PermissionDeniedException ex)
86  {
87    readCurrentOwner = false;
88  }
89 
90  %>
91
92  <base:page title="<%=title%>">
93  <base:head scripts="tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
94    <script language="JavaScript">
95    function editItem()
96    {
97      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
98    }
99    function shareItem()
100    {
101      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareLabel', 500, 400);
102    }
103    function deleteItem()
104    {
105      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
106    }
107    function restoreItem()
108    {
109      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
110    }
111    function runPlugin(cmd)
112    {
113      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
114    }
115    function newLabeledExtract()
116    {
117      Main.viewOrEditItem('<%=ID%>', 'LABELEDEXTRACT', 0, true, '&label_id='+<%=itemId%>);
118    }
119    </script>
120  </base:head>
121  <base:body>
122    <p>
123    <p:path>
124      <p:pathelement title="Labels" href="<%="index.jsp?ID="+ID%>" />
125      <p:pathelement title="<%=HTML.encodeTags(label.getName())%>" />
126    </p:path>
127   
128    <t:tabcontrol id="main" active="properties">
129    <t:tab id="properties" title="Properties">
130    <tbl:toolbar
131      >
132      <tbl:button 
133        disabled="<%=writePermission ? false : true%>" 
134        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
135        onclick="editItem()" 
136        title="Edit&hellip;" 
137        tooltip="<%=writePermission ? "Edit this label" : "You do not have permission to edit this label"%>" 
138      />
139      <tbl:button 
140        disabled="<%=deletePermission ? false : true%>" 
141        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
142        onclick="deleteItem()" 
143        title="Delete"
144        visible="<%=!label.isRemoved()%>"
145        tooltip="<%=deletePermission ? "Delete this label" : "You do not have permission to delete this label"%>" 
146      />
147      <tbl:button 
148        disabled="<%=writePermission ? false : true%>" 
149        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
150        onclick="restoreItem()" 
151        title="Restore"
152        visible="<%=label.isRemoved()%>"
153        tooltip="<%=writePermission ? "Restore this label" : "You do not have permission to restore this label"%>" 
154      />
155      <tbl:button 
156        disabled="<%=sharePermission ? false : true%>"
157        image="<%=sharePermission ? "share.gif" : "share_disabled.gif"%>"
158        onclick="shareItem()" 
159        title="Share&hellip;" 
160        tooltip="<%=sharePermission ? "Share this label to other user, groups and projects" : "You do not have permission to share this label"%>"
161      />
162      <tbl:button
163        image="add.png"
164        onclick="newLabeledExtract()"
165        title="New labeled extract&hellip;"
166        tooltip="Create a new labeled extract with this label"
167        visible="<%=sc.hasPermission(Permission.CREATE, Item.LABEL) && usePermission%>" 
168      />
169      <tbl:button 
170        image="import.gif" 
171        onclick="runPlugin('ImportItem')" 
172        title="Import&hellip;" 
173        tooltip="Import data" 
174        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
175      />
176      <tbl:button 
177        image="export.gif" 
178        onclick="runPlugin('ExportItem')" 
179        title="Export&hellip;" 
180        tooltip="Export data" 
181        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
182      />
183      <tbl:button 
184        image="runplugin.gif" 
185        onclick="runPlugin('RunPlugin')" 
186        title="Run plugin&hellip;" 
187        tooltip="Run a plugin" 
188        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
189      />
190      <tbl:button
191        image="help.gif"
192        onclick="<%="Main.openHelp('" + ID +"', 'label.view.properties')"%>"
193        title="Help&hellip;"
194        tooltip="Get help about this page"
195      /> 
196      </tbl:toolbar>
197    <div class="boxedbottom">
198      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(label)%></i></div>
199      <%
200      if (label.isRemoved() || label.isShared())
201      {
202        %>
203        <div class="itemstatus">
204          <base:icon image="deleted.gif" 
205            visible="<%=label.isRemoved()%>"> This item has been flagged for deletion<br></base:icon>
206          <base:icon image="shared.gif" 
207            visible="<%=label.isShared()%>"> This item is shared to other user, groups and/or projects</base:icon>
208        </div>
209        <%
210      }
211      %>
212      <table class="form" cellspacing=0>
213      <tr>
214        <td class="prompt">Name</td>
215        <td><%=HTML.encodeTags(label.getName())%></td>
216      </tr>
217      <tr>
218        <td class="prompt">Owner</td>
219        <td><base:propertyvalue item="<%=label%>" property="owner"/></td>
220      </tr>
221      <tr>
222        <td class="prompt">Description</td>
223        <td><%=HTML.niceFormat(label.getDescription())%></td>
224      </tr>
225      </table>
226
227    </div>
228    </t:tab>
229    </t:tabcontrol>
230
231  </base:body>
232  </base:page>
233  <%
234}
235finally
236{
237  if (dc != null) dc.close();
238}
239
240%>
Note: See TracBrowser for help on using the repository browser.