1 | <%-- $Id: edit_spotimages.jsp 6217 2012-12-14 13:05:00Z nicklas $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg |
---|
4 | |
---|
5 | This file is part of BASE - BioArray Software Environment. |
---|
6 | Available at http://base.thep.lu.se/ |
---|
7 | |
---|
8 | BASE is free software; you can redistribute it and/or |
---|
9 | modify it under the terms of the GNU General Public License |
---|
10 | as published by the Free Software Foundation; either version 3 |
---|
11 | of the License, or (at your option) any later version. |
---|
12 | |
---|
13 | BASE is distributed in the hope that it will be useful, |
---|
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | GNU General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with BASE. If not, see <http://www.gnu.org/licenses/>. |
---|
20 | ------------------------------------------------------------------ |
---|
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.Item" |
---|
30 | import="net.sf.basedb.core.SystemItems" |
---|
31 | import="net.sf.basedb.core.ItemContext" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.RawBioAssay" |
---|
34 | import="net.sf.basedb.core.SpotImages" |
---|
35 | import="net.sf.basedb.core.File" |
---|
36 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
37 | import="net.sf.basedb.core.BaseException" |
---|
38 | import="net.sf.basedb.clients.web.Base" |
---|
39 | import="net.sf.basedb.clients.web.util.HTML" |
---|
40 | import="net.sf.basedb.util.Values" |
---|
41 | import="java.util.List" |
---|
42 | import="java.util.Set" |
---|
43 | import="java.util.HashSet" |
---|
44 | %> |
---|
45 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
46 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
47 | <% |
---|
48 | final Item itemType = Item.RAWBIOASSAY; |
---|
49 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
50 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
51 | final int itemId = cc.getId(); |
---|
52 | final String ID = sc.getId(); |
---|
53 | final float scale = Base.getScale(sc); |
---|
54 | final DbControl dc = sc.newDbControl(); |
---|
55 | try |
---|
56 | { |
---|
57 | String title = "Create spot images"; |
---|
58 | RawBioAssay rawBioAssay = RawBioAssay.getById(dc, itemId); |
---|
59 | SpotImages spi = rawBioAssay.getSpotImages(); |
---|
60 | |
---|
61 | if (!rawBioAssay.hasPermission(Permission.WRITE)) |
---|
62 | { |
---|
63 | throw new PermissionDeniedException(Permission.WRITE, itemType.toString()); |
---|
64 | } |
---|
65 | boolean readRedImageFile = true; |
---|
66 | boolean readGreenImageFile = true; |
---|
67 | boolean readBlueImageFile = true; |
---|
68 | boolean readSpotImagesFile = true; |
---|
69 | File redImageFile = null; |
---|
70 | File greenImageFile = null; |
---|
71 | File blueImageFile = null; |
---|
72 | File spotImagesFile = null; |
---|
73 | try |
---|
74 | { |
---|
75 | redImageFile = spi.getRedImageFile(); |
---|
76 | } |
---|
77 | catch (PermissionDeniedException ex) |
---|
78 | { |
---|
79 | readRedImageFile = false; |
---|
80 | } |
---|
81 | try |
---|
82 | { |
---|
83 | greenImageFile = spi.getGreenImageFile(); |
---|
84 | } |
---|
85 | catch (PermissionDeniedException ex) |
---|
86 | { |
---|
87 | readGreenImageFile = false; |
---|
88 | } |
---|
89 | try |
---|
90 | { |
---|
91 | blueImageFile = spi.getBlueImageFile(); |
---|
92 | } |
---|
93 | catch (PermissionDeniedException ex) |
---|
94 | { |
---|
95 | readBlueImageFile = false; |
---|
96 | } |
---|
97 | try |
---|
98 | { |
---|
99 | spotImagesFile = spi.getSpotImagesFile(); |
---|
100 | } |
---|
101 | catch (PermissionDeniedException ex) |
---|
102 | { |
---|
103 | readSpotImagesFile = false; |
---|
104 | } |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | %> |
---|
109 | |
---|
110 | <base:page type="popup" title="<%=title%>"> |
---|
111 | <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css"> |
---|
112 | <script> |
---|
113 | // Validate the "RawBioAssay" tab |
---|
114 | function validateSpotImages() |
---|
115 | { |
---|
116 | var frm = document.forms['spotimages']; |
---|
117 | |
---|
118 | return true; |
---|
119 | } |
---|
120 | function selectRedFileOnClick() |
---|
121 | { |
---|
122 | var frm = document.forms['spotimages']; |
---|
123 | var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setRedFileCallback'; |
---|
124 | url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(File.IMAGE)%>'; |
---|
125 | if (frm.redfile_id.length > 1) url += '&item_id='+frm.redfile_id[1].value; |
---|
126 | Main.openPopup(url, 'SelectRedFile', 1050, 700); |
---|
127 | } |
---|
128 | function setRedFileCallback(fileId, name) |
---|
129 | { |
---|
130 | var frm = document.forms['spotimages']; |
---|
131 | if (frm.redfile_id.length < 2) // > |
---|
132 | { |
---|
133 | frm.redfile_id[frm.redfile_id.length] = new Option(); |
---|
134 | } |
---|
135 | frm.redfile_id[1].value = fileId; |
---|
136 | frm.redfile_id[1].text = name; |
---|
137 | frm.redfile_id.selectedIndex = 1; |
---|
138 | } |
---|
139 | |
---|
140 | function selectGreenFileOnClick() |
---|
141 | { |
---|
142 | var frm = document.forms['spotimages']; |
---|
143 | var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setGreenFileCallback'; |
---|
144 | url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(File.IMAGE)%>'; |
---|
145 | if (frm.greenfile_id.length > 1) url += '&item_id='+frm.greenfile_id[1].value; |
---|
146 | Main.openPopup(url, 'SelectGreenFile', 1050, 700); |
---|
147 | } |
---|
148 | function setGreenFileCallback(fileId, name) |
---|
149 | { |
---|
150 | var frm = document.forms['spotimages']; |
---|
151 | if (frm.greenfile_id.length < 2) // > |
---|
152 | { |
---|
153 | frm.greenfile_id[frm.greenfile_id.length] = new Option(); |
---|
154 | } |
---|
155 | frm.greenfile_id[1].value = fileId; |
---|
156 | frm.greenfile_id[1].text = name; |
---|
157 | frm.greenfile_id.selectedIndex = 1; |
---|
158 | } |
---|
159 | |
---|
160 | function selectBlueFileOnClick() |
---|
161 | { |
---|
162 | var frm = document.forms['spotimages']; |
---|
163 | var url = '../../filemanager/index.jsp?ID=<%=ID%>&cmd=SelectOne&callback=setBlueFileCallback'; |
---|
164 | url += '&resetTemporary=1&tmpfilter:INT:itemSubtype=<%=SystemItems.getId(File.IMAGE)%>'; |
---|
165 | if (frm.bluefile_id.length > 1) url += '&item_id='+frm.bluefile_id[1].value; |
---|
166 | Main.openPopup(url, 'SelectBlueFile', 1050, 700); |
---|
167 | } |
---|
168 | function setBlueFileCallback(fileId, name) |
---|
169 | { |
---|
170 | var frm = document.forms['spotimages']; |
---|
171 | if (frm.bluefile_id.length < 2) // > |
---|
172 | { |
---|
173 | frm.bluefile_id[frm.bluefile_id.length] = new Option(); |
---|
174 | } |
---|
175 | frm.bluefile_id[1].value = fileId; |
---|
176 | frm.bluefile_id[1].text = name; |
---|
177 | frm.bluefile_id.selectedIndex = 1; |
---|
178 | } |
---|
179 | |
---|
180 | function browseOnClick() |
---|
181 | { |
---|
182 | Main.openPopup('../../filemanager/index.jsp?ID=<%=ID%>&cmd=SaveAs&callback=setSaveAsCallback', 'SaveAs', 1050, 700); |
---|
183 | } |
---|
184 | function setSaveAsCallback(path) |
---|
185 | { |
---|
186 | var frm = document.forms['spotimages']; |
---|
187 | frm.path.value = path; |
---|
188 | } |
---|
189 | |
---|
190 | // Submit the form |
---|
191 | function saveSettings() |
---|
192 | { |
---|
193 | var frm = document.forms['spotimages']; |
---|
194 | frm.submit(); |
---|
195 | } |
---|
196 | </script> |
---|
197 | </base:head> |
---|
198 | <base:body> |
---|
199 | <h1><%=title%> <base:help helpid="rawbioassay.edit.spotimages" /></h1> |
---|
200 | <form action="index.jsp?ID=<%=ID%>" method="post" name="spotimages"> |
---|
201 | <input type="hidden" name="item_id" value="<%=itemId%>"> |
---|
202 | <input type="hidden" name="cmd" value="CreateSpotImages"> |
---|
203 | |
---|
204 | <div class="content filled bottomborder"> |
---|
205 | <table class="fullform input100"> |
---|
206 | <tbody class="sectionheader"> |
---|
207 | <tr> |
---|
208 | <th colspan="4">Scale, offset, etc. for the spots</th> |
---|
209 | </tr> |
---|
210 | </tbody> |
---|
211 | <tbody> |
---|
212 | <tr> |
---|
213 | <th>X scale</th> |
---|
214 | <td><input type="text" class="text required" name="x_scale" style="width: 8em;" |
---|
215 | value="<%=spi.getXScale()%>" maxlength="10" |
---|
216 | onkeypress="return Numbers.integerOnly(event)"></td> |
---|
217 | |
---|
218 | <th class="leftborder">Y scale</th> |
---|
219 | <td><input type="text" class="text required" name="y_scale" style="width: 8em;" |
---|
220 | value="<%=spi.getYScale()%>" maxlength="10" |
---|
221 | onkeypress="return Numbers.integerOnly(event)"></td> |
---|
222 | </tr> |
---|
223 | <tr> |
---|
224 | <th>X offset</th> |
---|
225 | <td><input type="text" class="text required" name="x_offset" style="width: 8em;" |
---|
226 | value="<%=spi.getXOffset()%>" maxlength="10" |
---|
227 | onkeypress="return Numbers.integerOnly(event)"></td> |
---|
228 | |
---|
229 | <th class="leftborder">Y offset</th> |
---|
230 | <td><input type="text" class="text required" name="y_offset" style="width: 8em;" |
---|
231 | value="<%=spi.getYOffset()%>" maxlength="10" |
---|
232 | onkeypress="return Numbers.integerOnly(event)"></td> |
---|
233 | </tr> |
---|
234 | <tr> |
---|
235 | <th>Spot size</th> |
---|
236 | <td><input type="text" class="text required" name="spotsize" style="width: 8em;" |
---|
237 | value="<%=spi.getSpotsize()%>" maxlength="10" |
---|
238 | onkeypress="return Numbers.integerOnly(event)"></td> |
---|
239 | |
---|
240 | <th class="leftborder">Gamma correction</th> |
---|
241 | <td><input type="text" class="text required" name="gamma" style="width: 8em;" |
---|
242 | value="<%=spi.getGamma()%>" maxlength="10" |
---|
243 | onkeypress="return Numbers.numberOnly(event)"></td> |
---|
244 | </tr> |
---|
245 | <tr> |
---|
246 | <th>Quality</th> |
---|
247 | <td><input type="text" class="text required" name="quality" style="width: 8em;" |
---|
248 | value="<%=spi.getQuality()%>" maxlength="10" |
---|
249 | onkeypress="return Numbers.integerOnly(event)"></td> |
---|
250 | <th class="leftborder"></th> |
---|
251 | <td></td> |
---|
252 | </tr> |
---|
253 | </tbody> |
---|
254 | <tbody class="sectionheader"> |
---|
255 | <tr> |
---|
256 | <th colspan="4">Raw image files</th> |
---|
257 | </tr> |
---|
258 | </tbody> |
---|
259 | <tbody> |
---|
260 | <tr> |
---|
261 | <th>Red image file</th> |
---|
262 | <td colspan="3"> |
---|
263 | <table> |
---|
264 | <tr> |
---|
265 | <td> |
---|
266 | <select name="redfile_id" style="width: 25em;"> |
---|
267 | <option value="0">- none - |
---|
268 | <% |
---|
269 | if (redImageFile != null) |
---|
270 | { |
---|
271 | %> |
---|
272 | <option value="<%=redImageFile.getId()%>" selected><%=HTML.encodeTags(redImageFile.getPath().toString())%> |
---|
273 | <% |
---|
274 | } |
---|
275 | %> |
---|
276 | </select> |
---|
277 | </td> |
---|
278 | <td><base:button onclick="selectRedFileOnClick()" title="Select…" /></td> |
---|
279 | </tr> |
---|
280 | </table> |
---|
281 | </td> |
---|
282 | </tr> |
---|
283 | |
---|
284 | <tr> |
---|
285 | <th>Green image file</th> |
---|
286 | <td colspan="3"> |
---|
287 | <table> |
---|
288 | <tr> |
---|
289 | <td> |
---|
290 | <select name="greenfile_id" style="width: 25em;"> |
---|
291 | <option value="0">- none - |
---|
292 | <% |
---|
293 | if (greenImageFile != null) |
---|
294 | { |
---|
295 | %> |
---|
296 | <option value="<%=greenImageFile.getId()%>" selected><%=HTML.encodeTags(greenImageFile.getPath().toString())%> |
---|
297 | <% |
---|
298 | } |
---|
299 | %> |
---|
300 | </select> |
---|
301 | </td> |
---|
302 | <td><base:button onclick="selectGreenFileOnClick()" title="Select…" /></td> |
---|
303 | </tr> |
---|
304 | </table> |
---|
305 | </td> |
---|
306 | </tr> |
---|
307 | |
---|
308 | <tr> |
---|
309 | <th>Blue image file</th> |
---|
310 | <td colspan="3"> |
---|
311 | <table> |
---|
312 | <tr> |
---|
313 | <td> |
---|
314 | <select name="bluefile_id" style="width: 25em;"> |
---|
315 | <option value="0">- none - |
---|
316 | <% |
---|
317 | if (blueImageFile != null) |
---|
318 | { |
---|
319 | %> |
---|
320 | <option value="<%=blueImageFile.getId()%>" selected><%=HTML.encodeTags(blueImageFile.getPath().toString())%> |
---|
321 | <% |
---|
322 | } |
---|
323 | %> |
---|
324 | </select> |
---|
325 | </td> |
---|
326 | <td><base:button onclick="selectBlueFileOnClick()" title="Select…" /></td> |
---|
327 | </tr> |
---|
328 | </table> |
---|
329 | </td> |
---|
330 | </tr> |
---|
331 | |
---|
332 | <tr > |
---|
333 | <th>Save as</th> |
---|
334 | <td colspan="3"> |
---|
335 | <table style="width: 100%;"> |
---|
336 | <tr> |
---|
337 | <td style="width: 98%;"><input type="text" class="text required" |
---|
338 | name="path" |
---|
339 | value="<%=spotImagesFile == null ? "" : HTML.encodeTags(spotImagesFile.getPath().toString())%>"></td> |
---|
340 | <td ><base:button |
---|
341 | title="Browse..." |
---|
342 | onclick="browseOnClick()" |
---|
343 | /> |
---|
344 | </td> |
---|
345 | </tr> |
---|
346 | </table> |
---|
347 | </td> |
---|
348 | </tr> |
---|
349 | <tr> |
---|
350 | <th class="subprompt"></th> |
---|
351 | <td colspan="3"><input type="checkbox" name="overwrite" id="overwrite" value="1"><label for="overwrite">Overwrite existing file</label></td> |
---|
352 | </tr> |
---|
353 | <tr class="dynamic"> |
---|
354 | <th></th> |
---|
355 | <td colspan="3"></td> |
---|
356 | </tr> |
---|
357 | </tbody> |
---|
358 | </table> |
---|
359 | </div> |
---|
360 | </form> |
---|
361 | |
---|
362 | <div class="legend"> |
---|
363 | <base:icon image="required.png" />= required information |
---|
364 | </div> |
---|
365 | |
---|
366 | <base:buttongroup subclass="dialogbuttons"> |
---|
367 | <base:button onclick="saveSettings()" title="Create" image="ok.png"/> |
---|
368 | <base:button onclick="window.close()" title="Cancel" /> |
---|
369 | </base:buttongroup> |
---|
370 | </base:body> |
---|
371 | </base:page> |
---|
372 | <% |
---|
373 | } |
---|
374 | finally |
---|
375 | { |
---|
376 | if (dc != null) dc.close(); |
---|
377 | } |
---|
378 | %> |
---|