4543 |
22 Sep 08 |
nicklas |
1 |
<%-- $Id$ |
4543 |
22 Sep 08 |
nicklas |
2 |
------------------------------------------------------------------ |
4889 |
06 Apr 09 |
nicklas |
Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson |
4543 |
22 Sep 08 |
nicklas |
4 |
|
4543 |
22 Sep 08 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
4543 |
22 Sep 08 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
4543 |
22 Sep 08 |
nicklas |
7 |
|
4543 |
22 Sep 08 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
4543 |
22 Sep 08 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4543 |
22 Sep 08 |
nicklas |
10 |
as published by the Free Software Foundation; either version 3 |
4543 |
22 Sep 08 |
nicklas |
11 |
of the License, or (at your option) any later version. |
4543 |
22 Sep 08 |
nicklas |
12 |
|
4543 |
22 Sep 08 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
4543 |
22 Sep 08 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4543 |
22 Sep 08 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4543 |
22 Sep 08 |
nicklas |
16 |
GNU General Public License for more details. |
4543 |
22 Sep 08 |
nicklas |
17 |
|
4543 |
22 Sep 08 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4543 |
22 Sep 08 |
nicklas |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4543 |
22 Sep 08 |
nicklas |
20 |
------------------------------------------------------------------ |
4543 |
22 Sep 08 |
nicklas |
21 |
|
4543 |
22 Sep 08 |
nicklas |
22 |
@author Nicklas |
4543 |
22 Sep 08 |
nicklas |
23 |
@version 2.0 |
4543 |
22 Sep 08 |
nicklas |
24 |
--%> |
5426 |
24 Sep 10 |
nicklas |
25 |
<%@ page pageEncoding="UTF-8" session="false" |
4543 |
22 Sep 08 |
nicklas |
26 |
import="net.sf.basedb.core.SessionControl" |
4543 |
22 Sep 08 |
nicklas |
27 |
import="net.sf.basedb.core.DbControl" |
4543 |
22 Sep 08 |
nicklas |
28 |
import="net.sf.basedb.core.SystemItems" |
4543 |
22 Sep 08 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
4543 |
22 Sep 08 |
nicklas |
30 |
import="net.sf.basedb.core.ItemContext" |
4543 |
22 Sep 08 |
nicklas |
31 |
import="net.sf.basedb.core.Permission" |
4543 |
22 Sep 08 |
nicklas |
32 |
import="net.sf.basedb.core.Quantity" |
4543 |
22 Sep 08 |
nicklas |
33 |
import="net.sf.basedb.core.Unit" |
4543 |
22 Sep 08 |
nicklas |
34 |
import="net.sf.basedb.core.PermissionDeniedException" |
4543 |
22 Sep 08 |
nicklas |
35 |
import="net.sf.basedb.core.PluginDefinition" |
4543 |
22 Sep 08 |
nicklas |
36 |
import="net.sf.basedb.core.data.RawData" |
4543 |
22 Sep 08 |
nicklas |
37 |
import="net.sf.basedb.core.plugin.GuiContext" |
4543 |
22 Sep 08 |
nicklas |
38 |
import="net.sf.basedb.core.plugin.Plugin" |
4543 |
22 Sep 08 |
nicklas |
39 |
import="net.sf.basedb.clients.web.Base" |
4543 |
22 Sep 08 |
nicklas |
40 |
import="net.sf.basedb.clients.web.PermissionUtil" |
4543 |
22 Sep 08 |
nicklas |
41 |
import="net.sf.basedb.clients.web.util.HTML" |
4543 |
22 Sep 08 |
nicklas |
42 |
import="net.sf.basedb.util.Values" |
4886 |
03 Apr 09 |
nicklas |
43 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
4886 |
03 Apr 09 |
nicklas |
44 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
4886 |
03 Apr 09 |
nicklas |
45 |
import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer" |
7604 |
25 Feb 19 |
nicklas |
46 |
import="net.sf.basedb.clients.web.extensions.toolbar.ButtonAction" |
4886 |
03 Apr 09 |
nicklas |
47 |
import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil" |
4886 |
03 Apr 09 |
nicklas |
48 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
4543 |
22 Sep 08 |
nicklas |
49 |
import="java.util.Date" |
4543 |
22 Sep 08 |
nicklas |
50 |
import="java.util.Map" |
4543 |
22 Sep 08 |
nicklas |
51 |
import="java.util.Set" |
4543 |
22 Sep 08 |
nicklas |
52 |
%> |
4543 |
22 Sep 08 |
nicklas |
53 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
4543 |
22 Sep 08 |
nicklas |
54 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
4543 |
22 Sep 08 |
nicklas |
55 |
<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %> |
4543 |
22 Sep 08 |
nicklas |
56 |
<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %> |
4886 |
03 Apr 09 |
nicklas |
57 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
4543 |
22 Sep 08 |
nicklas |
58 |
<%! |
4543 |
22 Sep 08 |
nicklas |
59 |
private static final Item itemType = Item.UNIT; |
4543 |
22 Sep 08 |
nicklas |
60 |
private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM); |
4543 |
22 Sep 08 |
nicklas |
61 |
%> |
4543 |
22 Sep 08 |
nicklas |
62 |
<% |
4543 |
22 Sep 08 |
nicklas |
63 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4543 |
22 Sep 08 |
nicklas |
64 |
final String ID = sc.getId(); |
4543 |
22 Sep 08 |
nicklas |
65 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
4543 |
22 Sep 08 |
nicklas |
66 |
final int itemId = cc.getId(); |
6289 |
05 Jun 13 |
nicklas |
67 |
final String tab = Values.getStringOrNull(request.getParameter("tab")); |
4543 |
22 Sep 08 |
nicklas |
68 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
69 |
final DbControl dc = sc.newDbControl(":View "+itemType); |
4543 |
22 Sep 08 |
nicklas |
70 |
try |
4543 |
22 Sep 08 |
nicklas |
71 |
{ |
4543 |
22 Sep 08 |
nicklas |
72 |
Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext); |
4543 |
22 Sep 08 |
nicklas |
73 |
|
4543 |
22 Sep 08 |
nicklas |
74 |
String title = null; |
4543 |
22 Sep 08 |
nicklas |
75 |
final Unit unit = Unit.getById(dc, itemId); |
4543 |
22 Sep 08 |
nicklas |
76 |
final Quantity quantity = unit.getQuantity(); |
4543 |
22 Sep 08 |
nicklas |
77 |
final int quantityId = quantity.getId(); |
4543 |
22 Sep 08 |
nicklas |
78 |
|
4543 |
22 Sep 08 |
nicklas |
79 |
Set<String> symbols = unit.getSymbols(); |
4543 |
22 Sep 08 |
nicklas |
80 |
symbols.remove(unit.getDisplaySymbol()); |
4543 |
22 Sep 08 |
nicklas |
81 |
symbols.add("<b>" + unit.getDisplaySymbol() + "</b>"); |
4543 |
22 Sep 08 |
nicklas |
82 |
|
4543 |
22 Sep 08 |
nicklas |
83 |
StringBuilder formula = new StringBuilder(); |
4543 |
22 Sep 08 |
nicklas |
84 |
formula.append("1").append(unit.getDisplaySymbol()).append(" = "); |
4543 |
22 Sep 08 |
nicklas |
85 |
if (unit.getReferenceFactor() != 1.0) |
4543 |
22 Sep 08 |
nicklas |
86 |
{ |
4888 |
06 Apr 09 |
nicklas |
87 |
formula.append(unit.getReferenceFactor()).append(" × "); |
4543 |
22 Sep 08 |
nicklas |
88 |
} |
4543 |
22 Sep 08 |
nicklas |
89 |
formula.append(quantity.getReferenceUnit()); |
4543 |
22 Sep 08 |
nicklas |
90 |
if (unit.getReferenceOffset() != 0.0) |
4543 |
22 Sep 08 |
nicklas |
91 |
{ |
4543 |
22 Sep 08 |
nicklas |
92 |
formula.append(" + ").append(unit.getReferenceOffset()); |
4543 |
22 Sep 08 |
nicklas |
93 |
} |
4543 |
22 Sep 08 |
nicklas |
94 |
|
4543 |
22 Sep 08 |
nicklas |
95 |
final boolean writePermission = unit.hasPermission(Permission.WRITE); |
4543 |
22 Sep 08 |
nicklas |
96 |
final boolean deletePermission = unit.hasPermission(Permission.DELETE); |
4543 |
22 Sep 08 |
nicklas |
97 |
final boolean isRemoved = unit.isRemoved(); |
4543 |
22 Sep 08 |
nicklas |
98 |
final boolean isUsed = isRemoved && unit.isUsed(); |
4543 |
22 Sep 08 |
nicklas |
99 |
final boolean deletePermanentlyPermission = deletePermission && !isUsed; |
4886 |
03 Apr 09 |
nicklas |
100 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, unit); |
7604 |
25 Feb 19 |
nicklas |
101 |
ExtensionsInvoker<ButtonAction> invoker = ToolbarUtil.useExtensions(jspContext); |
4543 |
22 Sep 08 |
nicklas |
102 |
%> |
6289 |
05 Jun 13 |
nicklas |
103 |
<base:page title="<%=title%>" id="view-page"> |
6289 |
05 Jun 13 |
nicklas |
104 |
<base:head scripts="table.js,tabcontrol-2.js,~units.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css"> |
4886 |
03 Apr 09 |
nicklas |
105 |
<ext:scripts context="<%=jspContext%>" /> |
4886 |
03 Apr 09 |
nicklas |
106 |
<ext:stylesheets context="<%=jspContext%>" /> |
4543 |
22 Sep 08 |
nicklas |
107 |
</base:head> |
4543 |
22 Sep 08 |
nicklas |
108 |
<base:body> |
5941 |
01 Feb 12 |
nicklas |
109 |
<p:path><p:pathelement |
5941 |
01 Feb 12 |
nicklas |
110 |
title="Quantities" href="<%="../index.jsp?ID="+ID%>" |
5941 |
01 Feb 12 |
nicklas |
111 |
/><p:pathelement |
4543 |
22 Sep 08 |
nicklas |
112 |
title="<%=HTML.encodeTags(quantity.getName())%>" |
6149 |
25 Sep 12 |
nicklas |
113 |
href="<%="index.jsp?ID="+ID+"&quantity_id="+quantityId%>" |
5941 |
01 Feb 12 |
nicklas |
114 |
/><p:pathelement title="<%=HTML.encodeTags(unit.getName())%>" |
5941 |
01 Feb 12 |
nicklas |
115 |
/></p:path> |
6289 |
05 Jun 13 |
nicklas |
116 |
<div id="page-data" data-item-id="<%=itemId%>" data-quantity-id="<%=quantityId%>"></div> |
4543 |
22 Sep 08 |
nicklas |
117 |
|
5941 |
01 Feb 12 |
nicklas |
118 |
<t:tabcontrol |
5941 |
01 Feb 12 |
nicklas |
119 |
id="main" |
5941 |
01 Feb 12 |
nicklas |
120 |
subclass="content mastertabcontrol" |
6289 |
05 Jun 13 |
nicklas |
121 |
active="<%=tab%>"> |
4543 |
22 Sep 08 |
nicklas |
122 |
<t:tab id="properties" title="Properties"> |
5941 |
01 Feb 12 |
nicklas |
123 |
<div> |
5941 |
01 Feb 12 |
nicklas |
124 |
<table class="fullform bottomborder"> |
5941 |
01 Feb 12 |
nicklas |
125 |
<tr> |
5941 |
01 Feb 12 |
nicklas |
126 |
<th class="itemstatus"> |
4543 |
22 Sep 08 |
nicklas |
127 |
<base:icon |
6289 |
05 Jun 13 |
nicklas |
128 |
id="btnDeletePermanently" |
5946 |
03 Feb 12 |
nicklas |
129 |
image="deleted.png" |
5941 |
01 Feb 12 |
nicklas |
130 |
tooltip="This item has been flagged for deletion. Click to delete it now." |
5941 |
01 Feb 12 |
nicklas |
131 |
enabled="<%=deletePermanentlyPermission %>" |
5941 |
01 Feb 12 |
nicklas |
132 |
visible="<%=isRemoved%>" |
5941 |
01 Feb 12 |
nicklas |
133 |
/> |
6289 |
05 Jun 13 |
nicklas |
134 |
<base:icon |
6289 |
05 Jun 13 |
nicklas |
135 |
id="btnUsingItems" |
6289 |
05 Jun 13 |
nicklas |
136 |
image="used.png" |
5941 |
01 Feb 12 |
nicklas |
137 |
tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one" |
5941 |
01 Feb 12 |
nicklas |
138 |
visible="<%=isRemoved && isUsed%>" /> |
5941 |
01 Feb 12 |
nicklas |
139 |
</th> |
5941 |
01 Feb 12 |
nicklas |
140 |
<td style="padding: 0px;"> |
6605 |
18 Nov 14 |
nicklas |
141 |
<tbl:toolbar subclass="bottomborder bg-filled-50"> |
5941 |
01 Feb 12 |
nicklas |
142 |
<tbl:button |
6289 |
05 Jun 13 |
nicklas |
143 |
id="btnEdit" |
5942 |
01 Feb 12 |
nicklas |
144 |
disabled="<%=!writePermission%>" |
5945 |
02 Feb 12 |
nicklas |
145 |
image="edit.png" |
5941 |
01 Feb 12 |
nicklas |
146 |
title="Edit…" |
5941 |
01 Feb 12 |
nicklas |
147 |
tooltip="<%=writePermission ? "Edit this unit" : "You do not have permission to edit this unit"%>" |
5941 |
01 Feb 12 |
nicklas |
148 |
/> |
5941 |
01 Feb 12 |
nicklas |
149 |
<tbl:button |
6289 |
05 Jun 13 |
nicklas |
150 |
id="btnDelete" |
5942 |
01 Feb 12 |
nicklas |
151 |
disabled="<%=!deletePermission%>" |
5946 |
03 Feb 12 |
nicklas |
152 |
image="delete.png" |
5941 |
01 Feb 12 |
nicklas |
153 |
title="Delete" |
5941 |
01 Feb 12 |
nicklas |
154 |
visible="<%=!isRemoved%>" |
5941 |
01 Feb 12 |
nicklas |
155 |
tooltip="<%=deletePermission ? "Delete this unit" : "You do not have permission to delete this unit"%>" |
5941 |
01 Feb 12 |
nicklas |
156 |
/> |
5941 |
01 Feb 12 |
nicklas |
157 |
<tbl:button |
6289 |
05 Jun 13 |
nicklas |
158 |
id="btnRestore" |
5942 |
01 Feb 12 |
nicklas |
159 |
disabled="<%=!writePermission%>" |
5946 |
03 Feb 12 |
nicklas |
160 |
image="restore.png" |
5941 |
01 Feb 12 |
nicklas |
161 |
title="Restore" |
5941 |
01 Feb 12 |
nicklas |
162 |
visible="<%=isRemoved%>" |
5941 |
01 Feb 12 |
nicklas |
163 |
tooltip="<%=writePermission ? "Restore this unit" : "You do not have permission to restore this unit"%>" |
5941 |
01 Feb 12 |
nicklas |
164 |
/> |
5941 |
01 Feb 12 |
nicklas |
165 |
<tbl:button |
6289 |
05 Jun 13 |
nicklas |
166 |
id="btnImport" |
5946 |
03 Feb 12 |
nicklas |
167 |
image="import.png" |
6289 |
05 Jun 13 |
nicklas |
168 |
data-plugin-type="IMPORT" |
5941 |
01 Feb 12 |
nicklas |
169 |
title="Import…" |
5941 |
01 Feb 12 |
nicklas |
170 |
tooltip="Import data" |
5941 |
01 Feb 12 |
nicklas |
171 |
visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>" |
5941 |
01 Feb 12 |
nicklas |
172 |
/> |
5941 |
01 Feb 12 |
nicklas |
173 |
<tbl:button |
6289 |
05 Jun 13 |
nicklas |
174 |
id="btnExport" |
6289 |
05 Jun 13 |
nicklas |
175 |
image="export.png" |
6289 |
05 Jun 13 |
nicklas |
176 |
data-plugin-type="EXPORT" |
5941 |
01 Feb 12 |
nicklas |
177 |
title="Export…" |
5941 |
01 Feb 12 |
nicklas |
178 |
tooltip="Export data" |
5941 |
01 Feb 12 |
nicklas |
179 |
visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>" |
5941 |
01 Feb 12 |
nicklas |
180 |
/> |
5941 |
01 Feb 12 |
nicklas |
181 |
<tbl:button |
6289 |
05 Jun 13 |
nicklas |
182 |
id="btnRunPlugin" |
6289 |
05 Jun 13 |
nicklas |
183 |
image="runplugin.png" |
6289 |
05 Jun 13 |
nicklas |
184 |
data-plugin-type="OTHER" |
5941 |
01 Feb 12 |
nicklas |
185 |
title="Run plugin…" |
5941 |
01 Feb 12 |
nicklas |
186 |
tooltip="Run a plugin" |
5941 |
01 Feb 12 |
nicklas |
187 |
visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>" |
5941 |
01 Feb 12 |
nicklas |
188 |
/> |
5941 |
01 Feb 12 |
nicklas |
189 |
<ext:render extensions="<%=invoker%>" context="<%=jspContext%>" |
7604 |
25 Feb 19 |
nicklas |
190 |
wrapper="<%=new PrefixSuffixRenderer<ButtonAction>(jspContext, "<td>", "</td>") %>"/> |
5941 |
01 Feb 12 |
nicklas |
191 |
<tbl:button |
5941 |
01 Feb 12 |
nicklas |
192 |
image="help.png" |
6289 |
05 Jun 13 |
nicklas |
193 |
subclass="auto-init" |
6289 |
05 Jun 13 |
nicklas |
194 |
data-auto-init="help" |
6289 |
05 Jun 13 |
nicklas |
195 |
data-help-id="unit.view.properties" |
5941 |
01 Feb 12 |
nicklas |
196 |
title="Help…" |
5941 |
01 Feb 12 |
nicklas |
197 |
tooltip="Get help about this page" |
5941 |
01 Feb 12 |
nicklas |
198 |
/> |
5941 |
01 Feb 12 |
nicklas |
199 |
</tbl:toolbar> |
5941 |
01 Feb 12 |
nicklas |
200 |
</td> |
5941 |
01 Feb 12 |
nicklas |
201 |
</tr> |
4543 |
22 Sep 08 |
nicklas |
202 |
<tr> |
5941 |
01 Feb 12 |
nicklas |
203 |
<tH>Name</tH> |
4543 |
22 Sep 08 |
nicklas |
204 |
<td><%=HTML.encodeTags(unit.getName())%></td> |
4543 |
22 Sep 08 |
nicklas |
205 |
</tr> |
4543 |
22 Sep 08 |
nicklas |
206 |
<tr> |
5941 |
01 Feb 12 |
nicklas |
207 |
<tH>Symbols</tH> |
4543 |
22 Sep 08 |
nicklas |
208 |
<td><%=Values.getString(symbols, ", ", true)%></td> |
4543 |
22 Sep 08 |
nicklas |
209 |
</tr> |
4543 |
22 Sep 08 |
nicklas |
210 |
<tr> |
5941 |
01 Feb 12 |
nicklas |
211 |
<tH>Conversion formula</tH> |
4543 |
22 Sep 08 |
nicklas |
212 |
<td><%=HTML.encodeTags(formula.toString())%></td> |
4543 |
22 Sep 08 |
nicklas |
213 |
</tr> |
5941 |
01 Feb 12 |
nicklas |
214 |
<tr> |
5941 |
01 Feb 12 |
nicklas |
215 |
<th>Permissions</th> |
5941 |
01 Feb 12 |
nicklas |
216 |
<td><%=PermissionUtil.getFullPermissionNames(unit)%></td> |
5941 |
01 Feb 12 |
nicklas |
217 |
</tr> |
5905 |
12 Dec 11 |
nicklas |
218 |
<tr > |
5941 |
01 Feb 12 |
nicklas |
219 |
<tH>Description</tH> |
4543 |
22 Sep 08 |
nicklas |
220 |
<td><%=HTML.formatLineBreaks(HTML.encodeTags(unit.getDescription()))%></td> |
4543 |
22 Sep 08 |
nicklas |
221 |
</tr> |
4543 |
22 Sep 08 |
nicklas |
222 |
</table> |
5941 |
01 Feb 12 |
nicklas |
223 |
</div> |
5511 |
19 Nov 10 |
nicklas |
224 |
<jsp:include page="../../../common/anytoany/list_anytoany.jsp"> |
5511 |
19 Nov 10 |
nicklas |
225 |
<jsp:param name="ID" value="<%=ID%>" /> |
5511 |
19 Nov 10 |
nicklas |
226 |
<jsp:param name="item_type" value="<%=itemType.name()%>" /> |
5511 |
19 Nov 10 |
nicklas |
227 |
<jsp:param name="item_id" value="<%=itemId%>" /> |
5511 |
19 Nov 10 |
nicklas |
228 |
<jsp:param name="title" value="Other items related to this unit" /> |
5511 |
19 Nov 10 |
nicklas |
229 |
</jsp:include> |
5941 |
01 Feb 12 |
nicklas |
230 |
</t:tab> |
5941 |
01 Feb 12 |
nicklas |
231 |
</t:tabcontrol> |
4543 |
22 Sep 08 |
nicklas |
232 |
|
4543 |
22 Sep 08 |
nicklas |
233 |
</base:body> |
4543 |
22 Sep 08 |
nicklas |
234 |
</base:page> |
4543 |
22 Sep 08 |
nicklas |
235 |
<% |
4543 |
22 Sep 08 |
nicklas |
236 |
} |
4543 |
22 Sep 08 |
nicklas |
237 |
finally |
4543 |
22 Sep 08 |
nicklas |
238 |
{ |
4543 |
22 Sep 08 |
nicklas |
239 |
if (dc != null) dc.close(); |
4543 |
22 Sep 08 |
nicklas |
240 |
} |
4543 |
22 Sep 08 |
nicklas |
241 |
|
4543 |
22 Sep 08 |
nicklas |
242 |
%> |