source: branches/filedb/www/admin/platforms/edit_platform.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: 7.9 KB
Line 
1<%-- $Id: edit_platform.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.RawDataType"
37  import="net.sf.basedb.core.RawDataTypes"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.clients.web.Base"
40  import="net.sf.basedb.clients.web.util.HTML"
41  import="net.sf.basedb.util.Values"
42%>
43<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
44<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
45<%
46final Item itemType = Item.PLATFORM;
47final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
48final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
49final int itemId = cc.getId();
50final String ID = sc.getId();
51final float scale = Base.getScale(sc);
52final DbControl dc = sc.newDbControl();
53try
54{
55  String title = null;
56  Platform platform = null;
57  boolean isFileOnly = false;
58
59  if (itemId == 0)
60  {
61    title = "Create platform";
62    isFileOnly = Values.getBoolean(cc.getPropertyValue("fileOnly"), isFileOnly);
63    cc.removeObject("item");
64  }
65  else
66  {
67    platform = Platform.getById(dc, itemId);
68    isFileOnly = platform.isFileOnly();
69    cc.setObject("item", platform);
70    title = "Edit platform -- " + HTML.encodeTags(platform.getName());
71  }
72  if (platform != null)
73  {
74    platform.checkPermission(Permission.WRITE);
75  }
76 
77  final String clazz = "class=\"text\"";
78  final String requiredClazz = "class=\"text required\"";
79  final String unchangeableClazz = "class=\"text required unchangeable\"";
80  %>
81
82  <base:page type="popup" title="<%=title%>">
83  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
84    <script language="JavaScript">
85    // Validate the "Platform" tab
86    function validatePlatform()
87    {
88      var frm = document.forms['platform'];
89      if (Main.trimString(frm.name.value) == '')
90      {
91        alert("You must enter a name");
92        frm.name.focus();
93        return false;
94      }
95      if (frm.externalId)
96      {
97        var fileOnly = Forms.getCheckedRadio(frm.fileOnly).value == '1';
98        if (Main.trimString(frm.externalId.value) == '')
99        {
100          alert("You must enter an external ID");
101          frm.externalId.focus();
102          return false;
103        }
104        else if (fileOnly)
105        {
106          if (!Numbers.isInteger(frm.channels.value))
107          {
108            alert("You must enter the number of channels");
109            frm.channels.focus();
110            return false;
111          }
112          if (parseInt(frm.channels.value) <= 0)
113          {
114            alert("The number of channels must be > 0");
115            frm.channels.focus();
116            return false;
117          }
118        }
119      }
120      return true;
121    }
122
123    // Submit the form
124    function saveSettings()
125    {
126      var frm = document.forms['platform'];
127      if (TabControl.validateActiveTab('settings'))
128      {
129        frm.submit();
130      }
131    }
132   
133    function init()
134    {
135      <%
136      if (platform == null)
137      {
138        %>
139        var frm = document.forms['platform'];
140        frm.name.focus();
141        frm.name.select();
142        <%
143      }
144      %>
145      fileOnlyOnClick();
146    }
147    function fileOnlyOnClick()
148    {
149      var frm = document.forms['platform'];
150      var fileOnly = Forms.getCheckedRadio(frm.fileOnly).value == '1';
151      frm.rawdatatype.disabled = fileOnly;
152      frm.channels.disabled = !fileOnly;
153      Main.addOrRemoveClass(frm.rawdatatype, 'required', !frm.rawdatatype.disabled);
154      Main.addOrRemoveClass(frm.channels, 'required', !frm.channels.disabled);
155    }
156    </script>
157  </base:head>
158  <base:body onload="init()">
159    <p>
160    <form action="index.jsp?ID=<%=ID%>" method="post" name="platform" onsubmit="return false;">
161    <input type="hidden" name="cmd" value="UpdateItem">
162
163    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
164    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" 
165      position="bottom"  remember="<%=platform != null%>">
166    <t:tab id="info" title="Platform" validate="validatePlatform()" helpid="platform.edit">
167      <table class="form" cellspacing=0>
168      <tr>
169        <td class="prompt">Name</td>
170        <td><input <%=requiredClazz%> type="text" name="name" 
171          value="<%=HTML.encodeTags(platform == null ? Values.getString(cc.getPropertyValue("name"), "New platform") : platform.getName())%>" 
172          size="40" maxlength="<%=Platform.MAX_NAME_LENGTH%>"></td>
173      </tr>
174      <%
175      if (platform == null)
176      {
177        // For new platforms only
178        RawDataType currentRawDataType = 
179          RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType"));
180        if (currentRawDataType == null)
181        {
182          currentRawDataType = RawDataTypes.getRawDataType(cc.getRecent("RawDataType", 0));
183        }
184       
185        %>
186        <tr>
187          <td class="prompt">External ID</td>
188          <td><input <%=unchangeableClazz%> type="text" name="externalId" 
189            value="<%=HTML.encodeTags(cc.getPropertyValue("externalId"))%>" 
190            size="40" maxlength="<%=Platform.MAX_EXTERNAL_ID_LENGTH%>"></td>
191        </tr>
192        <tr>
193          <td class="prompt">File-only</td>
194          <td>
195            <input <%=unchangeableClazz%> type="radio" name="fileOnly" value="0" <%=!isFileOnly ? "checked" : ""%>
196              onclick="fileOnlyOnClick()">no
197            <input <%=unchangeableClazz%> type="radio" name="fileOnly" value="1" <%=isFileOnly ? "checked" : ""%>
198              onclick="fileOnlyOnClick()">yes
199          </td>
200        </tr>
201
202        <tr>
203          <td class="prompt">Raw data type</td>
204          <td>
205            <select name="rawdatatype" <%=unchangeableClazz%>>
206            <option value="">- any -
207            <%
208            for (RawDataType rdt : RawDataTypes.getRawDataTypes())
209            {
210              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
211              %>
212              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
213              <%
214            }
215            %>
216            </select>
217          </td>
218        </tr>
219        <tr>
220          <td class="prompt">Channels</td>
221          <td><input <%=unchangeableClazz%> type="text" name="channels" 
222            value="<%=Values.getInt(cc.getPropertyValue("channels"), 1)%>" 
223            size="12" maxlength="10" 
224            onkeypress="return Numbers.integerOnly(event)"></td>
225        </tr>
226        <%
227      }
228      %>
229      <tr valign=top>
230        <td class="prompt">Description</td>
231        <td nowrap>
232          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
233            ><%=HTML.encodeTags(platform == null ? cc.getPropertyValue("description") : platform.getDescription())%></textarea>
234          <a href="javascript:Main.zoom('Description', 'platform', 'description')"
235            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
236        </td>
237      </tr>
238      </table>
239      <div align=right>
240        &nbsp;<i><base:icon image="required.gif" /> = required information</i>
241        <%if (platform == null) {%><br>
242        <i><base:icon image="unchangeable.gif" /> = can't be changed later</i>
243        <%}%>
244        </div>
245    </t:tab>
246    </t:tabcontrol>
247
248    <table align="center">
249    <tr>
250      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
251      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
252    </tr>
253    </table>
254    </form>
255  </base:body>
256  </base:page>
257  <%
258}
259finally
260{
261  if (dc != null) dc.close();
262}
263%>
Note: See TracBrowser for help on using the repository browser.