1 | <%-- $Id $ |
---|
2 | ------------------------------------------------------------------ |
---|
3 | Copyright (C) 2010 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.ItemContext" |
---|
31 | import="net.sf.basedb.core.SystemItems" |
---|
32 | import="net.sf.basedb.core.Permission" |
---|
33 | import="net.sf.basedb.core.Include" |
---|
34 | import="net.sf.basedb.core.BioPlateType" |
---|
35 | import="net.sf.basedb.core.BioWell" |
---|
36 | import="net.sf.basedb.core.ItemQuery" |
---|
37 | import="net.sf.basedb.core.ItemResultList" |
---|
38 | import="net.sf.basedb.core.PermissionDeniedException" |
---|
39 | import="net.sf.basedb.core.BaseException" |
---|
40 | import="net.sf.basedb.core.query.Orders" |
---|
41 | import="net.sf.basedb.core.query.Hql" |
---|
42 | import="net.sf.basedb.clients.web.Base" |
---|
43 | import="net.sf.basedb.clients.web.util.HTML" |
---|
44 | import="net.sf.basedb.util.Values" |
---|
45 | import="net.sf.basedb.core.plugin.GuiContext" |
---|
46 | import="net.sf.basedb.clients.web.extensions.ExtensionsControl" |
---|
47 | import="net.sf.basedb.clients.web.extensions.JspContext" |
---|
48 | import="net.sf.basedb.clients.web.extensions.edit.EditUtil" |
---|
49 | import="net.sf.basedb.util.extensions.ExtensionsInvoker" |
---|
50 | import="java.util.List" |
---|
51 | import="java.util.Set" |
---|
52 | import="java.util.HashSet" |
---|
53 | import="java.util.Date" |
---|
54 | %> |
---|
55 | <%@ taglib prefix="base" uri="/WEB-INF/base.tld" %> |
---|
56 | <%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %> |
---|
57 | <% |
---|
58 | final Item itemType = Item.BIOPLATETYPE; |
---|
59 | final SessionControl sc = Base.getExistingSessionControl(pageContext, true); |
---|
60 | final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null); |
---|
61 | final int itemId = cc.getId(); |
---|
62 | final String ID = sc.getId(); |
---|
63 | final float scale = Base.getScale(sc); |
---|
64 | final DbControl dc = sc.newDbControl(); |
---|
65 | try |
---|
66 | { |
---|
67 | String title = null; |
---|
68 | BioPlateType bioPlateType = null; |
---|
69 | BioWell.LockMode lockMode = BioWell.LockMode.UNLOCKED; |
---|
70 | |
---|
71 | if (itemId == 0) |
---|
72 | { |
---|
73 | title = "Create bioplate type"; |
---|
74 | cc.removeObject("item"); |
---|
75 | int lm = Values.getInt(cc.getPropertyValue("lockMode")); |
---|
76 | lockMode = BioWell.LockMode.fromValue(lm); |
---|
77 | } |
---|
78 | else |
---|
79 | { |
---|
80 | bioPlateType = BioPlateType.getById(dc, itemId); |
---|
81 | bioPlateType.checkPermission(Permission.WRITE); |
---|
82 | lockMode = bioPlateType.getLockMode(); |
---|
83 | cc.setObject("item", bioPlateType); |
---|
84 | title = "Edit bioplate type -- " + HTML.encodeTags(bioPlateType.getName()); |
---|
85 | } |
---|
86 | final String clazz = "class=\"text\""; |
---|
87 | final String requiredClazz = "class=\"text required\""; |
---|
88 | JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioPlateType); |
---|
89 | ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext); |
---|
90 | %> |
---|
91 | <base:page type="popup" title="<%=title%>"> |
---|
92 | <base:head scripts="tabcontrol.js" styles="tabcontrol.css"> |
---|
93 | <ext:scripts context="<%=jspContext%>" /> |
---|
94 | <ext:stylesheets context="<%=jspContext%>" /> |
---|
95 | <script language="JavaScript"> |
---|
96 | // Validate the "BioPlateType" tab |
---|
97 | function validateBioPlateType() |
---|
98 | { |
---|
99 | var frm = document.forms['bioPlateType']; |
---|
100 | if (Main.trimString(frm.name.value) == '') |
---|
101 | { |
---|
102 | alert("You must enter a name"); |
---|
103 | frm.name.focus(); |
---|
104 | return false; |
---|
105 | } |
---|
106 | return true; |
---|
107 | } |
---|
108 | |
---|
109 | // Submit the form |
---|
110 | function saveSettings() |
---|
111 | { |
---|
112 | var frm = document.forms['bioPlateType']; |
---|
113 | if (TabControl.validateActiveTab('settings')) |
---|
114 | { |
---|
115 | frm.submit(); |
---|
116 | } |
---|
117 | } |
---|
118 | |
---|
119 | function init() |
---|
120 | { |
---|
121 | var frm = document.forms['bioPlateType']; |
---|
122 | <% |
---|
123 | if (bioPlateType == null) |
---|
124 | { |
---|
125 | %> |
---|
126 | frm.name.focus(); |
---|
127 | frm.name.select(); |
---|
128 | <% |
---|
129 | } |
---|
130 | %> |
---|
131 | } |
---|
132 | </script> |
---|
133 | </base:head> |
---|
134 | <base:body onload="init()"> |
---|
135 | <p> |
---|
136 | <form action="index.jsp?ID=<%=ID%>" method="post" name="bioPlateType" onsubmit="return false;"> |
---|
137 | <input type="hidden" name="cmd" value="UpdateItem"> |
---|
138 | |
---|
139 | <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3> |
---|
140 | <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" |
---|
141 | position="bottom" remember="<%=bioPlateType != null%>" |
---|
142 | extensions="<%=invoker%>"> |
---|
143 | <t:tab id="info" title="Bioplate type" validate="validateBioPlateType()" helpid="bioplatetype.edit"> |
---|
144 | <table class="form" cellspacing=0> |
---|
145 | <tr> |
---|
146 | <td class="prompt">Name</td> |
---|
147 | <td><input <%=requiredClazz%> type="text" name="name" |
---|
148 | value="<%=HTML.encodeTags(bioPlateType == null ? Values.getString(cc.getPropertyValue("name"), "New bioplate type") : bioPlateType.getName())%>" |
---|
149 | size="40" maxlength="<%=BioPlateType.MAX_NAME_LENGTH%>"></td> |
---|
150 | </tr> |
---|
151 | <% |
---|
152 | if (bioPlateType == null) |
---|
153 | { |
---|
154 | %> |
---|
155 | <tr valign=top> |
---|
156 | <td class="prompt">Biomaterial type</td> |
---|
157 | <td> |
---|
158 | <select name="bioMaterialType" class="required unchangeable"> |
---|
159 | <option value="">any |
---|
160 | <option value="<%=Item.SAMPLE.name()%>">Sample |
---|
161 | <option value="<%=Item.EXTRACT.name()%>">Extract |
---|
162 | </select> |
---|
163 | </td> |
---|
164 | </tr> |
---|
165 | <% |
---|
166 | } |
---|
167 | %> |
---|
168 | <tr> |
---|
169 | <td class="prompt">Well lock mode</td> |
---|
170 | <td> |
---|
171 | <select name="lockMode"> |
---|
172 | <% |
---|
173 | for (BioWell.LockMode lm : BioWell.LockMode.values()) |
---|
174 | { |
---|
175 | String selected = lm == lockMode ? "selected" : ""; |
---|
176 | %> |
---|
177 | <option value="<%=lm.name()%>" <%=selected%>><%=lm%> |
---|
178 | <% |
---|
179 | } |
---|
180 | %> |
---|
181 | </select> |
---|
182 | </td> |
---|
183 | </tr> |
---|
184 | <tr valign=top> |
---|
185 | <td class="prompt">Description</td> |
---|
186 | <td nowrap> |
---|
187 | <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual" |
---|
188 | ><%=HTML.encodeTags(bioPlateType == null ? cc.getPropertyValue("description") : bioPlateType.getDescription())%></textarea> |
---|
189 | <a href="javascript:Main.zoom('Description', 'bioPlateType', 'description')" |
---|
190 | title="Edit in larger window"><base:icon image="zoom.gif" /></a> |
---|
191 | </td> |
---|
192 | </tr> |
---|
193 | </table> |
---|
194 | <div align=right> <i><base:icon image="required.gif" /> = required information</i> |
---|
195 | <%if (bioPlateType == null) {%><br> |
---|
196 | <i><base:icon image="unchangeable.gif" /> = can't be changed later</i> |
---|
197 | <%}%> |
---|
198 | </div> |
---|
199 | </t:tab> |
---|
200 | </t:tabcontrol> |
---|
201 | |
---|
202 | <table align="center"> |
---|
203 | <tr> |
---|
204 | <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td> |
---|
205 | <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td> |
---|
206 | </tr> |
---|
207 | </table> |
---|
208 | </form> |
---|
209 | </base:body> |
---|
210 | </base:page> |
---|
211 | <% |
---|
212 | } |
---|
213 | finally |
---|
214 | { |
---|
215 | if (dc != null) dc.close(); |
---|
216 | } |
---|
217 | %> |
---|