source: trunk/www/lims/plates/merge_plates_2.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.9 KB
Line 
1<%-- $Id: merge_plates_2.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.Permission"
32  import="net.sf.basedb.core.Plate"
33  import="net.sf.basedb.core.PlateMapping"
34  import="net.sf.basedb.core.PlateType"
35  import="net.sf.basedb.core.PlateGeometry"
36  import="net.sf.basedb.core.BaseException"
37  import="net.sf.basedb.clients.web.Base"
38  import="net.sf.basedb.clients.web.WebException"
39  import="net.sf.basedb.clients.web.util.HTML"
40  import="net.sf.basedb.util.Values"
41%>
42<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
43<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
44<%
45final Item itemType = Item.PLATE;
46final SessionControl sc = Base.getExistingSessionControl(pageContext, Permission.CREATE, itemType);
47final String ID = sc.getId();
48final float scale = Base.getScale(sc);
49final DbControl dc = sc.newDbControl();
50try
51{
52  final int plateMappingId = Values.getInt(request.getParameter("platemapping_id"));
53  final int plateTypeId = Values.getInt(request.getParameter("platetype_id"));
54  final PlateMapping plateMapping = PlateMapping.getById(dc, plateMappingId);
55  final PlateType plateType = PlateType.getById(dc, plateTypeId);
56  PlateGeometry sourceGeometry = plateMapping.getSourceGeometry();
57 
58  if (!plateMapping.getDestinationGeometry().equals(plateType.getPlateGeometry()))
59  {
60    throw new WebException("popup", "Incomatible plate type and plate mapping", 
61      "The selected plate type has a different geometry than the mapping.");
62  }
63 
64  String title = "Merge plates -- step 2 of 2 -- Select plates";
65  final String clazz = "class=\"text\"";
66  final String requiredClazz = "class=\"text required\"";
67  %>
68
69  <base:page type="popup" title="<%=title%>">
70  <base:head scripts="linkitems.js">
71    <script language="JavaScript">
72    // Validate the entered information
73    function validate()
74    {
75      var frm = document.forms['merge'];
76      if (Main.trimString(frm.name.value) == '')
77      {
78        alert("You must enter a name");
79        frm.name.focus();
80        return false;
81      }
82      if (frm.plates.length != <%=plateMapping.getSourceCount()%>)
83      {
84        alert("You must select exactly <%=plateMapping.getSourceCount()%> plates");
85        return false;
86      }
87      return true;
88    }
89
90    // Submit the form
91    function mergePlates()
92    {
93      var frm = document.forms['merge'];
94      if (validate())
95      {
96        frm.mergePlates.value = Link.getActionIds(1, 'P').join(',');
97        frm.submit();
98      }
99    }
100   
101    function addPlatesOnClick()
102    {
103      var ids = Link.getListIds(document.forms['merge'].plates, 'P');
104      var excludes = ids.join(',');
105      var url = '../plates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addPlateCallback';
106      url += "&exclude="+excludes;
107      url += '&resetTemporary=1&tmpfilter:INT:plateType.plateGeometry=<%=sourceGeometry.getId()%>';
108      Main.openPopup(url, 'AddPlates', 1000, 700);
109    }
110
111    function addPlateCallback(plateId, name)
112    {
113      var item = Link.getItem('P', plateId);
114      if (!item) item = new Item('P', plateId, name);
115      Link.addItem(document.forms['merge'].plates, item);
116    }
117   
118    function removePlatesOnClick()
119    {
120      Link.removeSelected(document.forms['merge'].plates);
121    }
122    </script>
123  </base:head>
124  <base:body>
125    <h1><%=title%> <base:help helpid="plates.merge.2" /></h1>
126
127    <form action="index.jsp?ID=<%=ID%>" method="post" name="merge" onsubmit="return false;">
128    <input type="hidden" name="cmd" value="MergePlates">
129    <input type="hidden" name="platemapping_id" value="<%=plateMappingId%>">
130    <input type="hidden" name="platetype_id" value="<%=plateTypeId%>">
131
132    <div class="content bottomborder">
133      <table class="fullform input100 smaller">
134      <tr>
135        <th>Plate mapping</th>
136        <td>
137          <table><tr>
138            <td><%=HTML.encodeTags(plateMapping.getName())%></td>
139          <%
140          if (plateMapping.getImage() !=  null)
141          {
142            %>
143            <td><img src="../../images/platemappings/<%=plateMapping.getImage()%>"></td>
144            <%
145          }
146          %>
147          </tr></table>
148        </td>
149      </tr>
150      <tr>
151        <th>Name</th>
152        <td><input <%=requiredClazz%> type="text" name="name" value="<%=HTML.encodeTags(request.getParameter("name"))%>" 
153          maxlength="<%=Plate.MAX_NAME_LENGTH%>"></td>
154      </tr>
155      <tr>
156        <th>Plate type</th>
157        <td><%=HTML.encodeTags(plateType.getName())%></td>
158      </tr>
159      <tr class="big">
160        <th>Plates</th>
161        <td>
162        <table>
163        <tr>
164          <td style="padding: 5px;">
165            <base:buttongroup vertical="true">
166              <base:button
167                onclick="Forms.moveListOptions(document.forms['merge'].plates, false)" 
168                image="move_up.png" 
169                tooltip="Move up" 
170                subclass="square"
171              />
172              <base:button 
173                onclick="Forms.moveListOptions(document.forms['merge'].plates, true)" 
174                image="move_down.png" 
175                tooltip="Move down" 
176                subclass="square"
177              />
178            </base:buttongroup>
179          </td>
180          <td>
181            <select name="plates" size="<%=plateMapping.getSourceCount()%>" multiple 
182              style="width: 15em;" class="required">
183            </select>
184            <input type="hidden" name="mergePlates">
185          </td>
186          <td>
187            <base:buttongroup vertical="true">
188              <base:button 
189                subclass="leftaligned"
190                style="width: 14em;"
191                onclick="addPlatesOnClick()" 
192                title="Add&nbsp;plates&hellip;" 
193                tooltip="Add plates to be used"
194              />
195              <base:button 
196                subclass="leftaligned"
197                style="width: 14em;"
198                onclick="removePlatesOnClick()" 
199                title="Remove" 
200                tooltip="Remove the selected plates"
201              />
202            </base:buttongroup>
203          </td>
204          </tr>
205          </table>
206        </td>
207      </tr>
208      <tr class="dynamic">
209        <th></th>
210        <td></td>
211      </tr>
212      </table>
213    </div>
214    </form>
215   
216    <div class="legend">
217      <base:icon image="required.gif" /> = required information
218    </div>
219   
220    <base:buttongroup subclass="dialogbuttons">
221      <base:button onclick="mergePlates()" title="Merge" image="gonext.png"/>
222      <base:button onclick="window.close()" title="Cancel" />
223    </base:buttongroup>
224
225  </base:body>
226  </base:page>
227  <%
228}
229finally
230{
231  if (dc != null) dc.close();
232}
233%>
Note: See TracBrowser for help on using the repository browser.