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

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

References #1655: GUI improvements

Edit dialogs in plates section of Array LIMS.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.8 KB
Line 
1<%-- $Id: edit_well.jsp 5920 2012-01-10 09:41:59Z 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  final String clazz = "class=\"text\"";
70  final String requiredClazz = "class=\"text required\"";
71 
72  if (well != null && !well.hasPermission(Permission.WRITE))
73  {
74    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
75  }
76  cc.setObject("item", well);
77  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), well);
78  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
79  %>
80  <base:page type="popup" title="<%=title%>">
81  <base:head scripts="tabcontrol.js,annotations.js" styles="tabcontrol.css">
82    <ext:scripts context="<%=jspContext%>" />
83    <ext:stylesheets context="<%=jspContext%>" />
84    <script language="JavaScript">
85    // Validate the "Well" tab
86    function validateWell()
87    {
88      var frm = document.forms['well'];
89      return true;
90    }
91
92    // Submit the form
93    function saveSettings()
94    {
95      var frm = document.forms['well'];
96      if (TabControl.validateActiveTab('settings'))
97      {
98        if (annotationsLoaded)
99        {
100          Annotations.addModifiedAnnotationsToForm(frames.annotations, frm);
101        }
102        if (inheritedAnnotationsLoaded)
103        {
104          Annotations.addInheritedAnnotationsToForm(frames.inheritedAnnotations, frm);
105        }
106        frm.submit();
107      }
108    }
109   
110    var annotationsLoaded = false;
111    var inheritedAnnotationsLoaded = false;
112    var parentsChanged = false;
113    function switchTab(tabControlId, tabId)
114    {
115      if (TabControl.setActiveTab(tabControlId, tabId))
116      {
117        if (tabId == 'annotations' && !annotationsLoaded)
118        {
119          Annotations.loadAnnotateFrame(frames.annotations, '<%=ID%>', '<%=itemType.name()%>', <%=well == null ? 0 : well.getId()%>);
120          annotationsLoaded = true;
121        }
122        else if (tabId == 'inheritedAnnotations' && 
123          (parentsChanged || !inheritedAnnotationsLoaded))
124        {
125          Annotations.loadInheritFrame(frames.inheritedAnnotations, '<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, getParents());
126          inheritedAnnotationsLoaded = true;
127          parentsChanged = false;
128        }
129      }
130    }
131    function getParents()
132    {
133      return new Array();
134    }
135    </script>
136  </base:head>
137  <base:body>
138    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
139    <form action="index.jsp?ID=<%=ID%>" method="post" name="well" onsubmit="return false;">
140    <input type="hidden" name="cmd" value="UpdateItem">
141    <input type="hidden" name="plate_id" value="<%=plateId%>">
142
143    <t:tabcontrol id="settings" 
144      subclass="content dialogtabcontrol"
145      position="bottom" switch="switchTab"
146      extensions="<%=invoker%>">
147    <t:tab id="info" title="Well" validate="validateWell()" helpid="well.edit">
148      <table class="fullform input100 outlined">
149      <tr>
150        <th>Plate</th>
151        <td><%=HTML.encodeTags(plate.getName())%></td>
152      </tr>
153      <tr>
154        <th>Coordinate</th>
155        <td><%=rowFormatter.format(well.getRow())%><%=columnFormatter.format(well.getColumn())%></td>
156      </tr>
157      <tr>
158        <th>Reporter name</th>
159        <td><%=reporter == null ? "<i>- none -</i>" : HTML.encodeTags(reporter.getName())%></td>
160      </tr>
161      <tr>
162        <th>Reporter External ID</th>
163        <td><%=reporter == null ? "<i>- none -</i>" : HTML.encodeTags(reporter.getExternalId())%></td>
164      </tr>
165      <tr class="dynamic">
166        <th></th>
167        <td></td>
168      </tr>
169      </table>
170    </t:tab>
171
172    <t:tab id="annotations" title="Annotations" helpid="annotations.edit"><iframe 
173      name="annotations" id="idAnnotations" src="../../../common/annotations/wait.jsp" 
174      style="width: 100%; height: 100%;"></iframe></t:tab>   
175   
176    <t:tab id="inheritedAnnotations" title="Inherited annotations" 
177      helpid="annotations.edit.inherited"><iframe 
178        name="inheritedAnnotations" id="idInheritedAnnotations" src="../../../common/annotations/wait.jsp" 
179        style="width: 100%; height: 100%;"></iframe></t:tab>
180    </t:tabcontrol>
181    </form>
182
183    <base:buttongroup subclass="dialogbuttons">
184      <base:button onclick="saveSettings()" title="Save" />
185      <base:button onclick="window.close()" title="Cancel" />
186    </base:buttongroup>
187  </base:body>
188  </base:page>
189  <%
190}
191finally
192{
193  if (dc != null) dc.close();
194}
195%>
Note: See TracBrowser for help on using the repository browser.