source: trunk/www/lims/arraydesigns/manage_plates.jsp @ 5917

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

References #1655: GUI improvements

Edit dialogs for array lims.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.3 KB
Line 
1<%-- $Id: manage_plates.jsp 5917 2011-12-19 11:28:45Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg
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
22
23  @author Nicklas
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.SystemItems"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.Include"
34  import="net.sf.basedb.core.ArrayDesign"
35  import="net.sf.basedb.core.ArrayDesignPlate"
36  import="net.sf.basedb.core.Plate"
37  import="net.sf.basedb.core.ItemQuery"
38  import="net.sf.basedb.core.ItemResultList"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.BaseException"
41  import="net.sf.basedb.core.query.Orders"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.util.HTML"
45  import="net.sf.basedb.util.Values"
46  import="java.util.List"
47  import="java.util.Set"
48  import="java.util.HashSet"
49  import="java.util.Date"
50%>
51<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
52<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
53<%
54final Item itemType = Item.ARRAYDESIGN;
55final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
56final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
57final int itemId = cc.getId();
58final String ID = sc.getId();
59final float scale = Base.getScale(sc);
60final DbControl dc = sc.newDbControl();
61try
62{
63  ArrayDesign design = ArrayDesign.getById(dc, itemId);
64  cc.setObject("item", design);
65  String title = "Attach plate -- " + HTML.encodeTags(design.getName());
66  if (!design.hasPermission(Permission.WRITE))
67  {
68    throw new PermissionDeniedException(Permission.WRITE, itemType.toString());
69  }
70  final String clazz = "class=\"text\"";
71  final String requiredClazz = "class=\"text required\"";
72  %>
73
74  <base:page type="popup" title="<%=title%>">
75  <base:head scripts="tabcontrol.js,linkitems.js" styles="tabcontrol.css">
76    <script language="JavaScript">
77    // Validate the "Plates" tab
78    function validatePlates()
79    {
80      return true;
81    }
82
83    // Submit the form
84    function saveSettings()
85    {
86      var frm = document.forms['design'];
87      if (TabControl.validateActiveTab('settings'))
88      {
89        var plates = frm.plates;
90        for (var i = 0; i < plates.length; ++i) // >
91        {
92          plates[i].selected = true;
93        }
94        frm.submit();
95      }
96    }
97   
98    function addPlatesOnClick()
99    {
100      var ids = Link.getListIds(document.forms['design'].plates, '');
101      var excludes = ids.join(',');
102      var url = '../plates/index.jsp?ID=<%=ID%>&cmd=UpdateContext&mode=selectmultiple&callback=addPlateCallback';
103      url += '&excludes='+excludes;
104      Main.openPopup(url, 'AddPlates', 1000, 700);
105    }
106
107    function addPlateCallback(plateId, name)
108    {
109      var item = Link.getItem('', plateId);
110      if (!item) item = new Item('', plateId, name);
111      Link.addItem(document.forms['design'].plates, item);
112    }
113   
114    function removePlatesOnClick()
115    {
116      Link.removeSelected(document.forms['design'].plates);
117    }
118
119    function init()
120    {
121      var frm = document.forms['design'];
122      var plates = frm.plates;
123      <%
124      ItemQuery<ArrayDesignPlate> platesQuery = design.getArrayDesignPlates();
125      platesQuery.include(Include.MINE, Include.SHARED, Include.OTHERS, Include.IN_PROJECT);
126      platesQuery.order(Orders.asc(Hql.property("position")));
127      ItemResultList<ArrayDesignPlate> plates = platesQuery.list(dc);
128      for (ArrayDesignPlate adPlate : plates)
129      {
130        Plate plate = adPlate.getPlate();
131        %>
132        Link.addNewItem(plates, new Item('', <%=plate.getId()%>, '<%=HTML.javaScriptEncode(plate.getName())%>'));
133        <%
134      }
135      %>
136    }
137    </script>
138  </base:head>
139  <base:body onload="init()">
140    <h1><%=title%> <base:help helpid="arraydesign.edit.plates" /></h1>
141    <form action="index.jsp?ID=<%=ID%>" method="post" name="design" onsubmit="return false;">
142    <input type="hidden" name="cmd" value="UpdatePlates">
143
144    <div class="content bottomborder">
145      <table class="fullform">
146      <tr>
147        <th>Array design</th>
148        <td><%=HTML.encodeTags(design.getName())%></td>
149      </tr>
150      <tr class="dynamic">
151        <th>Plates</th>
152        <td>
153          <div class="selectionlist">
154          <table>
155          <tr style="vertical-align: top;">
156          <td>
157            <base:buttongroup vertical="true">
158              <base:button
159                onclick="Forms.moveListOptions(document.forms['design'].plates, false)"
160                image="move_up.png" 
161                tooltip="Move up" 
162                subclass="square"
163              />
164              <base:button 
165                onclick="Forms.moveListOptions(document.forms['design'].plates, true)" 
166                image="move_down.png" 
167                tooltip="Move down" 
168                subclass="square"
169              />
170            </base:buttongroup>
171          </td>
172          <td>
173            <select name="plates" size="15" multiple>
174            </select>
175          </td>
176          <td>
177            <base:buttongroup vertical="true">
178              <base:button 
179                subclass="leftaligned"
180                style="width: 12em;"
181                onclick="addPlatesOnClick()" 
182                title="Add plates..." 
183                tooltip="Add plates to be used"
184              />
185              <base:button 
186                subclass="leftaligned"
187                style="width: 12em;"
188                onclick="removePlatesOnClick()" 
189                title="Remove" 
190                tooltip="Remove the selected plates"
191              />
192            </base:buttongroup>
193          </td>
194          </tr>
195          </table>
196          </div>
197        </td>
198      </tr>
199      </table>
200    </div>
201    </form>
202
203    <base:buttongroup subclass="dialogbuttons">
204      <base:button onclick="saveSettings()" title="Save" />
205      <base:button onclick="window.close()" title="Cancel" />
206    </base:buttongroup>
207  </base:body>
208  </base:page>
209  <%
210}
211finally
212{
213  if (dc != null) dc.close();
214}
215%>
Note: See TracBrowser for help on using the repository browser.