source: trunk/www/lims/plates/wells/edit_well.jsp @ 6254

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

References #1729 and #1730. Use lazy loading of 'Annotations'/'Inherited annotations' for all other items.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.1 KB
Line 
1<%-- $Id: edit_well.jsp 6254 2013-03-22 07:28:26Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
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 3
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 BASE. If not, see <http://www.gnu.org/licenses/>.
20  ------------------------------------------------------------------
21  @author Nicklas
22  @version 2.0
23--%>
24<%@ page pageEncoding="UTF-8" session="false"
25  import="net.sf.basedb.core.SessionControl"
26  import="net.sf.basedb.core.DbControl"
27  import="net.sf.basedb.core.Item"
28  import="net.sf.basedb.core.ItemContext"
29  import="net.sf.basedb.core.Permission"
30  import="net.sf.basedb.core.Well"
31  import="net.sf.basedb.core.Plate"
32  import="net.sf.basedb.core.PermissionDeniedException"
33  import="net.sf.basedb.core.Reporter"
34  import="net.sf.basedb.core.data.ReporterData"
35  import="net.sf.basedb.core.BaseException"
36  import="net.sf.basedb.clients.web.Base"
37  import="net.sf.basedb.clients.web.util.HTML"
38  import="net.sf.basedb.util.Values"
39  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
40  import="net.sf.basedb.core.plugin.GuiContext"
41  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
42  import="net.sf.basedb.clients.web.extensions.JspContext"
43  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
44  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
45%>
46<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
47<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
48<%
49final Item itemType = Item.WELL;
50final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
51final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
52final int itemId = cc.getId();
53final int plateId = Values.getInt(request.getParameter("plate_id"));
54final String ID = sc.getId();
55final float scale = Base.getScale(sc);
56final DbControl dc = sc.newDbControl();
57try
58{
59  String title = null;
60  Well well = Well.getById(dc, itemId);
61  Plate plate = well.getPlate();
62  ReporterData reporter = well.getReporter();
63  if (reporter != null) reporter = Reporter.getById(dc, reporter.getId());
64  WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true);
65  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
66 
67  title = "Edit well -- " + HTML.encodeTags(plate.getName()) + " [" + rowFormatter.format(well.getRow()) + columnFormatter.format(well.getColumn()) + "]";
68 
69  if (well != null && !well.hasPermission(Permission.WRITE))
70  {
71    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
72  }
73  cc.setObject("item", well);
74  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), well);
75  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
76  %>
77  <base:page type="popup" title="<%=title%>">
78  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
79    <ext:scripts context="<%=jspContext%>" />
80    <ext:stylesheets context="<%=jspContext%>" />
81    <script>
82    // Validate the "Well" tab
83    function validateWell()
84    {
85      var frm = document.forms['well'];
86      return true;
87    }
88
89    // Submit the form
90    function saveSettings()
91    {
92      var frm = document.forms['well'];
93      if (TabControl.validateActiveTab('settings'))
94      {
95        Annotations.saveModifiedAnnotationsToForm(frm);
96        Annotations.saveInheritedAnnotationsToForm(frm);
97        frm.submit();
98      }
99    }
100   
101    function loadAnnotationsFrame()
102    {
103      Annotations.autoLoadEditFrame();
104    }
105   
106    function loadInheritedAnnotationsFrame()
107    {
108      Annotations.autoLoadInheritFrame();
109    }
110    </script>
111  </base:head>
112  <base:body>
113    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
114    <form action="index.jsp?ID=<%=ID%>" method="post" name="well">
115    <input type="hidden" name="cmd" value="UpdateItem">
116    <input type="hidden" name="plate_id" value="<%=plateId%>">
117
118    <t:tabcontrol id="settings" 
119      subclass="content dialogtabcontrol"
120      position="bottom" 
121      extensions="<%=invoker%>">
122    <t:tab id="info" title="Well" validate="validateWell()" helpid="well.edit">
123      <table class="fullform input100 outlined">
124      <tr>
125        <th>Plate</th>
126        <td><%=HTML.encodeTags(plate.getName())%></td>
127      </tr>
128      <tr>
129        <th>Coordinate</th>
130        <td><%=rowFormatter.format(well.getRow())%><%=columnFormatter.format(well.getColumn())%></td>
131      </tr>
132      <tr>
133        <th>Reporter name</th>
134        <td><%=reporter == null ? "<i>- none -</i>" : HTML.encodeTags(reporter.getName())%></td>
135      </tr>
136      <tr>
137        <th>Reporter External ID</th>
138        <td><%=reporter == null ? "<i>- none -</i>" : HTML.encodeTags(reporter.getExternalId())%></td>
139      </tr>
140      <tr class="dynamic">
141        <th></th>
142        <td></td>
143      </tr>
144      </table>
145    </t:tab>
146
147    <t:tab id="annotations" title="Annotations" helpid="annotations.edit" activate="loadAnnotationsFrame()">
148      <jsp:include page="../../../common/annotations/annotate_frameset.jsp">
149        <jsp:param name="item_type" value="<%=itemType.name()%>" />
150        <jsp:param name="item_id" value="<%=itemId%>" />
151        <jsp:param name="ID" value="<%=ID%>" />
152      </jsp:include>
153    </t:tab>
154   
155    <t:tab id="inheritedAnnotations" title="Inherited annotations" 
156      helpid="annotations.edit.inherited" activate="loadInheritedAnnotationsFrame()">
157      <jsp:include page="../../../common/annotations/inherit_frameset.jsp">
158        <jsp:param name="item_type" value="<%=itemType.name()%>" />
159        <jsp:param name="item_id" value="<%=itemId%>" />
160        <jsp:param name="ID" value="<%=ID%>" />
161      </jsp:include>
162    </t:tab>
163    </t:tabcontrol>
164    </form>
165
166    <base:buttongroup subclass="dialogbuttons">
167      <base:button onclick="saveSettings()" title="Save" />
168      <base:button onclick="window.close()" title="Cancel" />
169    </base:buttongroup>
170  </base:body>
171  </base:page>
172  <%
173}
174finally
175{
176  if (dc != null) dc.close();
177}
178%>
Note: See TracBrowser for help on using the repository browser.