source: trunk/www/views/experiments/bioassaysets/edit_bioassayset.jsp @ 3400

Last change on this file since 3400 was 3400, checked in by Nicklas Nordborg, 14 years ago

Fixes #534.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.1 KB
Line 
1<%-- $Id: edit_bioassayset.jsp 3400 2007-05-29 06:47:04Z 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.ItemQuery"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.Include"
39  import="net.sf.basedb.core.query.Orders"
40  import="net.sf.basedb.core.query.Hql"
41  import="net.sf.basedb.core.PermissionDeniedException"
42  import="net.sf.basedb.core.BaseException"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.util.HTML"
45  import="net.sf.basedb.util.Values"
46  import="java.util.Date"
47%>
48<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
49<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
50<%
51final Item itemType = Item.BIOASSAYSET;
52final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
53final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
54final int itemId = cc.getId();
55final String ID = sc.getId();
56final float scale = Base.getScale(sc);
57final DbControl dc = sc.newDbControl();
58try
59{
60  BioAssaySet bioAssaySet = BioAssaySet.getById(dc, itemId);
61
62  cc.setObject("item", bioAssaySet);
63  String title = "Edit bioassay set -- " + HTML.encodeTags(bioAssaySet.getName());
64  if (bioAssaySet != null)
65  {
66    bioAssaySet.checkPermission(Permission.WRITE);
67  }
68  final String clazz = "class=\"text\"";
69  final String requiredClazz = "class=\"text required\"";
70  %>
71
72  <base:page type="popup" title="<%=title%>">
73  <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css">
74    <script language="JavaScript">
75    // Validate the "BioAssaySet" tab
76    function validateBioAssaySet()
77    {
78      var frm = document.forms['bioAssaySet'];
79      if (Main.trimString(frm.name.value) == '')
80      {
81        alert("You must enter a name");
82        frm.name.focus();
83        return false;
84      }
85      return true;
86    }
87
88    // Submit the form
89    function saveSettings()
90    {
91      var frm = document.forms['bioAssaySet'];
92      if (TabControl.validateActiveTab('settings'))
93      {
94        if (annotationsLoaded)
95        {
96          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
97        }
98        if (inheritedAnnotationsLoaded)
99        {
100          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
101        }
102        frm.submit();
103      }
104    }
105   
106    var annotationsLoaded = false;
107    var inheritedAnnotationsLoaded = false;
108    var parentsChanged = false;
109    var protocolChanged = false;
110    function switchTab(tabControlId, tabId)
111    {
112      if (TabControl.setActiveTab(tabControlId, tabId))
113      {
114        if (tabId == 'annotations' && (protocolChanged || !annotationsLoaded))
115        {
116          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getProtocolId());
117          annotationsLoaded = true;
118          protocolChanged = false;
119        }
120        else if (tabId == 'inheritedAnnotations' && 
121          (parentsChanged || !inheritedAnnotationsLoaded))
122        {
123          Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents());
124          inheritedAnnotationsLoaded = true;
125          parentsChanged = false;
126        }
127      }
128    }
129   
130    function getProtocolId()
131    {
132      // No protocol
133      return 0;
134    }
135   
136    function getParents()
137    {
138      // Parents are always fixed and if we pass null they will be loaded by
139      // the annotate.jsp page
140      return null;
141    }
142   
143    function init()
144    {
145      var frm = document.forms['bioAssaySet'];
146      <%
147      if (bioAssaySet == null)
148      {
149        %>
150        frm.name.focus();
151        frm.name.select();
152        <%
153      }
154      %>
155    }
156    </script>
157  </base:head>
158  <base:body onload="init()">
159    <p>
160    <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssaySet" 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*370)+"px;"%>" 
165      position="bottom"  remember="<%=bioAssaySet != null%>" switch="switchTab">
166    <t:tab id="info" title="Bioassay set" validate="validateBioAssaySet()" helpid="bioassayset.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(bioAssaySet == null ? Values.getString(cc.getPropertyValue("name"), "New bioassay set") : bioAssaySet.getName())%>" 
172          size="40" maxlength="<%=BioAssaySet.MAX_NAME_LENGTH%>"></td>
173      </tr>
174     
175
176      <tr valign=top>
177        <td class="prompt">Description</td>
178        <td nowrap>
179          <textarea <%=clazz%> rows="4" cols="40" name="description" wrap="virtual"
180            ><%=HTML.encodeTags(bioAssaySet == null ? cc.getPropertyValue("description") : bioAssaySet.getDescription())%></textarea>
181          <a href="javascript:Main.zoom('Description', 'bioAssaySet', 'description')"
182            title="Edit in larger window"><base:icon image="zoom.gif" /></a>
183        </td>
184      </tr>
185      </table>
186      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
187    </t:tab>
188    <t:tab id="annotations" title="Annotations" 
189      helpid="annotations.edit" tooltip="Enter values for annotations">
190      <iframe name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
191        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
192        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
193    </t:tab>
194   
195    <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited">
196      <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
197        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
198        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
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}
213finally
214{
215  if (dc != null) dc.close();
216}
217%>
Note: See TracBrowser for help on using the repository browser.