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 |
Copyright (C) 2007 Nicklas Nordborg, Martin Svensson |
4543 |
22 Sep 08 |
nicklas |
5 |
|
4543 |
22 Sep 08 |
nicklas |
6 |
This file is part of BASE - BioArray Software Environment. |
4543 |
22 Sep 08 |
nicklas |
7 |
Available at http://base.thep.lu.se/ |
4543 |
22 Sep 08 |
nicklas |
8 |
|
4543 |
22 Sep 08 |
nicklas |
9 |
BASE is free software; you can redistribute it and/or |
4543 |
22 Sep 08 |
nicklas |
10 |
modify it under the terms of the GNU General Public License |
4543 |
22 Sep 08 |
nicklas |
11 |
as published by the Free Software Foundation; either version 3 |
4543 |
22 Sep 08 |
nicklas |
12 |
of the License, or (at your option) any later version. |
4543 |
22 Sep 08 |
nicklas |
13 |
|
4543 |
22 Sep 08 |
nicklas |
14 |
BASE is distributed in the hope that it will be useful, |
4543 |
22 Sep 08 |
nicklas |
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4543 |
22 Sep 08 |
nicklas |
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4543 |
22 Sep 08 |
nicklas |
17 |
GNU General Public License for more details. |
4543 |
22 Sep 08 |
nicklas |
18 |
|
4543 |
22 Sep 08 |
nicklas |
19 |
You should have received a copy of the GNU General Public License |
4543 |
22 Sep 08 |
nicklas |
20 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4543 |
22 Sep 08 |
nicklas |
21 |
------------------------------------------------------------------ |
4543 |
22 Sep 08 |
nicklas |
22 |
|
4543 |
22 Sep 08 |
nicklas |
23 |
|
4543 |
22 Sep 08 |
nicklas |
24 |
@author Nicklas |
4543 |
22 Sep 08 |
nicklas |
25 |
@version 2.0 |
4543 |
22 Sep 08 |
nicklas |
26 |
--%> |
5426 |
24 Sep 10 |
nicklas |
27 |
<%@ page pageEncoding="UTF-8" session="false" |
4543 |
22 Sep 08 |
nicklas |
28 |
import="net.sf.basedb.core.SessionControl" |
4543 |
22 Sep 08 |
nicklas |
29 |
import="net.sf.basedb.core.DbControl" |
4543 |
22 Sep 08 |
nicklas |
30 |
import="net.sf.basedb.core.Item" |
4543 |
22 Sep 08 |
nicklas |
31 |
import="net.sf.basedb.core.ItemContext" |
4543 |
22 Sep 08 |
nicklas |
32 |
import="net.sf.basedb.core.SystemItems" |
4543 |
22 Sep 08 |
nicklas |
33 |
import="net.sf.basedb.core.Permission" |
4543 |
22 Sep 08 |
nicklas |
34 |
import="net.sf.basedb.core.Include" |
4543 |
22 Sep 08 |
nicklas |
35 |
import="net.sf.basedb.core.Quantity" |
4543 |
22 Sep 08 |
nicklas |
36 |
import="net.sf.basedb.core.Unit" |
4543 |
22 Sep 08 |
nicklas |
37 |
import="net.sf.basedb.core.PermissionDeniedException" |
4543 |
22 Sep 08 |
nicklas |
38 |
import="net.sf.basedb.core.BaseException" |
4543 |
22 Sep 08 |
nicklas |
39 |
import="net.sf.basedb.core.query.Orders" |
4543 |
22 Sep 08 |
nicklas |
40 |
import="net.sf.basedb.core.query.Hql" |
4543 |
22 Sep 08 |
nicklas |
41 |
import="net.sf.basedb.clients.web.Base" |
4543 |
22 Sep 08 |
nicklas |
42 |
import="net.sf.basedb.clients.web.util.HTML" |
4543 |
22 Sep 08 |
nicklas |
43 |
import="net.sf.basedb.util.Values" |
4543 |
22 Sep 08 |
nicklas |
44 |
import="java.util.List" |
4543 |
22 Sep 08 |
nicklas |
45 |
import="java.util.ArrayList" |
4543 |
22 Sep 08 |
nicklas |
46 |
import="java.util.Set" |
4543 |
22 Sep 08 |
nicklas |
47 |
import="java.util.HashSet" |
4543 |
22 Sep 08 |
nicklas |
48 |
import="java.util.Date" |
5510 |
19 Nov 10 |
nicklas |
49 |
import="net.sf.basedb.core.plugin.GuiContext" |
5510 |
19 Nov 10 |
nicklas |
50 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5510 |
19 Nov 10 |
nicklas |
51 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5510 |
19 Nov 10 |
nicklas |
52 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
53 |
import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction" |
5510 |
19 Nov 10 |
nicklas |
54 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
4543 |
22 Sep 08 |
nicklas |
55 |
%> |
4543 |
22 Sep 08 |
nicklas |
56 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
4543 |
22 Sep 08 |
nicklas |
57 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
6149 |
25 Sep 12 |
nicklas |
58 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
4543 |
22 Sep 08 |
nicklas |
59 |
<% |
4543 |
22 Sep 08 |
nicklas |
60 |
final Item itemType = Item.UNIT; |
4543 |
22 Sep 08 |
nicklas |
61 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
4543 |
22 Sep 08 |
nicklas |
62 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
4543 |
22 Sep 08 |
nicklas |
63 |
final int itemId = cc.getId(); |
4543 |
22 Sep 08 |
nicklas |
64 |
final int quantityId = Values.getInt(request.getParameter("quantity_id")); |
4543 |
22 Sep 08 |
nicklas |
65 |
final String ID = sc.getId(); |
4543 |
22 Sep 08 |
nicklas |
66 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
67 |
final DbControl dc = sc.newDbControl(":Edit "+itemType); |
4543 |
22 Sep 08 |
nicklas |
68 |
try |
4543 |
22 Sep 08 |
nicklas |
69 |
{ |
4543 |
22 Sep 08 |
nicklas |
70 |
String title = null; |
4543 |
22 Sep 08 |
nicklas |
71 |
Quantity quantity = null; |
4543 |
22 Sep 08 |
nicklas |
72 |
Unit unit = null; |
4543 |
22 Sep 08 |
nicklas |
73 |
List<String> symbols = null; |
4543 |
22 Sep 08 |
nicklas |
74 |
if (itemId == 0) |
4543 |
22 Sep 08 |
nicklas |
75 |
{ |
4543 |
22 Sep 08 |
nicklas |
76 |
title = "Create unit"; |
4543 |
22 Sep 08 |
nicklas |
77 |
cc.removeObject("item"); |
4543 |
22 Sep 08 |
nicklas |
78 |
quantity = Quantity.getById(dc, quantityId); |
4543 |
22 Sep 08 |
nicklas |
79 |
} |
4543 |
22 Sep 08 |
nicklas |
80 |
else |
4543 |
22 Sep 08 |
nicklas |
81 |
{ |
4543 |
22 Sep 08 |
nicklas |
82 |
unit = Unit.getById(dc, itemId); |
6305 |
09 Aug 13 |
nicklas |
83 |
unit.checkPermission(Permission.WRITE); |
4543 |
22 Sep 08 |
nicklas |
84 |
quantity = unit.getQuantity(); |
4543 |
22 Sep 08 |
nicklas |
85 |
cc.setObject("item", unit); |
4543 |
22 Sep 08 |
nicklas |
86 |
title = "Edit unit -- " + HTML.encodeTags(unit.getName()); |
4543 |
22 Sep 08 |
nicklas |
87 |
Set<String> temp = unit.getSymbols(); |
4543 |
22 Sep 08 |
nicklas |
88 |
temp.remove(unit.getDisplaySymbol()); |
4543 |
22 Sep 08 |
nicklas |
89 |
symbols = new ArrayList<String>(); |
4543 |
22 Sep 08 |
nicklas |
90 |
symbols.add(unit.getDisplaySymbol()); |
4543 |
22 Sep 08 |
nicklas |
91 |
if (temp.size() > 0) symbols.addAll(temp); |
4543 |
22 Sep 08 |
nicklas |
92 |
} |
6217 |
14 Dec 12 |
nicklas |
93 |
|
5510 |
19 Nov 10 |
nicklas |
94 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), unit); |
7604 |
25 Feb 19 |
nicklas |
95 |
ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext); |
4543 |
22 Sep 08 |
nicklas |
96 |
%> |
6305 |
09 Aug 13 |
nicklas |
97 |
<base:page type="popup" title="<%=title%>" id="edit-page"> |
6305 |
09 Aug 13 |
nicklas |
98 |
<base:head scripts="tabcontrol-2.js,~units.js" styles="toolbar.css,tabcontrol.css"> |
5510 |
19 Nov 10 |
nicklas |
99 |
<ext:scripts context="<%=jspContext%>" /> |
5510 |
19 Nov 10 |
nicklas |
100 |
<ext:stylesheets context="<%=jspContext%>" /> |
4543 |
22 Sep 08 |
nicklas |
101 |
</base:head> |
6305 |
09 Aug 13 |
nicklas |
102 |
<base:body> |
5922 |
11 Jan 12 |
nicklas |
103 |
<h1><%=title%> <base:help tabcontrol="settings" /></h1> |
6162 |
10 Oct 12 |
nicklas |
104 |
<form action="index.jsp?ID=<%=ID%>" method="post" name="unit"> |
4543 |
22 Sep 08 |
nicklas |
105 |
<input type="hidden" name="cmd" value="UpdateItem"> |
4543 |
22 Sep 08 |
nicklas |
106 |
<input type="hidden" name="quantity_id" value="<%=quantityId%>"> |
4543 |
22 Sep 08 |
nicklas |
107 |
|
5922 |
11 Jan 12 |
nicklas |
108 |
<t:tabcontrol id="settings" |
5922 |
11 Jan 12 |
nicklas |
109 |
subclass="content dialogtabcontrol" |
5510 |
19 Nov 10 |
nicklas |
110 |
position="bottom" remember="<%=unit != null%>" |
5510 |
19 Nov 10 |
nicklas |
111 |
extensions="<%=invoker%>"> |
6305 |
09 Aug 13 |
nicklas |
112 |
<t:tab id="info" title="Unit" helpid="unit.edit"> |
5922 |
11 Jan 12 |
nicklas |
113 |
<table class="fullform input100"> |
4543 |
22 Sep 08 |
nicklas |
114 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
115 |
<th>Title</th> |
6305 |
09 Aug 13 |
nicklas |
116 |
<td><input class="text required auto-init" data-auto-init="<%=unit == null ? "focus-select" : "focus" %>" |
6305 |
09 Aug 13 |
nicklas |
117 |
type="text" name="name" |
4543 |
22 Sep 08 |
nicklas |
118 |
value="<%=HTML.encodeTags(unit == null ? Values.getString(cc.getPropertyValue("name"), "New unit") : unit.getName())%>" |
5922 |
11 Jan 12 |
nicklas |
119 |
maxlength="<%=Unit.MAX_NAME_LENGTH%>"></td> |
5922 |
11 Jan 12 |
nicklas |
120 |
<td></td> |
4543 |
22 Sep 08 |
nicklas |
121 |
</tr> |
5922 |
11 Jan 12 |
nicklas |
122 |
<tr class="big"> |
5922 |
11 Jan 12 |
nicklas |
123 |
<th>Symbols</th> |
4543 |
22 Sep 08 |
nicklas |
124 |
<td> |
6305 |
09 Aug 13 |
nicklas |
125 |
<textarea class="text required" name="symbols" id="symbols" rows="4" |
4543 |
22 Sep 08 |
nicklas |
126 |
><%=Values.getString(symbols, "\n", true)%></textarea> |
4543 |
22 Sep 08 |
nicklas |
127 |
</td> |
5922 |
11 Jan 12 |
nicklas |
128 |
<td></td> |
4543 |
22 Sep 08 |
nicklas |
129 |
</tr> |
4543 |
22 Sep 08 |
nicklas |
130 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
131 |
<th>Conversion formula</th> |
4543 |
22 Sep 08 |
nicklas |
132 |
<td> |
5922 |
11 Jan 12 |
nicklas |
133 |
1 <span id="symbol"><%=unit == null ? "<i>unit</i>" : HTML.encodeTags(unit.getDisplaySymbol())%></span> |
5922 |
11 Jan 12 |
nicklas |
134 |
= |
4543 |
22 Sep 08 |
nicklas |
135 |
<%=HTML.encodeTags(quantity.getReferenceUnit())%> |
6305 |
09 Aug 13 |
nicklas |
136 |
× <input class="text required auto-init" data-auto-init="number-only" |
6305 |
09 Aug 13 |
nicklas |
137 |
type="text" name="referenceFactor" |
4543 |
22 Sep 08 |
nicklas |
138 |
value="<%=unit == null ? 1.0 : unit.getReferenceFactor()%>" |
6305 |
09 Aug 13 |
nicklas |
139 |
maxlength="12" style="width: 10em;"> |
6305 |
09 Aug 13 |
nicklas |
140 |
+ <input class="text required auto-init" data-auto-init="number-only" |
6305 |
09 Aug 13 |
nicklas |
141 |
type="text" name="referenceOffset" |
4543 |
22 Sep 08 |
nicklas |
142 |
value="<%=unit == null ? 0.0 : unit.getReferenceOffset()%>" |
6305 |
09 Aug 13 |
nicklas |
143 |
maxlength="12" style="width: 10em;"> |
4543 |
22 Sep 08 |
nicklas |
144 |
</td> |
5922 |
11 Jan 12 |
nicklas |
145 |
<td></td> |
4543 |
22 Sep 08 |
nicklas |
146 |
</tr> |
5922 |
11 Jan 12 |
nicklas |
147 |
<% |
5922 |
11 Jan 12 |
nicklas |
148 |
if (unit != null) |
5922 |
11 Jan 12 |
nicklas |
149 |
{ |
5922 |
11 Jan 12 |
nicklas |
150 |
%> |
5922 |
11 Jan 12 |
nicklas |
151 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
152 |
<th class="subprompt"></th> |
5922 |
11 Jan 12 |
nicklas |
153 |
<td> |
5922 |
11 Jan 12 |
nicklas |
154 |
<div class="messagecontainer help" style="margin: 0.5em;"> |
5922 |
11 Jan 12 |
nicklas |
155 |
Changing the conversion formula triggers a conversion of existing annotation values |
5922 |
11 Jan 12 |
nicklas |
156 |
to the new settings. This may result in loss of precision due to rounding or |
5922 |
11 Jan 12 |
nicklas |
157 |
truncation. |
5922 |
11 Jan 12 |
nicklas |
158 |
</div> |
5922 |
11 Jan 12 |
nicklas |
159 |
</td> |
5922 |
11 Jan 12 |
nicklas |
160 |
<td></td> |
5922 |
11 Jan 12 |
nicklas |
161 |
</tr> |
5922 |
11 Jan 12 |
nicklas |
162 |
<% |
5922 |
11 Jan 12 |
nicklas |
163 |
} |
5922 |
11 Jan 12 |
nicklas |
164 |
%> |
5922 |
11 Jan 12 |
nicklas |
165 |
<tr class="dynamic"> |
5922 |
11 Jan 12 |
nicklas |
166 |
<th>Description</th> |
4543 |
22 Sep 08 |
nicklas |
167 |
<td> |
6217 |
14 Dec 12 |
nicklas |
168 |
<textarea class="text" rows="6" name="description" id="description" |
4543 |
22 Sep 08 |
nicklas |
169 |
><%=HTML.encodeTags(unit == null ? cc.getPropertyValue("description") : unit.getDescription())%></textarea> |
4543 |
22 Sep 08 |
nicklas |
170 |
</td> |
5922 |
11 Jan 12 |
nicklas |
171 |
<td style="width: 20px;"> |
6215 |
13 Dec 12 |
nicklas |
172 |
<base:zoom textarea="description" title="Description" /> |
5922 |
11 Jan 12 |
nicklas |
173 |
</td> |
4543 |
22 Sep 08 |
nicklas |
174 |
</tr> |
4543 |
22 Sep 08 |
nicklas |
175 |
</table> |
4543 |
22 Sep 08 |
nicklas |
176 |
</t:tab> |
4543 |
22 Sep 08 |
nicklas |
177 |
</t:tabcontrol> |
5922 |
11 Jan 12 |
nicklas |
178 |
</form> |
5922 |
11 Jan 12 |
nicklas |
179 |
|
5922 |
11 Jan 12 |
nicklas |
180 |
<div class="legend"> |
5946 |
03 Feb 12 |
nicklas |
181 |
<base:icon image="required.png" />= required information |
5922 |
11 Jan 12 |
nicklas |
182 |
</div> |
4543 |
22 Sep 08 |
nicklas |
183 |
|
5922 |
11 Jan 12 |
nicklas |
184 |
<base:buttongroup subclass="dialogbuttons"> |
6305 |
09 Aug 13 |
nicklas |
185 |
<base:button id="btnSave" title="Save" /> |
6305 |
09 Aug 13 |
nicklas |
186 |
<base:button id="close" title="Cancel" /> |
5922 |
11 Jan 12 |
nicklas |
187 |
</base:buttongroup> |
4543 |
22 Sep 08 |
nicklas |
188 |
</base:body> |
4543 |
22 Sep 08 |
nicklas |
189 |
</base:page> |
4543 |
22 Sep 08 |
nicklas |
190 |
<% |
4543 |
22 Sep 08 |
nicklas |
191 |
} |
4543 |
22 Sep 08 |
nicklas |
192 |
finally |
4543 |
22 Sep 08 |
nicklas |
193 |
{ |
4543 |
22 Sep 08 |
nicklas |
194 |
if (dc != null) dc.close(); |
4543 |
22 Sep 08 |
nicklas |
195 |
} |
4543 |
22 Sep 08 |
nicklas |
196 |
%> |