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

Last change on this file since 5923 was 5923, checked in by Nicklas Nordborg, 10 years ago

References #1655: GUI improvements

  • Edit dialogs for bioassay set, bioassay, transformation and some other experiment related dialogs
  • Analysis plug-in that have special jsp forms
  • Change history
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.8 KB
Line 
1<%-- $Id: edit_bioassayset.jsp 5923 2012-01-11 14:29:26Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
4  Copyright (C) 2007 Nicklas Nordborg
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 3
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 BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page pageEncoding="UTF-8" session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.Experiment"
34  import="net.sf.basedb.core.BioAssaySet"
35  import="net.sf.basedb.core.ItemQuery"
36  import="net.sf.basedb.core.ItemResultList"
37  import="net.sf.basedb.core.Include"
38  import="net.sf.basedb.core.query.Orders"
39  import="net.sf.basedb.core.query.Hql"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.BaseException"
42  import="net.sf.basedb.core.IntensityTransform"
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="net.sf.basedb.core.plugin.GuiContext"
47  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
48  import="net.sf.basedb.clients.web.extensions.JspContext"
49  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
50  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
51  import="java.util.Date"
52%>
53<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
54<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
55<%
56final Item itemType = Item.BIOASSAYSET;
57final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
58final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
59final int itemId = cc.getId();
60final String ID = sc.getId();
61final float scale = Base.getScale(sc);
62final DbControl dc = sc.newDbControl();
63try
64{
65  BioAssaySet bioAssaySet = BioAssaySet.getById(dc, itemId);
66
67  cc.setObject("item", bioAssaySet);
68  String title = "Edit bioassay set -- " + HTML.encodeTags(bioAssaySet.getName());
69  if (bioAssaySet != null)
70  {
71    bioAssaySet.checkPermission(Permission.WRITE);
72  }
73  final String clazz = "class=\"text\"";
74  final String requiredClazz = "class=\"text required\"";
75  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), bioAssaySet);
76  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
77  %>
78  <base:page type="popup" title="<%=title%>">
79  <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css">
80    <ext:scripts context="<%=jspContext%>" />
81    <ext:stylesheets context="<%=jspContext%>" />
82    <script language="JavaScript">
83    // Validate the "BioAssaySet" tab
84    function validateBioAssaySet()
85    {
86      var frm = document.forms['bioAssaySet'];
87      if (Main.trimString(frm.name.value) == '')
88      {
89        alert("You must enter a name");
90        frm.name.focus();
91        return false;
92      }
93      return true;
94    }
95
96    // Submit the form
97    function saveSettings()
98    {
99      var frm = document.forms['bioAssaySet'];
100      if (TabControl.validateActiveTab('settings'))
101      {
102        if (annotationsLoaded)
103        {
104          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
105        }
106        if (inheritedAnnotationsLoaded)
107        {
108          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
109        }
110        frm.submit();
111      }
112    }
113   
114    var annotationsLoaded = false;
115    var inheritedAnnotationsLoaded = false;
116    var parentsChanged = false;
117    var protocolChanged = false;
118    function switchTab(tabControlId, tabId)
119    {
120      if (TabControl.setActiveTab(tabControlId, tabId))
121      {
122        if (tabId == 'annotations' && (protocolChanged || !annotationsLoaded))
123        {
124          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getProtocolId());
125          annotationsLoaded = true;
126          protocolChanged = false;
127        }
128        else if (tabId == 'inheritedAnnotations' && 
129          (parentsChanged || !inheritedAnnotationsLoaded))
130        {
131          Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents());
132          inheritedAnnotationsLoaded = true;
133          parentsChanged = false;
134        }
135      }
136    }
137   
138    function getProtocolId()
139    {
140      // No protocol
141      return 0;
142    }
143   
144    function getParents()
145    {
146      // Parents are always fixed and if we pass null they will be loaded by
147      // the annotate.jsp page
148      return null;
149    }
150   
151    function init()
152    {
153      var frm = document.forms['bioAssaySet'];
154      <%
155      if (bioAssaySet == null)
156      {
157        %>
158        frm.name.focus();
159        frm.name.select();
160        <%
161      }
162      %>
163    }
164    </script>
165  </base:head>
166  <base:body onload="init()">
167    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
168    <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssaySet" onsubmit="return false;">
169    <input type="hidden" name="cmd" value="UpdateItem">
170
171    <t:tabcontrol id="settings" 
172      subclass="content dialogtabcontrol"
173      position="bottom"  remember="<%=bioAssaySet != null%>" switch="switchTab"
174      extensions="<%=invoker%>">
175    <t:tab id="info" title="Bioassay set" validate="validateBioAssaySet()" helpid="bioassayset.edit">
176      <table class="fullform input100">
177      <tr>
178        <th>Name</th>
179        <td><input <%=requiredClazz%> type="text" name="name" 
180          value="<%=HTML.encodeTags(bioAssaySet == null ? Values.getString(cc.getPropertyValue("name"), "New bioassay set") : bioAssaySet.getName())%>" 
181          maxlength="<%=BioAssaySet.MAX_NAME_LENGTH%>"></td>
182        <td></td>
183      </tr>
184      <tr>
185        <th>Spot intensity<br>transformation</th>
186        <td>
187          <select name="intensityTransform">
188          <%
189          IntensityTransform transform = bioAssaySet.getIntensityTransform();
190          for (IntensityTransform t : IntensityTransform.values())
191          {
192            String selected = transform == t ? "selected" : "";
193            %>
194            <option value="<%=t.name()%>" <%=selected%>><%=t.toString()%>
195            <%
196          }
197          %>
198          </select>
199        </td>
200        <td></td>
201      </tr>
202      <tr class="dynamic">
203        <th>Description</th>
204        <td>
205          <textarea <%=clazz%> rows="6" name="description" 
206            ><%=HTML.encodeTags(bioAssaySet == null ? cc.getPropertyValue("description") : bioAssaySet.getDescription())%></textarea>
207        </td>
208        <td style="width: 20px;">
209          <base:icon image="zoom.png" 
210            onclick="Main.zoom('Description', 'bioAssaySet', 'description')"
211            tooltip="Edit in larger window"
212          />
213        </td>
214      </tr>
215      </table>
216    </t:tab>
217    <t:tab id="annotations" title="Annotations &amp; parameters" helpid="annotations.edit"><iframe 
218      name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
219      style="width: 100%; height: 100%;"></iframe></t:tab>
220   
221    <t:tab id="inheritedAnnotations" title="Inherited annotations" 
222      helpid="annotations.edit.inherited"><iframe 
223        name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
224        style="width: 100%; height: 100%;"></iframe></t:tab>
225    </t:tabcontrol>
226    </form>
227   
228    <div class="legend">
229      <base:icon image="required.gif" /> = required information
230    </div>
231
232    <base:buttongroup subclass="dialogbuttons">
233      <base:button onclick="saveSettings()" title="Save" />
234      <base:button onclick="window.close()" title="Cancel" />
235    </base:buttongroup>
236  </base:body>
237  </base:page>
238  <%
239}
240finally
241{
242  if (dc != null) dc.close();
243}
244%>
Note: See TracBrowser for help on using the repository browser.