source: branches/filedb/www/admin/platforms/edit_platform.jsp @ 3798

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

References #721: Changed systemId to externalId in JSP as well

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.6 KB
Line 
1<%-- $Id: edit_platform.jsp 3798 2007-09-28 06:45:09Z 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  %>
80
81  <base:page type="popup" title="<%=title%>">
82  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
83    <script language="JavaScript">
84    // Validate the "Platform" tab
85    function validatePlatform()
86    {
87      var frm = document.forms['platform'];
88      var fileOnly = Forms.getCheckedRadio(frm.fileOnly).value == '1';
89      if (Main.trimString(frm.name.value) == '')
90      {
91        alert("You must enter a name");
92        frm.name.focus();
93        return false;
94      }
95      else if (Main.trimString(frm.externalId.value) == '')
96      {
97        alert("You must enter an external ID");
98        frm.externalId.focus();
99        return false;
100      }
101      else if (fileOnly)
102      {
103        if (!Numbers.isInteger(frm.channels.value))
104        {
105          alert("You must enter the number of channels");
106          frm.channels.focus();
107          return false;
108        }
109        if (parseInt(frm.channels.value) <= 0)
110        {
111          alert("The number of channels must be > 0");
112          frm.channels.focus();
113          return false;
114        }
115      }
116      return true;
117    }
118
119    // Submit the form
120    function saveSettings()
121    {
122      var frm = document.forms['platform'];
123      if (TabControl.validateActiveTab('settings'))
124      {
125        frm.submit();
126      }
127    }
128   
129    function init()
130    {
131      <%
132      if (platform == null)
133      {
134        %>
135        var frm = document.forms['platform'];
136        frm.name.focus();
137        frm.name.select();
138        <%
139      }
140      %>
141      fileOnlyOnClick();
142    }
143    function fileOnlyOnClick()
144    {
145      var frm = document.forms['platform'];
146      var fileOnly = Forms.getCheckedRadio(frm.fileOnly).value == '1';
147      frm.rawdatatype.disabled = fileOnly;
148      frm.channels.disabled = !fileOnly;
149      Main.addOrRemoveClass(frm.rawdatatype, 'required', !frm.rawdatatype.disabled);
150      Main.addOrRemoveClass(frm.channels, 'required', !frm.channels.disabled);
151    }
152    </script>
153  </base:head>
154  <base:body onload="init()">
155    <p>
156    <form action="index.jsp?ID=<%=ID%>" method="post" name="platform" onsubmit="return false;">
157    <input type="hidden" name="cmd" value="UpdateItem">
158
159    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
160    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*260)+"px;"%>" 
161      position="bottom"  remember="<%=platform != null%>">
162    <t:tab id="info" title="Platform" validate="validatePlatform()" helpid="platform.edit">
163      <table class="form" cellspacing=0>
164      <tr>
165        <td class="prompt">Name</td>
166        <td><input <%=requiredClazz%> type="text" name="name" 
167          value="<%=HTML.encodeTags(platform == null ? Values.getString(cc.getPropertyValue("name"), "New platform") : platform.getName())%>" 
168          size="40" maxlength="<%=Platform.MAX_NAME_LENGTH%>"></td>
169      </tr>
170      <%
171      if (platform == null)
172      {
173        // For new platforms only
174        RawDataType currentRawDataType = 
175          RawDataTypes.getRawDataType(cc.getPropertyValue("rawDataType"));
176        if (currentRawDataType == null)
177        {
178          currentRawDataType = RawDataTypes.getRawDataType(cc.getRecent("RawDataType", 0));
179        }
180       
181        %>
182        <tr>
183          <td class="prompt">External ID</td>
184          <td><input <%=requiredClazz%> type="text" name="externalId" 
185            value="<%=HTML.encodeTags(cc.getPropertyValue("externalId"))%>" 
186            size="40" maxlength="<%=Platform.MAX_EXTERNAL_ID_LENGTH%>"></td>
187        </tr>
188        <tr>
189          <td class="prompt">File-only</td>
190          <td>
191            <input type="radio" name="fileOnly" value="0" <%=!isFileOnly ? "checked" : ""%>
192              onclick="fileOnlyOnClick()">no
193            <input type="radio" name="fileOnly" value="1" <%=isFileOnly ? "checked" : ""%>
194              onclick="fileOnlyOnClick()">yes
195          </td>
196        </tr>
197
198        <tr>
199          <td class="prompt">Raw data type</td>
200          <td>
201            <select name="rawdatatype" class="required">
202            <option value="">- any -
203            <%
204            for (RawDataType rdt : RawDataTypes.getRawDataTypes())
205            {
206              String selected = rdt.equals(currentRawDataType) ? "selected" : "";
207              %>
208              <option value="<%=rdt.getId()%>" <%=selected%>><%=HTML.encodeTags(rdt.getName())%>
209              <%
210            }
211            %>
212            </select>
213          </td>
214        </tr>
215        <tr>
216          <td class="prompt">Channels</td>
217          <td><input <%=requiredClazz%> type="text" name="channels" 
218            value="<%=Values.getInt(cc.getPropertyValue("channels"), 1)%>" 
219            size="12" maxlength="10" 
220            onkeypress="return Numbers.integerOnly(event)"></td>
221        </tr>
222        <%
223      }
224      %>
225      <tr valign=top>
226        <td class="prompt">Description</td>
227        <td nowrap>
228          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
229            ><%=HTML.encodeTags(platform == null ? cc.getPropertyValue("description") : platform.getDescription())%></textarea>
230          <a href="javascript:Main.zoom('Description', 'platform', 'description')"
231            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
232        </td>
233      </tr>
234      </table>
235      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
236    </t:tab>
237    </t:tabcontrol>
238
239    <table align="center">
240    <tr>
241      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
242      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
243    </tr>
244    </table>
245    </form>
246  </base:body>
247  </base:page>
248  <%
249}
250finally
251{
252  if (dc != null) dc.close();
253}
254%>
Note: See TracBrowser for help on using the repository browser.