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

Last change on this file since 5498 was 5498, checked in by Nicklas Nordborg, 11 years ago

References #1545: Add extension points to edit pages

Fixed on array lims pages.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.1 KB
Line 
1<%-- $Id: edit_well.jsp 5498 2010-11-17 10:29:50Z 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.data.ReporterData"
34  import="net.sf.basedb.core.BaseException"
35  import="net.sf.basedb.clients.web.Base"
36  import="net.sf.basedb.clients.web.util.HTML"
37  import="net.sf.basedb.util.Values"
38  import="net.sf.basedb.util.formatter.WellCoordinateFormatter"
39  import="net.sf.basedb.core.plugin.GuiContext"
40  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
41  import="net.sf.basedb.clients.web.extensions.JspContext"
42  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
43  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
44%>
45<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
46<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
47<%
48final Item itemType = Item.WELL;
49final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
50final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
51final int itemId = cc.getId();
52final int plateId = Values.getInt(request.getParameter("plate_id"));
53final String ID = sc.getId();
54final float scale = Base.getScale(sc);
55final DbControl dc = sc.newDbControl();
56try
57{
58  String title = null;
59  Well well = Well.getById(dc, itemId);
60  Plate plate = well.getPlate();
61  ReporterData reporter = well.getReporter();
62  WellCoordinateFormatter rowFormatter = new WellCoordinateFormatter(true);
63  WellCoordinateFormatter columnFormatter = new WellCoordinateFormatter(false);
64 
65  title = "Edit well -- [" + rowFormatter.format(well.getRow()) + ", " + columnFormatter.format(well.getColumn()) + "] on plate " + HTML.encodeTags(plate.getName());
66
67  final String clazz = "class=\"text\"";
68  final String requiredClazz = "class=\"text required\"";
69 
70  if (well != null && !well.hasPermission(Permission.WRITE))
71  {
72    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
73  }
74  cc.setObject("item", well);
75  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), well);
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 "Well" tab
84    function validateWell()
85    {
86      var frm = document.forms['well'];
87      return true;
88    }
89
90    // Submit the form
91    function saveSettings()
92    {
93      var frm = document.forms['well'];
94      if (TabControl.validateActiveTab('settings'))
95      {
96        if (annotationsLoaded)
97        {
98          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
99        }
100        if (inheritedAnnotationsLoaded)
101        {
102          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
103        }
104        frm.submit();
105      }
106    }
107   
108    var annotationsLoaded = false;
109    var inheritedAnnotationsLoaded = false;
110    var parentsChanged = false;
111    function switchTab(tabControlId, tabId)
112    {
113      if (TabControl.setActiveTab(tabControlId, tabId))
114      {
115        if (tabId == 'annotations' && !annotationsLoaded)
116        {
117          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=well == null ? 0 : well.getId()%>);
118          annotationsLoaded = true;
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    function getParents()
130    {
131      return new Array();
132    }
133    </script>
134  </base:head>
135  <base:body>
136    <p>
137    <form action="index.jsp?ID=<%=ID%>" method="post" name="well" onsubmit="return false;">
138    <input type="hidden" name="cmd" value="UpdateItem">
139    <input type="hidden" name="plate_id" value="<%=plateId%>">
140
141    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
142    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
143      position="bottom" switch="switchTab"
144      extensions="<%=invoker%>">
145    <t:tab id="info" title="Well" validate="validateWell()" helpid="well.edit">
146      <table class="form" cellspacing=0>
147      <tr>
148        <td class="prompt">Plate</td>
149        <td><%=HTML.encodeTags(plate.getName())%></td>
150      </tr>
151      <tr>
152        <td class="prompt">Coordinate</td>
153        <td>[<%=rowFormatter.format(well.getRow())%>, <%=columnFormatter.format(well.getColumn())%>]</td>
154      </tr>
155      <tr>
156        <td class="prompt">Reporter name</td>
157        <td><%=reporter == null ? "<i>- none -</i>" : HTML.encodeTags(reporter.getName())%></td>
158      </tr>
159      <tr>
160        <td class="prompt">Reporter External ID</td>
161        <td><%=reporter == null ? "<i>- none -</i>" : HTML.encodeTags(reporter.getExternalId())%></td>
162      </tr>
163      </table>
164      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
165    </t:tab>
166
167    <t:tab id="annotations" title="Annotations" helpid="annotations.edit">
168      <iframe name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
169        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
170        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
171    </t:tab>
172   
173    <t:tab id="inheritedAnnotations" title="Inherited annotations" helpid="annotations.edit.inherited">
174   
175      <iframe name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
176        width="100%"  height="<%=(int)(scale*370)%>" frameborder=0 vspace=0 hspace=0
177        marginwidth=0 marginheight=0 scrolling="auto" style="overflow: visible"></iframe>
178    </t:tab>
179    </t:tabcontrol>
180
181    <table align="center">
182    <tr>
183      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
184      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
185    </tr>
186    </table>
187    </form>
188  </base:body>
189  </base:page>
190  <%
191}
192finally
193{
194  if (dc != null) dc.close();
195}
196%>
Note: See TracBrowser for help on using the repository browser.