source: trunk/www/biomaterials/tags/view_tag.jsp @ 6261

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

References #1729 and #1730. Fixed for all biomaterial view pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.4 KB
Line 
1<%-- $Id: view_tag.jsp 6261 2013-03-27 12:25:00Z 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.Group"
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.Tag"
38  import="net.sf.basedb.core.MultiPermissions"
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.Project"
45  import="net.sf.basedb.core.query.Orders"
46  import="net.sf.basedb.core.query.Hql"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.clients.web.PermissionUtil"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.util.Values"
51  import="net.sf.basedb.util.formatter.Formatter"
52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
53  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
54  import="net.sf.basedb.clients.web.extensions.JspContext"
55  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
56  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
57  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
58  import="java.util.Date"
59  import="java.util.Collections"
60  import="java.util.Map"
61  import="java.util.Set"
62%>
63<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
64<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
65<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
66<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
67<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
68<%!
69  private static final Item itemType = Item.TAG;
70  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
71%>
72<%
73final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
74final String ID = sc.getId();
75final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
76final int itemId = cc.getId();
77final String tab = Values.getStringOrNull(request.getParameter("tab"));
78final float scale = Base.getScale(sc);
79final DbControl dc = sc.newDbControl();
80try
81{
82  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
83  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
84
85  String title = null;
86  Tag tag = Tag.getById(dc, itemId);
87 
88  final boolean writePermission = tag.hasPermission(Permission.WRITE);
89  final boolean deletePermission = tag.hasPermission(Permission.DELETE);
90  final boolean sharePermission = tag.hasPermission(Permission.SET_PERMISSION);
91  final boolean usePermission = tag.hasPermission(Permission.USE);
92  final boolean setOwnerPermission = tag.hasPermission(Permission.SET_OWNER);
93  final boolean isRemoved = tag.isRemoved();
94  final boolean isUsed = isRemoved && tag.isUsed();
95  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
96  final boolean isOwner = tag.isOwner();
97  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, tag);
98  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
99  %>
100  <base:page title="<%=title%>" id="view-page">
101  <base:head scripts="table.js,tabcontrol-2.js,~tags.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
102    <ext:scripts context="<%=jspContext%>" />
103    <ext:stylesheets context="<%=jspContext%>" />
104  </base:head>
105  <base:body>
106    <p:path><p:pathelement 
107      title="Tags" href="<%="index.jsp?ID="+ID%>" /><p:pathelement 
108      title="<%=HTML.encodeTags(tag.getName())%>" /></p:path>
109    <div id="page-data" data-item-id="<%=itemId%>"></div>
110   
111    <t:tabcontrol 
112      id="main" 
113      subclass="content mastertabcontrol" 
114      active="<%=tab%>">
115    <t:tab id="properties" title="Properties">
116      <div>
117      <table class="fullform bottomborder">
118      <tr>
119        <th class="itemstatus">
120          <base:icon 
121            image="shared.png" 
122            visible="<%=tag.isShared()%>"
123            tooltip="This item is shared to other users, groups and/or projects"
124          />
125          <base:icon 
126            id="btnDeletePermanently"
127            image="deleted.png"
128            tooltip="This item has been flagged for deletion. Click to delete it now."
129            enabled="<%=deletePermanentlyPermission %>"
130            visible="<%=isRemoved%>" 
131          />
132          <base:icon 
133            id="btnUsingItems"
134            image="used.png" 
135            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
136            visible="<%=isRemoved && isUsed%>" />
137        </th>
138        <td style="padding: 0px;">
139          <tbl:toolbar subclass="bottomborder">
140            <tbl:button 
141              id="btnEdit"
142              disabled="<%=!writePermission%>" 
143              image="edit.png" 
144              title="Edit&hellip;" 
145              tooltip="<%=writePermission ? "Edit this tag" : "You do not have permission to edit this tag"%>" 
146            />
147            <tbl:button 
148              id="btnDelete"
149              disabled="<%=!deletePermission%>" 
150              image="delete.png" 
151              title="Delete"
152              visible="<%=!tag.isRemoved()%>"
153              tooltip="<%=deletePermission ? "Delete this tag" : "You do not have permission to delete this tag"%>" 
154            />
155            <tbl:button 
156              id="btnRestore"
157              disabled="<%=!writePermission%>" 
158              image="restore.png" 
159              title="Restore"
160              visible="<%=tag.isRemoved()%>"
161              tooltip="<%=writePermission ? "Restore this tag" : "You do not have permission to restore this tag"%>" 
162            />
163            <tbl:button 
164              id="btnShare"
165              disabled="<%=!sharePermission%>"
166              image="share.png"
167              title="Share&hellip;" 
168              tooltip="<%=sharePermission ? "Share this tag to other user, groups and projects" : "You do not have permission to share this tag"%>"
169            />
170            <tbl:button 
171              id="btnSetOwner"
172              disabled="<%=!setOwnerPermission%>"
173              image="take_ownership.png"
174              title="Set owner&hellip;"
175              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
176            />
177            <tbl:button 
178              id="btnImport"
179              image="import.png" 
180              data-plugin-type="IMPORT" 
181              title="Import&hellip;" 
182              tooltip="Import data" 
183              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
184            />
185            <tbl:button 
186              id="btnExport"
187              image="export.png"
188              data-plugin-type="EXPORT" 
189              title="Export&hellip;" 
190              tooltip="Export data" 
191              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
192            />
193            <tbl:button 
194              id="btnRunPlugin"
195              image="runplugin.png" 
196              data-plugin-type="OTHER" 
197              title="Run plugin&hellip;" 
198              tooltip="Run a plugin" 
199              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
200            />
201            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
202              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
203            <tbl:button
204              image="help.png"
205              subclass="auto-init"
206              data-auto-init="help"
207              data-help-id="tag.view.properties"
208              title="Help&hellip;"
209              tooltip="Get help about this page"
210            /> 
211            </tbl:toolbar>
212          </td>
213        </tr>
214        <tr>
215          <th>Name</th>
216          <td><%=HTML.encodeTags(tag.getName())%></td>
217        </tr>
218        <tr>
219          <th>Type</th>
220          <td><base:propertyvalue item="<%=tag%>" property="itemSubtype" /></td>
221        </tr>
222        <tr>
223          <th>Registered</th>
224          <td><%=dateFormatter.format(tag.getEntryDate())%></td>
225        </tr>
226        <tr>
227          <th>Owner</th>
228          <td><base:propertyvalue item="<%=tag%>" property="owner"/></td>
229        </tr>
230        <tr>
231          <th>Permissions</th>
232          <td><%=PermissionUtil.getFullPermissionNames(tag)%></td>
233        </tr>
234        <tr>
235          <th>Description</th>
236          <td><%=HTML.niceFormat(tag.getDescription())%></td>
237        </tr>
238      </table>
239      </div>
240      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
241        <jsp:param name="ID" value="<%=ID%>" />
242        <jsp:param name="item_type" value="<%=itemType.name()%>" />
243        <jsp:param name="item_id" value="<%=itemId%>" />
244        <jsp:param name="title" value="Other items related to this tag" />
245      </jsp:include>
246      <jsp:include page="../../common/share/list_share.jsp">
247        <jsp:param name="ID" value="<%=ID%>" />
248        <jsp:param name="item_type" value="<%=itemType.name()%>" />
249        <jsp:param name="item_id" value="<%=itemId%>" />
250        <jsp:param name="title" value="Shared to" />
251      </jsp:include>
252    </t:tab>
253    </t:tabcontrol>
254
255  </base:body>
256  </base:page>
257  <%
258}
259finally
260{
261  if (dc != null) dc.close();
262}
263
264%>
Note: See TracBrowser for help on using the repository browser.