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

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

References #1655: GUI improvements

  • File manager dialogs
  • File server edit dialog
  • Changed zoom.gif to png
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.1 KB
Line 
1<%-- $Id: edit_bioassayset.jsp 5908 2011-12-13 13:48:46Z 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    <p>
168    <form action="index.jsp?ID=<%=ID%>" method="post" name="bioAssaySet" onsubmit="return false;">
169    <input type="hidden" name="cmd" value="UpdateItem">
170
171    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
172    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
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="form" cellspacing=0>
177      <tr>
178        <td class="prompt">Name</td>
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          size="40" maxlength="<%=BioAssaySet.MAX_NAME_LENGTH%>"></td>
182      </tr>
183      <tr>
184        <td class="prompt">Spot intensity<br>transformation</td>
185        <td>
186          <select name="intensityTransform">
187          <%
188          IntensityTransform transform = bioAssaySet.getIntensityTransform();
189          for (IntensityTransform t : IntensityTransform.values())
190          {
191            String selected = transform == t ? "selected" : "";
192            %>
193            <option value="<%=t.name()%>" <%=selected%>><%=t.toString()%>
194            <%
195          }
196          %>
197          </select>
198        </td>
199      </tr>
200
201      <tr >
202        <td class="prompt">Description</td>
203        <td nowrap>
204          <textarea <%=clazz%> rows="4" cols="40" name="description" 
205            ><%=HTML.encodeTags(bioAssaySet == null ? cc.getPropertyValue("description") : bioAssaySet.getDescription())%></textarea>
206          <a href="javascript:Main.zoom('Description', 'bioAssaySet', 'description')"
207            title="Edit in larger window"><base:icon image="zoom.png" /></a>
208        </td>
209      </tr>
210      </table>
211      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
212    </t:tab>
213    <t:tab id="annotations" title="Annotations" 
214      helpid="annotations.edit" tooltip="Enter values for annotations">
215      <iframe name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
216        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
217        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
218    </t:tab>
219   
220    <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited">
221      <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
222        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
223        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
224    </t:tab>
225    </t:tabcontrol>
226
227    <table align="center">
228    <tr>
229      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
230      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
231    </tr>
232    </table>
233    </form>
234  </base:body>
235  </base:page>
236  <%
237}
238finally
239{
240  if (dc != null) dc.close();
241}
242%>
Note: See TracBrowser for help on using the repository browser.