1 | <%-- $Id: view_tag.jsp 6136 2012-09-18 11:15:20Z 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 | <% |
---|
73 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
74 | final String ID = sc.getId(); |
---|
75 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
76 | final int itemId = cc.getId(); |
---|
77 | final float scale = Base.getScale(sc); |
---|
78 | final DbControl dc = sc.newDbControl(); |
---|
79 | try |
---|
80 | { |
---|
81 | Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc); |
---|
82 | Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
---|
83 | |
---|
84 | String title = null; |
---|
85 | Tag tag = Tag.getById(dc, itemId); |
---|
86 | |
---|
87 | final boolean writePermission = tag.hasPermission(Permission.WRITE); |
---|
88 | final boolean deletePermission = tag.hasPermission(Permission.DELETE); |
---|
89 | final boolean sharePermission = tag.hasPermission(Permission.SET_PERMISSION); |
---|
90 | final boolean usePermission = tag.hasPermission(Permission.USE); |
---|
91 | final boolean setOwnerPermission = tag.hasPermission(Permission.SET_OWNER); |
---|
92 | final boolean isRemoved = tag.isRemoved(); |
---|
93 | final boolean isUsed = isRemoved && tag.isUsed(); |
---|
94 | final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
---|
95 | final boolean isOwner = tag.isOwner(); |
---|
96 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, tag); |
---|
97 | ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext); |
---|
98 | %> |
---|
99 | <base:page title="<%=title%>"> |
---|
100 | <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css"> |
---|
101 | <ext:scripts context="<%=jspContext%>" /> |
---|
102 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
103 | <script> |
---|
104 | function editItem() |
---|
105 | { |
---|
106 | Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true); |
---|
107 | } |
---|
108 | function shareItem() |
---|
109 | { |
---|
110 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareTag', 600, 400); |
---|
111 | } |
---|
112 | function deleteItem() |
---|
113 | { |
---|
114 | location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>'); |
---|
115 | } |
---|
116 | function restoreItem() |
---|
117 | { |
---|
118 | location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>'); |
---|
119 | } |
---|
120 | function deleteItemPermanently() |
---|
121 | { |
---|
122 | Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted'); |
---|
123 | } |
---|
124 | function itemDeleted() |
---|
125 | { |
---|
126 | Main.listItems('<%=ID%>', '<%=itemType.name()%>'); |
---|
127 | } |
---|
128 | function showUsingItems() |
---|
129 | { |
---|
130 | Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>); |
---|
131 | } |
---|
132 | function setOwner() |
---|
133 | { |
---|
134 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300); |
---|
135 | } |
---|
136 | function runPlugin(cmd) |
---|
137 | { |
---|
138 | Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500); |
---|
139 | } |
---|
140 | </script> |
---|
141 | </base:head> |
---|
142 | <base:body> |
---|
143 | <p:path><p:pathelement |
---|
144 | title="Tags" href="<%="index.jsp?ID="+ID%>" /><p:pathelement |
---|
145 | title="<%=HTML.encodeTags(tag.getName())%>" /></p:path> |
---|
146 | |
---|
147 | <t:tabcontrol |
---|
148 | id="main" |
---|
149 | subclass="content mastertabcontrol" |
---|
150 | active="properties"> |
---|
151 | <t:tab id="properties" title="Properties"> |
---|
152 | <div> |
---|
153 | <table class="fullform bottomborder"> |
---|
154 | <tr> |
---|
155 | <th class="itemstatus"> |
---|
156 | <base:icon |
---|
157 | image="shared.png" |
---|
158 | visible="<%=tag.isShared()%>" |
---|
159 | tooltip="This item is shared to other users, groups and/or projects" |
---|
160 | /> |
---|
161 | <base:icon |
---|
162 | image="deleted.png" |
---|
163 | onclick="deleteItemPermanently()" |
---|
164 | tooltip="This item has been flagged for deletion. Click to delete it now." |
---|
165 | enabled="<%=deletePermanentlyPermission %>" |
---|
166 | visible="<%=isRemoved%>" |
---|
167 | /> |
---|
168 | <base:icon image="used.png" |
---|
169 | onclick="showUsingItems()" |
---|
170 | tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one" |
---|
171 | visible="<%=isRemoved && isUsed%>" /> |
---|
172 | </th> |
---|
173 | <td style="padding: 0px;"> |
---|
174 | <tbl:toolbar subclass="bottomborder"> |
---|
175 | <tbl:button |
---|
176 | disabled="<%=!writePermission%>" |
---|
177 | image="edit.png" |
---|
178 | onclick="editItem()" |
---|
179 | title="Edit…" |
---|
180 | tooltip="<%=writePermission ? "Edit this tag" : "You do not have permission to edit this tag"%>" |
---|
181 | /> |
---|
182 | <tbl:button |
---|
183 | disabled="<%=!deletePermission%>" |
---|
184 | image="delete.png" |
---|
185 | onclick="deleteItem()" |
---|
186 | title="Delete" |
---|
187 | visible="<%=!tag.isRemoved()%>" |
---|
188 | tooltip="<%=deletePermission ? "Delete this tag" : "You do not have permission to delete this tag"%>" |
---|
189 | /> |
---|
190 | <tbl:button |
---|
191 | disabled="<%=!writePermission%>" |
---|
192 | image="restore.png" |
---|
193 | onclick="restoreItem()" |
---|
194 | title="Restore" |
---|
195 | visible="<%=tag.isRemoved()%>" |
---|
196 | tooltip="<%=writePermission ? "Restore this tag" : "You do not have permission to restore this tag"%>" |
---|
197 | /> |
---|
198 | <tbl:button |
---|
199 | disabled="<%=!sharePermission%>" |
---|
200 | image="share.png" |
---|
201 | onclick="shareItem()" |
---|
202 | title="Share…" |
---|
203 | tooltip="<%=sharePermission ? "Share this tag to other user, groups and projects" : "You do not have permission to share this tag"%>" |
---|
204 | /> |
---|
205 | <tbl:button |
---|
206 | disabled="<%=!setOwnerPermission%>" |
---|
207 | image="take_ownership.png" |
---|
208 | onclick="setOwner()" |
---|
209 | title="Set owner…" |
---|
210 | tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>" |
---|
211 | /> |
---|
212 | <tbl:button |
---|
213 | image="import.png" |
---|
214 | onclick="runPlugin('ImportItem')" |
---|
215 | title="Import…" |
---|
216 | tooltip="Import data" |
---|
217 | visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
---|
218 | /> |
---|
219 | <tbl:button |
---|
220 | image="export.png" |
---|
221 | onclick="runPlugin('ExportItem')" |
---|
222 | title="Export…" |
---|
223 | tooltip="Export data" |
---|
224 | visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
---|
225 | /> |
---|
226 | <tbl:button |
---|
227 | image="runplugin.png" |
---|
228 | onclick="runPlugin('RunPlugin')" |
---|
229 | title="Run plugin…" |
---|
230 | tooltip="Run a plugin" |
---|
231 | visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
---|
232 | /> |
---|
233 | <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
---|
234 | wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/> |
---|
235 | <tbl:button |
---|
236 | image="help.png" |
---|
237 | onclick="<%="Main.openHelp('" + ID +"', 'tag.view.properties')"%>" |
---|
238 | title="Help…" |
---|
239 | tooltip="Get help about this page" |
---|
240 | /> |
---|
241 | </tbl:toolbar> |
---|
242 | </td> |
---|
243 | </tr> |
---|
244 | <tr> |
---|
245 | <th>Name</th> |
---|
246 | <td><%=HTML.encodeTags(tag.getName())%></td> |
---|
247 | </tr> |
---|
248 | <tr> |
---|
249 | <th>Type</th> |
---|
250 | <td><base:propertyvalue item="<%=tag%>" property="itemSubtype" /></td> |
---|
251 | </tr> |
---|
252 | <tr> |
---|
253 | <th>Registered</th> |
---|
254 | <td><%=dateFormatter.format(tag.getEntryDate())%></td> |
---|
255 | </tr> |
---|
256 | <tr> |
---|
257 | <th>Owner</th> |
---|
258 | <td><base:propertyvalue item="<%=tag%>" property="owner"/></td> |
---|
259 | </tr> |
---|
260 | <tr> |
---|
261 | <th>Permissions</th> |
---|
262 | <td><%=PermissionUtil.getFullPermissionNames(tag)%></td> |
---|
263 | </tr> |
---|
264 | <tr> |
---|
265 | <th>Description</th> |
---|
266 | <td><%=HTML.niceFormat(tag.getDescription())%></td> |
---|
267 | </tr> |
---|
268 | </table> |
---|
269 | </div> |
---|
270 | <jsp:include page="../../common/anytoany/list_anytoany.jsp"> |
---|
271 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
272 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
273 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
274 | <jsp:param name="title" value="Other items related to this tag" /> |
---|
275 | </jsp:include> |
---|
276 | <jsp:include page="../../common/share/list_share.jsp"> |
---|
277 | <jsp:param name="ID" value="<%=ID%>" /> |
---|
278 | <jsp:param name="item_type" value="<%=itemType.name()%>" /> |
---|
279 | <jsp:param name="item_id" value="<%=itemId%>" /> |
---|
280 | <jsp:param name="title" value="Shared to" /> |
---|
281 | </jsp:include> |
---|
282 | </t:tab> |
---|
283 | </t:tabcontrol> |
---|
284 | |
---|
285 | </base:body> |
---|
286 | </base:page> |
---|
287 | <% |
---|
288 | } |
---|
289 | finally |
---|
290 | { |
---|
291 | if (dc != null) dc.close(); |
---|
292 | } |
---|
293 | |
---|
294 | %> |
---|