2658 |
22 Sep 06 |
nicklas |
1 |
<%-- $Id$ |
2658 |
22 Sep 06 |
nicklas |
2 |
------------------------------------------------------------------ |
3675 |
16 Aug 07 |
jari |
Copyright (C) 2006, 2007 Nicklas Nordborg |
2658 |
22 Sep 06 |
nicklas |
4 |
|
2658 |
22 Sep 06 |
nicklas |
5 |
This file is part of BASE - BioArray Software Environment. |
2658 |
22 Sep 06 |
nicklas |
6 |
Available at http://base.thep.lu.se/ |
2658 |
22 Sep 06 |
nicklas |
7 |
|
2658 |
22 Sep 06 |
nicklas |
8 |
BASE is free software; you can redistribute it and/or |
2658 |
22 Sep 06 |
nicklas |
9 |
modify it under the terms of the GNU General Public License |
4476 |
05 Sep 08 |
jari |
10 |
as published by the Free Software Foundation; either version 3 |
2658 |
22 Sep 06 |
nicklas |
11 |
of the License, or (at your option) any later version. |
2658 |
22 Sep 06 |
nicklas |
12 |
|
2658 |
22 Sep 06 |
nicklas |
13 |
BASE is distributed in the hope that it will be useful, |
2658 |
22 Sep 06 |
nicklas |
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
2658 |
22 Sep 06 |
nicklas |
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2658 |
22 Sep 06 |
nicklas |
16 |
GNU General Public License for more details. |
2658 |
22 Sep 06 |
nicklas |
17 |
|
2658 |
22 Sep 06 |
nicklas |
18 |
You should have received a copy of the GNU General Public License |
4510 |
11 Sep 08 |
jari |
19 |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
2658 |
22 Sep 06 |
nicklas |
20 |
------------------------------------------------------------------ |
2658 |
22 Sep 06 |
nicklas |
21 |
|
2658 |
22 Sep 06 |
nicklas |
22 |
|
2658 |
22 Sep 06 |
nicklas |
23 |
@author Nicklas |
2658 |
22 Sep 06 |
nicklas |
24 |
@version 2.0 |
2658 |
22 Sep 06 |
nicklas |
25 |
--%> |
5426 |
24 Sep 10 |
nicklas |
26 |
<%@ page pageEncoding="UTF-8" session="false" |
2658 |
22 Sep 06 |
nicklas |
27 |
import="net.sf.basedb.core.SessionControl" |
2658 |
22 Sep 06 |
nicklas |
28 |
import="net.sf.basedb.core.DbControl" |
2658 |
22 Sep 06 |
nicklas |
29 |
import="net.sf.basedb.core.Item" |
2658 |
22 Sep 06 |
nicklas |
30 |
import="net.sf.basedb.core.Type" |
2658 |
22 Sep 06 |
nicklas |
31 |
import="net.sf.basedb.core.ItemContext" |
2658 |
22 Sep 06 |
nicklas |
32 |
import="net.sf.basedb.core.Permission" |
2658 |
22 Sep 06 |
nicklas |
33 |
import="net.sf.basedb.core.ExtraValueType" |
3558 |
16 Jul 07 |
nicklas |
34 |
import="net.sf.basedb.core.Formula" |
2733 |
16 Oct 06 |
nicklas |
35 |
import="net.sf.basedb.core.Coloring" |
2658 |
22 Sep 06 |
nicklas |
36 |
import="net.sf.basedb.core.PermissionDeniedException" |
2658 |
22 Sep 06 |
nicklas |
37 |
import="net.sf.basedb.clients.web.Base" |
2658 |
22 Sep 06 |
nicklas |
38 |
import="net.sf.basedb.clients.web.util.HTML" |
2753 |
20 Oct 06 |
nicklas |
39 |
import="net.sf.basedb.util.Values" |
5510 |
19 Nov 10 |
nicklas |
40 |
import="net.sf.basedb.core.plugin.GuiContext" |
5510 |
19 Nov 10 |
nicklas |
41 |
import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
5510 |
19 Nov 10 |
nicklas |
42 |
import="net.sf.basedb.clients.web.extensions.JspContext" |
5510 |
19 Nov 10 |
nicklas |
43 |
import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
7604 |
25 Feb 19 |
nicklas |
44 |
import="net.sf.basedb.clients.web.extensions.tabcontrol.TabAction" |
5510 |
19 Nov 10 |
nicklas |
45 |
import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
2658 |
22 Sep 06 |
nicklas |
46 |
%> |
2658 |
22 Sep 06 |
nicklas |
47 |
<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
2658 |
22 Sep 06 |
nicklas |
48 |
<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
6149 |
25 Sep 12 |
nicklas |
49 |
<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %> |
2658 |
22 Sep 06 |
nicklas |
50 |
<% |
2658 |
22 Sep 06 |
nicklas |
51 |
final Item itemType = Item.EXTRAVALUETYPE; |
2658 |
22 Sep 06 |
nicklas |
52 |
final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
2658 |
22 Sep 06 |
nicklas |
53 |
final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
2658 |
22 Sep 06 |
nicklas |
54 |
final int itemId = cc.getId(); |
2658 |
22 Sep 06 |
nicklas |
55 |
final String ID = sc.getId(); |
2658 |
22 Sep 06 |
nicklas |
56 |
final float scale = Base.getScale(sc); |
7954 |
12 May 21 |
nicklas |
57 |
final DbControl dc = sc.newDbControl(":Edit "+itemType); |
2658 |
22 Sep 06 |
nicklas |
58 |
try |
2658 |
22 Sep 06 |
nicklas |
59 |
{ |
2658 |
22 Sep 06 |
nicklas |
60 |
String title = null; |
2658 |
22 Sep 06 |
nicklas |
61 |
ExtraValueType extraValueType = null; |
2733 |
16 Oct 06 |
nicklas |
62 |
Coloring coloring = null; |
3558 |
16 Jul 07 |
nicklas |
63 |
Formula.AverageMethod currentAverageMethod = null; |
2658 |
22 Sep 06 |
nicklas |
64 |
|
2658 |
22 Sep 06 |
nicklas |
65 |
if (itemId == 0) |
2658 |
22 Sep 06 |
nicklas |
66 |
{ |
2658 |
22 Sep 06 |
nicklas |
67 |
title = "Create extra value type"; |
2658 |
22 Sep 06 |
nicklas |
68 |
cc.removeObject("item"); |
3558 |
16 Jul 07 |
nicklas |
69 |
currentAverageMethod = Formula.AverageMethod.fromValue(Values.getInt(cc.getPropertyValue("averageMethod"), |
3558 |
16 Jul 07 |
nicklas |
70 |
Formula.AverageMethod.ARITHMETIC_MEAN.getValue())); |
2733 |
16 Oct 06 |
nicklas |
71 |
coloring = new Coloring(); |
2733 |
16 Oct 06 |
nicklas |
72 |
coloring.setUsingColors(Values.getBoolean(cc.getPropertyValue("coloring.usingColors"))); |
2733 |
16 Oct 06 |
nicklas |
73 |
coloring.setLogarithmic(Values.getBoolean(cc.getPropertyValue("coloring.logarithmic"))); |
2733 |
16 Oct 06 |
nicklas |
74 |
coloring.setMinValue(Values.getFloat(cc.getPropertyValue("coloring.minValue"), null)); |
2733 |
16 Oct 06 |
nicklas |
75 |
coloring.setMidValue(Values.getFloat(cc.getPropertyValue("coloring.midValue"), null)); |
2733 |
16 Oct 06 |
nicklas |
76 |
coloring.setMaxValue(Values.getFloat(cc.getPropertyValue("coloring.maxValue"), null)); |
2658 |
22 Sep 06 |
nicklas |
77 |
} |
2658 |
22 Sep 06 |
nicklas |
78 |
else |
2658 |
22 Sep 06 |
nicklas |
79 |
{ |
2658 |
22 Sep 06 |
nicklas |
80 |
extraValueType = ExtraValueType.getById(dc, itemId); |
6296 |
13 Jun 13 |
nicklas |
81 |
extraValueType.checkPermission(Permission.WRITE); |
3558 |
16 Jul 07 |
nicklas |
82 |
currentAverageMethod = extraValueType.getAverageMethod(); |
2733 |
16 Oct 06 |
nicklas |
83 |
coloring = extraValueType.getColoring(); |
2658 |
22 Sep 06 |
nicklas |
84 |
cc.setObject("item", extraValueType); |
2658 |
22 Sep 06 |
nicklas |
85 |
title = "Edit extra value type -- " + HTML.encodeTags(extraValueType.getName()); |
2658 |
22 Sep 06 |
nicklas |
86 |
} |
2658 |
22 Sep 06 |
nicklas |
87 |
|
5510 |
19 Nov 10 |
nicklas |
88 |
JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), extraValueType); |
7604 |
25 Feb 19 |
nicklas |
89 |
ExtensionsInvoker<TabAction> invoker = EditUtil.useEditExtensions(jspContext); |
2658 |
22 Sep 06 |
nicklas |
90 |
%> |
6296 |
13 Jun 13 |
nicklas |
91 |
<base:page type="popup" title="<%=title%>" id="edit-page"> |
6296 |
13 Jun 13 |
nicklas |
92 |
<base:head scripts="tabcontrol-2.js,~extravaluetypes.js" styles="tabcontrol.css"> |
5510 |
19 Nov 10 |
nicklas |
93 |
<ext:scripts context="<%=jspContext%>" /> |
5510 |
19 Nov 10 |
nicklas |
94 |
<ext:stylesheets context="<%=jspContext%>" /> |
2658 |
22 Sep 06 |
nicklas |
95 |
</base:head> |
6296 |
13 Jun 13 |
nicklas |
96 |
<base:body> |
5922 |
11 Jan 12 |
nicklas |
97 |
<h1><%=title%> <base:help tabcontrol="settings" /></h1> |
6162 |
10 Oct 12 |
nicklas |
98 |
<form action="index.jsp?ID=<%=ID%>" method="post" name="extraValueType"> |
2658 |
22 Sep 06 |
nicklas |
99 |
<input type="hidden" name="cmd" value="UpdateItem"> |
2658 |
22 Sep 06 |
nicklas |
100 |
|
5922 |
11 Jan 12 |
nicklas |
101 |
<t:tabcontrol id="settings" |
5922 |
11 Jan 12 |
nicklas |
102 |
subclass="content dialogtabcontrol" |
5510 |
19 Nov 10 |
nicklas |
103 |
position="bottom" remember="<%=extraValueType != null%>" |
5510 |
19 Nov 10 |
nicklas |
104 |
extensions="<%=invoker%>"> |
6296 |
13 Jun 13 |
nicklas |
105 |
<t:tab id="info" title="Extra value type" |
2658 |
22 Sep 06 |
nicklas |
106 |
helpid="extravaluetype.edit"> |
5922 |
11 Jan 12 |
nicklas |
107 |
<table class="fullform input100 smaller"> |
2658 |
22 Sep 06 |
nicklas |
108 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
109 |
<th>Name</th> |
6296 |
13 Jun 13 |
nicklas |
110 |
<td><input class="text required auto-init" type="text" name="name" data-auto-init="<%=extraValueType == null ? "focus-select" : "focus" %>" |
2658 |
22 Sep 06 |
nicklas |
111 |
value="<%=HTML.encodeTags(extraValueType == null ? Values.getString(cc.getPropertyValue("name"), "New extra value type") : extraValueType.getName())%>" |
5922 |
11 Jan 12 |
nicklas |
112 |
maxlength="<%=ExtraValueType.MAX_NAME_LENGTH%>"></td> |
5922 |
11 Jan 12 |
nicklas |
113 |
<td></td> |
2658 |
22 Sep 06 |
nicklas |
114 |
</tr> |
2658 |
22 Sep 06 |
nicklas |
115 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
116 |
<th>External ID</th> |
6217 |
14 Dec 12 |
nicklas |
117 |
<td><input class="text required" type="text" name="external_id" |
2658 |
22 Sep 06 |
nicklas |
118 |
value="<%=HTML.encodeTags(extraValueType == null ? Values.getString(cc.getPropertyValue("externalId")) : extraValueType.getExternalId())%>" |
5922 |
11 Jan 12 |
nicklas |
119 |
maxlength="<%=ExtraValueType.MAX_EXTERNAL_ID_LENGTH%>"></td> |
5922 |
11 Jan 12 |
nicklas |
120 |
<td></td> |
2658 |
22 Sep 06 |
nicklas |
121 |
</tr> |
2658 |
22 Sep 06 |
nicklas |
122 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
123 |
<th>Value type</th> |
2658 |
22 Sep 06 |
nicklas |
124 |
<td> |
2658 |
22 Sep 06 |
nicklas |
125 |
<% |
2658 |
22 Sep 06 |
nicklas |
126 |
if (extraValueType != null) |
2658 |
22 Sep 06 |
nicklas |
127 |
{ |
2658 |
22 Sep 06 |
nicklas |
128 |
%> |
2658 |
22 Sep 06 |
nicklas |
129 |
<%=extraValueType.getValueType()%> |
2658 |
22 Sep 06 |
nicklas |
130 |
<% |
2658 |
22 Sep 06 |
nicklas |
131 |
} |
2658 |
22 Sep 06 |
nicklas |
132 |
else |
2658 |
22 Sep 06 |
nicklas |
133 |
{ |
2658 |
22 Sep 06 |
nicklas |
134 |
int currentValueType = Values.getInt(cc.getPropertyValue("valueType")); |
2658 |
22 Sep 06 |
nicklas |
135 |
%> |
6296 |
13 Jun 13 |
nicklas |
136 |
<select name="value_type" class="required unchangeable selectionlist" id="value_type"> |
2658 |
22 Sep 06 |
nicklas |
137 |
<option value="<%=Type.INT.name()%>" |
2658 |
22 Sep 06 |
nicklas |
138 |
<%=Type.INT.getValue() == currentValueType ? "selected" : "" %>><%=Type.INT%> |
2658 |
22 Sep 06 |
nicklas |
139 |
<option value="<%=Type.FLOAT.name()%>" |
2658 |
22 Sep 06 |
nicklas |
140 |
<%=Type.FLOAT.getValue() == currentValueType ? "selected" : "" %>><%=Type.FLOAT%> |
2658 |
22 Sep 06 |
nicklas |
141 |
<option value="<%=Type.STRING.name()%>" |
2658 |
22 Sep 06 |
nicklas |
142 |
<%=Type.STRING.getValue() == currentValueType ? "selected" : "" %>><%=Type.STRING%> |
2658 |
22 Sep 06 |
nicklas |
143 |
</select> |
2658 |
22 Sep 06 |
nicklas |
144 |
<% |
2658 |
22 Sep 06 |
nicklas |
145 |
} |
2658 |
22 Sep 06 |
nicklas |
146 |
%> |
2658 |
22 Sep 06 |
nicklas |
147 |
</td> |
5922 |
11 Jan 12 |
nicklas |
148 |
<td></td> |
2658 |
22 Sep 06 |
nicklas |
149 |
</tr> |
3558 |
16 Jul 07 |
nicklas |
150 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
151 |
<th>Avg. method</th> |
3558 |
16 Jul 07 |
nicklas |
152 |
<td> |
5922 |
11 Jan 12 |
nicklas |
153 |
<select name="averageMethod" class="required selectionlist"> |
3558 |
16 Jul 07 |
nicklas |
154 |
<% |
3558 |
16 Jul 07 |
nicklas |
155 |
for (Formula.AverageMethod method : Formula.AverageMethod.values()) |
3558 |
16 Jul 07 |
nicklas |
156 |
{ |
3558 |
16 Jul 07 |
nicklas |
157 |
String selected = method == currentAverageMethod ? "selected" : ""; |
3558 |
16 Jul 07 |
nicklas |
158 |
%> |
3558 |
16 Jul 07 |
nicklas |
159 |
<option value="<%=method.name()%>" <%=selected%>><%=HTML.encodeTags(method.toString())%> |
3558 |
16 Jul 07 |
nicklas |
160 |
<% |
3558 |
16 Jul 07 |
nicklas |
161 |
} |
3558 |
16 Jul 07 |
nicklas |
162 |
%> |
3558 |
16 Jul 07 |
nicklas |
163 |
</select> |
3558 |
16 Jul 07 |
nicklas |
164 |
</td> |
5922 |
11 Jan 12 |
nicklas |
165 |
<td></td> |
3558 |
16 Jul 07 |
nicklas |
166 |
</tr> |
2733 |
16 Oct 06 |
nicklas |
167 |
<% |
2733 |
16 Oct 06 |
nicklas |
168 |
if (extraValueType == null || extraValueType.getValueType().isNumerical()) |
2733 |
16 Oct 06 |
nicklas |
169 |
{ |
2733 |
16 Oct 06 |
nicklas |
170 |
%> |
2733 |
16 Oct 06 |
nicklas |
171 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
172 |
<th><label for="use_colors">Use colors</label></th> |
2733 |
16 Oct 06 |
nicklas |
173 |
<td> |
5922 |
11 Jan 12 |
nicklas |
174 |
<input type="checkbox" name="use_colors" value="1" id="use_colors" |
6296 |
13 Jun 13 |
nicklas |
175 |
<%=coloring.isUsingColors() ? "checked" : "" %>> |
5922 |
11 Jan 12 |
nicklas |
176 |
</td> |
5922 |
11 Jan 12 |
nicklas |
177 |
<td></td> |
5922 |
11 Jan 12 |
nicklas |
178 |
</tr> |
5922 |
11 Jan 12 |
nicklas |
179 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
180 |
<th class="subprompt">Min value</th> |
5922 |
11 Jan 12 |
nicklas |
181 |
<td> |
6296 |
13 Jun 13 |
nicklas |
182 |
<input type="text" class="text" name="min_value" id="min_value" |
2733 |
16 Oct 06 |
nicklas |
183 |
value="<%=Values.formatNumber(coloring.getMinValue(), -1)%>" |
6296 |
13 Jun 13 |
nicklas |
184 |
maxlength="6" style="width: 6em;"> |
5922 |
11 Jan 12 |
nicklas |
185 |
Mid value |
6296 |
13 Jun 13 |
nicklas |
186 |
<input type="text" class="text" name="mid_value" id="mid_value" |
2733 |
16 Oct 06 |
nicklas |
187 |
value="<%=Values.formatNumber(coloring.getMidValue(), -1)%>" |
6296 |
13 Jun 13 |
nicklas |
188 |
maxlength="6" style="width: 6em;"> |
5922 |
11 Jan 12 |
nicklas |
189 |
Max value |
6296 |
13 Jun 13 |
nicklas |
190 |
<input type="text" class="text" name="max_value" id="max_value" |
2733 |
16 Oct 06 |
nicklas |
191 |
value="<%=Values.formatNumber(coloring.getMaxValue(), -1)%>" |
6296 |
13 Jun 13 |
nicklas |
192 |
maxlength="6" style="width: 6em;"> |
5922 |
11 Jan 12 |
nicklas |
193 |
</td> |
5922 |
11 Jan 12 |
nicklas |
194 |
<td></td> |
5922 |
11 Jan 12 |
nicklas |
195 |
</tr> |
5922 |
11 Jan 12 |
nicklas |
196 |
<tr> |
5922 |
11 Jan 12 |
nicklas |
197 |
<th class="subprompt"><label for="logarithmic">Logarithmic</label></th> |
5922 |
11 Jan 12 |
nicklas |
198 |
<td> |
5922 |
11 Jan 12 |
nicklas |
199 |
<input type="checkbox" name="logarithmic" value="1" id="logarithmic" |
2733 |
16 Oct 06 |
nicklas |
200 |
<%=coloring.isLogarithmic() ? "checked" : "" %>> |
2733 |
16 Oct 06 |
nicklas |
201 |
</td> |
5922 |
11 Jan 12 |
nicklas |
202 |
<td></td> |
2733 |
16 Oct 06 |
nicklas |
203 |
</tr> |
2733 |
16 Oct 06 |
nicklas |
204 |
<% |
2733 |
16 Oct 06 |
nicklas |
205 |
} |
2733 |
16 Oct 06 |
nicklas |
206 |
%> |
5922 |
11 Jan 12 |
nicklas |
207 |
<tr class="dynamic"> |
5922 |
11 Jan 12 |
nicklas |
208 |
<th>Description</th> |
5922 |
11 Jan 12 |
nicklas |
209 |
<td> |
6217 |
14 Dec 12 |
nicklas |
210 |
<textarea class="text" rows="6" name="description" id="description" |
2658 |
22 Sep 06 |
nicklas |
211 |
><%=HTML.encodeTags(extraValueType == null ? cc.getPropertyValue("description") : extraValueType.getDescription())%></textarea> |
2658 |
22 Sep 06 |
nicklas |
212 |
</td> |
5922 |
11 Jan 12 |
nicklas |
213 |
<td style="width: 20px;"> |
6215 |
13 Dec 12 |
nicklas |
214 |
<base:zoom textarea="description" title="Description" /> |
5922 |
11 Jan 12 |
nicklas |
215 |
</td> |
2658 |
22 Sep 06 |
nicklas |
216 |
</tr> |
2658 |
22 Sep 06 |
nicklas |
217 |
</table> |
2658 |
22 Sep 06 |
nicklas |
218 |
</t:tab> |
2658 |
22 Sep 06 |
nicklas |
219 |
</t:tabcontrol> |
5922 |
11 Jan 12 |
nicklas |
220 |
</form> |
5922 |
11 Jan 12 |
nicklas |
221 |
|
5922 |
11 Jan 12 |
nicklas |
222 |
<div class="legend"> |
5946 |
03 Feb 12 |
nicklas |
223 |
<base:icon image="required.png" />= required information |
5922 |
11 Jan 12 |
nicklas |
224 |
<%if (extraValueType == null) {%><br> |
5967 |
16 Feb 12 |
nicklas |
225 |
<base:icon image="unchangeable.png" />= can't be changed later |
5922 |
11 Jan 12 |
nicklas |
226 |
<%}%> |
5922 |
11 Jan 12 |
nicklas |
227 |
</div> |
2658 |
22 Sep 06 |
nicklas |
228 |
|
5922 |
11 Jan 12 |
nicklas |
229 |
<base:buttongroup subclass="dialogbuttons"> |
6296 |
13 Jun 13 |
nicklas |
230 |
<base:button id="btnSave" title="Save" /> |
6296 |
13 Jun 13 |
nicklas |
231 |
<base:button id="close" title="Cancel" /> |
5922 |
11 Jan 12 |
nicklas |
232 |
</base:buttongroup> |
2658 |
22 Sep 06 |
nicklas |
233 |
</base:body> |
2658 |
22 Sep 06 |
nicklas |
234 |
</base:page> |
2658 |
22 Sep 06 |
nicklas |
235 |
<% |
2658 |
22 Sep 06 |
nicklas |
236 |
} |
2658 |
22 Sep 06 |
nicklas |
237 |
finally |
2658 |
22 Sep 06 |
nicklas |
238 |
{ |
2658 |
22 Sep 06 |
nicklas |
239 |
if (dc != null) dc.close(); |
2658 |
22 Sep 06 |
nicklas |
240 |
} |
2658 |
22 Sep 06 |
nicklas |
241 |
%> |