source: trunk/www/lims/geometries/edit_geometry.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: 7.1 KB
Line 
1<%-- $Id: edit_geometry.jsp 5920 2012-01-10 09:41:59Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
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.SystemItems"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.Include"
35  import="net.sf.basedb.core.PlateGeometry"
36  import="net.sf.basedb.core.ItemQuery"
37  import="net.sf.basedb.core.ItemResultList"
38  import="net.sf.basedb.core.PermissionDeniedException"
39  import="net.sf.basedb.core.BaseException"
40  import="net.sf.basedb.core.query.Orders"
41  import="net.sf.basedb.core.query.Hql"
42  import="net.sf.basedb.clients.web.Base"
43  import="net.sf.basedb.clients.web.util.HTML"
44  import="net.sf.basedb.util.Values"
45  import="net.sf.basedb.core.plugin.GuiContext"
46  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
47  import="net.sf.basedb.clients.web.extensions.JspContext"
48  import="net.sf.basedb.clients.web.extensions.edit.EditUtil"
49  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
50  import="java.util.List"
51  import="java.util.Set"
52  import="java.util.HashSet"
53  import="java.util.Date"
54%>
55<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
56<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
57<%
58final Item itemType = Item.PLATEGEOMETRY;
59final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
60final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
61final int itemId = cc.getId();
62final String ID = sc.getId();
63final float scale = Base.getScale(sc);
64final DbControl dc = sc.newDbControl();
65try
66{
67  String title = null;
68  PlateGeometry geometry = null;
69 
70  if (itemId == 0)
71  {
72    title = "Create plate geometry";
73    cc.removeObject("item");
74  }
75  else
76  {
77    geometry = PlateGeometry.getById(dc, itemId);
78    cc.setObject("item", geometry);
79    title = "Edit plate geometry -- " + HTML.encodeTags(geometry.getName());
80  }
81  if (geometry != null && !geometry.hasPermission(Permission.WRITE))
82  {
83    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
84  }
85  final String clazz = "class=\"text\"";
86  final String requiredClazz = "class=\"text required\"";
87  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, GuiContext.item(itemType), geometry);
88  ExtensionsInvoker invoker = EditUtil.useEditExtensions(jspContext);
89  %>
90  <base:page type="popup" title="<%=title%>">
91  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
92    <ext:scripts context="<%=jspContext%>" />
93    <ext:stylesheets context="<%=jspContext%>" />
94    <script language="JavaScript">
95    // Validate the "PlateGeoemtry" tab
96    function validatePlateGeometry()
97    {
98      var frm = document.forms['geometry'];
99      if (Main.trimString(frm.name.value) == '')
100      {
101        alert("You must enter a name");
102        frm.name.focus();
103        return false;
104      }
105      else if (frm.rows && frm.rows.value == '')
106      {
107        alert("You must enter the number of rows");
108        frm.rows.focus();
109        return false;
110      }
111      else if (frm.columns && frm.columns.value == '')
112      {
113        alert("You must enter the number of columns");
114        frm.columns.focus();
115        return false;
116      }
117      return true;
118    }
119
120    // Submit the form
121    function saveSettings()
122    {
123      var frm = document.forms['geometry'];
124      if (TabControl.validateActiveTab('settings'))
125      {
126        frm.submit();
127      }
128    }
129   
130    function init()
131    {
132      var frm = document.forms['geometry'];
133      <%
134      if (geometry == null)
135      {
136        %>
137        frm.name.focus();
138        frm.name.select();
139        <%
140      }
141      %>
142    }
143    </script>
144  </base:head>
145  <base:body onload="init()">
146    <h1><%=title%> <base:help tabcontrol="settings" /></h1>
147
148    <form action="index.jsp?ID=<%=ID%>" method="post" name="geometry" onsubmit="return false;">
149    <input type="hidden" name="cmd" value="UpdateItem">
150
151    <t:tabcontrol id="settings"
152      subclass="content dialogtabcontrol" 
153      position="bottom"  remember="<%=geometry != null%>"
154      extensions="<%=invoker%>">
155    <t:tab id="info" title="Plate geometry" validate="validatePlateGeometry()" helpid="plategeometry.edit">
156      <table class="fullform input100 smaller">
157      <tr>
158        <th>Name</th>
159        <td><input <%=requiredClazz%> type="text" name="name" 
160          value="<%=HTML.encodeTags(geometry == null ? Values.getString(cc.getPropertyValue("name"), "New plate geometry") : geometry.getName())%>" 
161          maxlength="<%=PlateGeometry.MAX_NAME_LENGTH%>"></td>
162        <td></td>
163      </tr>
164      <tr>
165        <th>Rows</th>
166        <td>
167          <%
168          if (geometry != null)
169          {
170            %>
171            <%=geometry.getRows()%>
172            <%
173          }
174          else
175          {
176            %>
177            <input class="unchangeable" type="text" name="rows" style="width: 15em;"
178              value="<%=cc.getPropertyValue("rows") == null ? "" : Values.getInt(cc.getPropertyValue("rows"))%>" 
179              maxlength="10" onkeypress="return Numbers.integerOnly(event)">
180            <%
181          }
182          %>
183        </td>
184        <td></td>
185      </tr>
186      <tr>
187        <th>Columns</th>
188        <td>
189          <%
190          if (geometry != null)
191          {
192            %>
193            <%=geometry.getColumns()%>
194            <%
195          }
196          else
197          {
198            %>
199            <input class="unchangeable" type="text" name="columns" style="width: 15em;"
200              value="<%=cc.getPropertyValue("columns") == null ? "" : Values.getInt(cc.getPropertyValue("columns"))%>" 
201              maxlength="10" onkeypress="return Numbers.integerOnly(event)">
202            <%
203          }
204          %>
205        </td>
206        <td></td>
207      </tr>
208      <tr class="dynamic">
209        <th>Description</th>
210        <td>
211          <textarea <%=clazz%> rows="4" name="description" 
212            ><%=HTML.encodeTags(geometry == null ? cc.getPropertyValue("description") : geometry.getDescription())%></textarea>
213        </td>
214        <td style="width: 20px;">
215          <base:icon image="zoom.png" 
216            onclick="Main.zoom('Description', 'geometry', 'description')"
217            tooltip="Edit in larger window"
218          />
219        </td>
220      </tr>
221      </table>
222    </t:tab>
223    </t:tabcontrol>
224    </form>
225
226    <div class="legend">
227      <base:icon image="required.gif" /> = required information
228      <%if (geometry == null) {%><br>
229        <base:icon image="unchangeable.gif" /> = can't be changed later
230      <%}%>
231    </div>
232
233    <base:buttongroup subclass="dialogbuttons">
234      <base:button onclick="saveSettings()" title="Save" />
235      <base:button onclick="window.close()" title="Cancel" />
236    </base:buttongroup>
237  </base:body>
238  </base:page>
239  <%
240}
241finally
242{
243  if (dc != null) dc.close();
244}
245%>
Note: See TracBrowser for help on using the repository browser.