source: trunk/www/lims/plates/merge_plates_2.jsp @ 5906

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

References #1655: GUI improvements

  • Implement vertical button groups.
  • Replaced some gif icons with png variants.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.7 KB
Line 
1<%-- $Id: merge_plates_2.jsp 5906 2011-12-12 11:59:03Z 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    <p>
126    <form action="index.jsp?ID=<%=ID%>" method="post" name="merge" onsubmit="return false;">
127    <input type="hidden" name="cmd" value="MergePlates">
128    <input type="hidden" name="platemapping_id" value="<%=plateMappingId%>">
129    <input type="hidden" name="platetype_id" value="<%=plateTypeId%>">
130
131    <h3 class="docked"><%=title%> <base:help helpid="plates.merge.2" /></h3>
132    <div class="boxed" style="<%="height: "+(int)(scale*280)+"px;"%>">
133      <table class="form" cellspacing=0>
134      <tr >
135        <td class="prompt">Plate mapping</td>
136        <td><%=HTML.encodeTags(plateMapping.getName())%>
137          <%
138          if (plateMapping.getImage() !=  null)
139          {
140            %>
141            <br>
142            <img src="../../images/platemappings/<%=plateMapping.getImage()%>">
143            <%
144          }
145          %>
146        </td>
147      </tr>
148      <tr>
149        <td class="prompt">Name</td>
150        <td><input <%=requiredClazz%> type="text" name="name" value="<%=HTML.encodeTags(request.getParameter("name"))%>" 
151          size="40" maxlength="<%=Plate.MAX_NAME_LENGTH%>"></td>
152      </tr>
153      <tr>
154        <td class="prompt">Plate type</td>
155        <td><%=HTML.encodeTags(plateType.getName())%></td>
156      </tr>
157      <tr >
158        <td class="prompt">Plates</td>
159        <td>
160
161          <table>
162          <tr >
163          <td>
164            <base:button
165              onclick="Forms.moveListOptions(document.forms['merge'].plates, false)" 
166              title="<img src='../../images/move_up.png' alt='' style='vertical-align: middle;'>" 
167              tooltip="Move up" 
168            /><p>
169            <base:button 
170              onclick="Forms.moveListOptions(document.forms['merge'].plates, true)" 
171              title="<img src='../../images/move_down.png' alt='' style='vertical-align: middle;'>" 
172              tooltip="Move down" 
173            />
174          </td>
175          <td>
176            <select name="plates" size="<%=plateMapping.getSourceCount()%>" multiple 
177              style="width: 15em;">
178            </select>
179            <input type="hidden" name="mergePlates">
180          </td>
181          <td>
182            <table width="150">
183            <tr><td><base:button 
184              onclick="addPlatesOnClick()" 
185              title="Add plates..." 
186              tooltip="Add plates to be used"
187              /></td></tr>
188            <tr><td><base:button 
189              onclick="removePlatesOnClick()" 
190              title="Remove" 
191              tooltip="Remove the selected plates"
192              /></td></tr>
193            </table>
194          </td>
195          </tr>
196          </table>
197        </td>
198      </tr>
199      </table>
200    </div>
201
202    <table align="center">
203    <tr>
204      <td width="50%"><base:button onclick="mergePlates()" title="Merge" /></td>
205      <td width="50%"><base:button onclick="window.close()" title="Cancel" /></td>
206    </tr>
207    </table>
208
209    </form>
210  </base:body>
211  </base:page>
212  <%
213}
214finally
215{
216  if (dc != null) dc.close();
217}
218%>
Note: See TracBrowser for help on using the repository browser.