source: trunk/www/views/experiments/bioassays/edit_bioassay.jsp @ 2978

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

Added session="false" to all jsp pages so we no longer generate unneeded cookies

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.7 KB
Line 
1<%-- $Id: edit_bioassay.jsp 2978 2006-11-30 07:27:42Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24
25  @author Nicklas
26  @version 2.0
27--%>
28<%@ page session="false"
29  import="net.sf.basedb.core.SessionControl"
30  import="net.sf.basedb.core.DbControl"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.Experiment"
35  import="net.sf.basedb.core.BioAssaySet"
36  import="net.sf.basedb.core.BioAssay"
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%>
42<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
43<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
44<%
45final Item itemType = Item.BIOASSAY;
46final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
47final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
48final int itemId = cc.getId();
49final String ID = sc.getId();
50final float scale = Base.getScale(sc);
51final DbControl dc = sc.newDbControl();
52try
53{
54  BioAssay bioAssay = BioAssay.getById(dc, itemId);
55
56  cc.setObject("item", bioAssay);
57  String title = "Edit bioassay -- " + HTML.encodeTags(bioAssay.getName());
58  if (bioAssay != null) bioAssay.checkPermission(Permission.WRITE);
59  final String clazz = "class=\"text\"";
60  final String requiredClazz = "class=\"text required\"";
61  %>
62
63  <base:page type="popup" title="<%=title%>">
64  <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css">
65    <script language="JavaScript">
66    // Validate the "BioAssay" tab
67    function validateBioAssay()
68    {
69      var frm = document.forms['bioAssay'];
70      if (Main.trimString(frm.name.value) == '')
71      {
72        alert("You must enter a name");
73        frm.name.focus();
74        return false;
75      }
76      return true;
77    }
78
79    // Submit the form
80    function saveSettings()
81    {
82      var frm = document.forms['bioAssay'];
83      if (TabControl.validateActiveTab('settings'))
84      {
85        if (annotationsLoaded)
86        {
87          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
88        }
89        if (inheritedAnnotationsLoaded)
90        {
91          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
92        }
93        frm.submit();
94      }
95    }
96   
97    var annotationsLoaded = false;
98    var inheritedAnnotationsLoaded = false;
99    var parentsChanged = false;
100    var protocolChanged = false;
101    function switchTab(tabControlId, tabId)
102    {
103      if (TabControl.setActiveTab(tabControlId, tabId))
104      {
105        if (tabId == 'annotations' && (protocolChanged || !annotationsLoaded))
106        {
107          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getProtocolId());
108          annotationsLoaded = true;
109          protocolChanged = false;
110        }
111        else if (tabId == 'inheritedAnnotations' && 
112          (parentsChanged || !inheritedAnnotationsLoaded))
113        {
114          Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents());
115          inheritedAnnotationsLoaded = true;
116          parentsChanged = false;
117        }
118      }
119    }
120    function getProtocolId()
121    {
122      // No protocol
123      return 0;
124    }
125    function getParents()
126    {
127      // Parents are always fixed and if we pass null they will be loaded by
128      // the annotate.jsp page
129      return null;
130    }   
131    function init()
132    {
133      var frm = document.forms['bioAssay'];
134      <%
135      if (bioAssay == null)
136      {
137        %>
138        frm.name.focus();
139        frm.name.select();
140        <%
141      }
142      %>
143    }
144    </script>
145  </base:head>
146  <base:body onload="init()">
147    <p>
148    <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssay" onsubmit="return false;">
149    <input type="hidden" name="cmd" value="UpdateItem">
150
151    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
152    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
153      position="bottom"  remember="<%=bioAssay != null%>" switch="switchTab">
154    <t:tab id="info" title="Bioassay" validate="validateBioAssay()" helpid="bioassay.edit">
155      <table class="form" cellspacing=0>
156      <tr>
157        <td class="prompt">Name</td>
158        <td><input <%=requiredClazz%> type="text" name="name" 
159          value="<%=HTML.encodeTags(bioAssay == null ? Values.getString(cc.getPropertyValue("name"), "New bioassay") : bioAssay.getName())%>" 
160          size="40" maxlength="<%=BioAssay.MAX_NAME_LENGTH%>"></td>
161      </tr>
162     
163
164      <tr valign=top>
165        <td class="prompt">Description</td>
166        <td nowrap>
167          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
168            ><%=HTML.encodeTags(bioAssay == null ? cc.getPropertyValue("description") : bioAssay.getDescription())%></textarea>
169          <a href="javascript:Main.zoom('Description', 'bioAssaySet', 'description')"
170            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
171        </td>
172      </tr>
173      </table>
174      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
175    </t:tab> 
176    <t:tab id="annotations" title="Annotations" 
177      helpid="annotations.edit" tooltip="Enter values for annotations">
178      <iframe name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
179        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
180        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
181    </t:tab>
182   
183    <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inerited">
184      <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
185        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
186        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
187    </t:tab>
188    </t:tabcontrol>
189
190    <table align="center">
191    <tr>
192      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
193      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
194    </tr>
195    </table>
196    </form>
197  </base:body>
198  </base:page>
199  <%
200}
201finally
202{
203  if (dc != null) dc.close();
204}
205%>
Note: See TracBrowser for help on using the repository browser.