source: trunk/www/lims/geometries/edit_geometry.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: 7.1 KB
Line 
1<%-- $Id: edit_geometry.jsp 5908 2011-12-13 13:48:46Z 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    <p>
147    <form action="index.jsp?ID=<%=ID%>" method="post" name="geometry" onsubmit="return false;">
148    <input type="hidden" name="cmd" value="UpdateItem">
149
150    <h3 class="docked"><%=title%> <base:help tabcontrol="settings" /></h3>
151    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*200)+"px;"%>" 
152      position="bottom"  remember="<%=geometry != null%>"
153      extensions="<%=invoker%>">
154    <t:tab id="info" title="Plate geometry" validate="validatePlateGeometry()" helpid="plategeometry.edit">
155      <table class="form" cellspacing=0>
156      <tr>
157        <td class="prompt">Name</td>
158        <td><input <%=requiredClazz%> type="text" name="name" 
159          value="<%=HTML.encodeTags(geometry == null ? Values.getString(cc.getPropertyValue("name"), "New plate geometry") : geometry.getName())%>" 
160          size="40" maxlength="<%=PlateGeometry.MAX_NAME_LENGTH%>"></td>
161      </tr>
162      <tr>
163        <td class="prompt">Rows</td>
164        <td>
165          <%
166          if (geometry != null)
167          {
168            %>
169            <%=geometry.getRows()%>
170            <%
171          }
172          else
173          {
174            %>
175            <input <%=requiredClazz%> type="text" name="rows" 
176              value="<%=cc.getPropertyValue("rows") == null ? "" : Values.getInt(cc.getPropertyValue("rows"))%>" 
177              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
178              can't be changed later
179            <%
180          }
181          %>
182        </td>
183      </tr>
184      <tr>
185        <td class="prompt">Columns</td>
186        <td>
187          <%
188          if (geometry != null)
189          {
190            %>
191            <%=geometry.getColumns()%>
192            <%
193          }
194          else
195          {
196            %>
197            <input <%=requiredClazz%> type="text" name="columns" 
198              value="<%=cc.getPropertyValue("columns") == null ? "" : Values.getInt(cc.getPropertyValue("columns"))%>" 
199              size="12" maxlength="10" onkeypress="return Numbers.integerOnly(event)">
200              can't be changed later
201            <%
202          }
203          %>
204        </td>
205      </tr>
206      <tr >
207        <td class="prompt">Description</td>
208        <td nowrap>
209          <textarea <%=clazz%> rows="4" cols="40" name="description" 
210            ><%=HTML.encodeTags(geometry == null ? cc.getPropertyValue("description") : geometry.getDescription())%></textarea>
211          <a href="javascript:Main.zoom('Description', 'geometry', 'description')"
212            title="Edit in larger window"><base:icon image="zoom.png" /></a>
213        </td>
214      </tr>
215      </table>
216      <div align=right>&nbsp;<i><base:icon image="required.gif" /> = required information</i></div>
217    </t:tab>
218    </t:tabcontrol>
219
220    <table align="center">
221    <tr>
222      <td width="50%"><base:button onclick="saveSettings()" title="Save" /></td>
223      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
224    </tr>
225    </table>
226    </form>
227  </base:body>
228  </base:page>
229  <%
230}
231finally
232{
233  if (dc != null) dc.close();
234}
235%>
Note: See TracBrowser for help on using the repository browser.