source: branches/filedb/www/admin/platforms/variants/edit_variant.jsp @ 3799

Last change on this file since 3799 was 3799, checked in by Nicklas Nordborg, 15 years ago

References #721: Added platform variants to web gui.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.4 KB
Line 
1<%-- $Id: edit_variant.jsp 3799 2007-09-28 07:50:15Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Hakkinen, Nicklas Nordborg, Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 2
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place - Suite 330,
22  Boston, MA  02111-1307, USA.
23  ------------------------------------------------------------------
24
25
26  @author Nicklas
27  @version 2.0
28--%>
29<%@ page session="false"
30  import="net.sf.basedb.core.SessionControl"
31  import="net.sf.basedb.core.DbControl"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.Platform"
36  import="net.sf.basedb.core.PlatformVariant"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.RawDataTypes"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.clients.web.Base"
41  import="net.sf.basedb.clients.web.util.HTML"
42  import="net.sf.basedb.util.Values"
43%>
44<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
45<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
46<%
47final int platformId = Values.getInt(request.getParameter("platform_id"));
48final Item itemType = Item.PLATFORMVARIANT;
49final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
50final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
51final int itemId = cc.getId();
52final String ID = sc.getId();
53final float scale = Base.getScale(sc);
54final DbControl dc = sc.newDbControl();
55try
56{
57  String title = null;
58  Platform platform = null;
59  PlatformVariant variant = null;
60  boolean isFileOnly = false;
61
62  if (itemId == 0)
63  {
64    title = "Create platform variant";
65    platform = Platform.getById(dc, platformId);
66    isFileOnly = Values.getBoolean(cc.getPropertyValue("fileOnly"), platform.isFileOnly());
67    cc.removeObject("item");
68    platform.checkPermission(Permission.WRITE);
69  }
70  else
71  {
72    variant = PlatformVariant.getById(dc, itemId);
73    platform = variant.getPlatform();
74    isFileOnly = variant.isFileOnly();
75    cc.setObject("item", variant);
76    title = "Edit platform variant -- " + HTML.encodeTags(variant.getName());
77    variant.checkPermission(Permission.WRITE);
78  }
79 
80  final String clazz = "class=\"text\"";
81  final String requiredClazz = "class=\"text required\"";
82  final String unchangeableClazz = "class=\"text required unchangeable\"";
83  %>
84
85  <base:page type="popup" title="<%=title%>">
86  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
87    <script language="JavaScript">
88    // Validate the "Variant" tab
89    function validateVariant()
90    {
91      var frm = document.forms['variant'];
92      if (Main.trimString(frm.name.value) == '')
93      {
94        alert("You must enter a name");
95        frm.name.focus();
96        return false;
97      }
98      if (frm.externalId)
99      {
100        var fileOnly = Forms.getCheckedRadio(frm.fileOnly).value == '1';
101        if (Main.trimString(frm.externalId.value) == '')
102        {
103          alert("You must enter an external ID");
104          frm.externalId.focus();
105          return false;
106        }
107        else if (fileOnly)
108        {
109          if (!Numbers.isInteger(frm.channels.value))
110          {
111            alert("You must enter the number of channels");
112            frm.channels.focus();
113            return false;
114          }
115          if (parseInt(frm.channels.value) <= 0)
116          {
117            alert("The number of channels must be > 0");
118            frm.channels.focus();
119            return false;
120          }
121        }
122      }
123      return true;
124    }
125
126    // Submit the form
127    function saveSettings()
128    {
129      var frm = document.forms['variant'];
130      if (TabControl.validateActiveTab('settings'))
131      {
132        frm.submit();
133      }
134    }
135   
136    function init()
137    {
138      <%
139      if (variant == null)
140      {
141        %>
142        var frm = document.forms['variant'];
143        frm.name.focus();
144        frm.name.select();
145        <%
146      }
147      %>
148      fileOnlyOnClick();
149    }
150    function fileOnlyOnClick()
151    {
152      var frm = document.forms['variant'];
153      var fileOnly = Forms.getCheckedRadio(frm.fileOnly).value == '1';
154      frm.rawdatatype.disabled = fileOnly;
155      frm.channels.disabled = !fileOnly;
156      Main.addOrRemoveClass(frm.rawdatatype, 'required', !frm.rawdatatype.disabled);
157      Main.addOrRemoveClass(frm.channels, 'required', !frm.channels.disabled);
158    }
159    </script>
160  </base:head>
161  <base:body onload="init()">
162    <p>
163    <form action="index.jsp?ID=<%=ID%>" method="post" name="variant" onsubmit="return false;">
164    <input type="hidden" name="cmd" value="UpdateItem">
165    <input type="hidden" name="platform_id" value="<%=platformId%>">
166
167    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
168    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" 
169      position="bottom"  remember="<%=variant != null%>">
170    <t:tab id="info" title="Platform" validate="validateVariant()" helpid="platformvariant.edit">
171      <table class="form" cellspacing=0>
172      <tr>
173        <td class="prompt">Name</td>
174        <td><input <%=requiredClazz%> type="text" name="name" 
175          value="<%=HTML.encodeTags(variant == null ? 
176              Values.getString(cc.getPropertyValue("name"), "New " + platform.getName() + " variant") : 
177              variant.getName())%>" 
178          size="40" maxlength="<%=PlatformVariant.MAX_NAME_LENGTH%>"></td>
179      </tr>
180      <%
181      if (variant == null)
182      {
183        // For new platforms only
184        RawDataType currentRawDataType = 
185          RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType"));
186        if (currentRawDataType == null)
187        {
188          currentRawDataType = platform.getRawDataType();
189        }
190        %>
191        <tr>
192          <td class="prompt">External ID</td>
193          <td><input <%=unchangeableClazz%> type="text" name="externalId" 
194            value="<%=HTML.encodeTags(Values.getString(cc.getPropertyValue("externalId"), platform.getExternalId() + ".new"))%>" 
195            size="40" maxlength="<%=PlatformVariant.MAX_EXTERNAL_ID_LENGTH%>"></td>
196        </tr>
197        <tr>
198          <td class="prompt">File-only</td>
199          <td>
200            <input <%=unchangeableClazz%> type="radio" name="fileOnly" value="0" <%=!isFileOnly ? "checked" : ""%>
201              onclick="fileOnlyOnClick()">no
202            <input <%=unchangeableClazz%> type="radio" name="fileOnly" value="1" <%=isFileOnly ? "checked" : ""%>
203              onclick="fileOnlyOnClick()">yes
204          </td>
205        </tr>
206
207        <tr>
208          <td class="prompt">Raw data type</td>
209          <td>
210            <select name="rawdatatype" <%=unchangeableClazz%>>
211            <option value="">- any -
212            <%
213            for (RawDataType rdt : RawDataTypes.getRawDataTypes())
214            {
215              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
216              %>
217              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
218              <%
219            }
220            %>
221            </select>
222          </td>
223        </tr>
224        <tr>
225          <td class="prompt">Channels</td>
226          <td><input <%=unchangeableClazz%> type="text" name="channels" 
227            value="<%=Values.getInt(cc.getPropertyValue("channels"), currentRawDataType == null ? 1 : currentRawDataType.getChannels())%>" 
228            size="12" maxlength="10" 
229            onkeypress="return Numbers.integerOnly(event)"></td>
230        </tr>
231        <%
232      }
233      %>
234      <tr valign=top>
235        <td class="prompt">Description</td>
236        <td nowrap>
237          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
238            ><%=HTML.encodeTags(variant == null ? cc.getPropertyValue("description") : variant.getDescription())%></textarea>
239          <a href="javascript:Main.zoom('Description', 'variant', 'description')"
240            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
241        </td>
242      </tr>
243      </table>
244      <div align=right>
245        &nbsp;<i><base:icon image="required.gif" /> = required information</i>
246        <%if (variant == null) {%><br>
247        <i><base:icon image="unchangeable.gif" /> = can't be changed later</i>
248        <%}%>
249        </div>
250    </t:tab>
251    </t:tabcontrol>
252
253    <table align="center">
254    <tr>
255      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
256      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
257    </tr>
258    </table>
259    </form>
260  </base:body>
261  </base:page>
262  <%
263}
264finally
265{
266  if (dc != null) dc.close();
267}
268%>
Note: See TracBrowser for help on using the repository browser.