source: trunk/www/views/experiments/overview/options.jsp @ 3045

Last change on this file since 3045 was 3045, checked in by Nicklas Nordborg, 15 years ago

References #262 and #340. The overview and validation is now complete.
Still missing possibility to save validation options as presets.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.1 KB
Line 
1<%-- $Id: options.jsp 3045 2006-12-20 14:37:29Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Experiment"
31  import="net.sf.basedb.core.Project"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.clients.web.Base"
36  import="net.sf.basedb.clients.web.util.HTML"
37  import="net.sf.basedb.util.Values"
38  import="net.sf.basedb.util.overview.ExperimentOverview"
39  import="net.sf.basedb.util.overview.Node"
40  import="net.sf.basedb.util.overview.ValidationOptions"
41  import="net.sf.basedb.util.overview.Severity"
42  import="net.sf.basedb.util.overview.Validator"
43  import="java.util.List"
44  import="java.util.Map"
45  import="java.util.Iterator"
46%>
47<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
48<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
49<%
50final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
51final String ID = sc.getId();
52final float scale = Base.getScale(sc);
53final ItemContext cc = sc.getCurrentContext(Item.EXPERIMENT);
54final int itemId = cc.getId();
55final DbControl dc = sc.newDbControl();
56try
57{
58  Experiment experiment = Experiment.getById(dc, itemId);
59  Project project = sc.getActiveProjectId() == 0 ? null : Project.getById(dc, sc.getActiveProjectId());
60  ExperimentOverview overview = ExperimentOverview.getOverview(experiment, project);
61  ValidationOptions options = overview.getValidationOptions();
62  Map<String, List<Validator>> validators = ExperimentOverview.getValidators();
63  %>
64  <base:page title="" type="popup">
65  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
66  <script language="JavaScript">
67  function saveOptions()
68  {
69    document.forms['options'].submit();
70  }
71  function toggle(grpId)
72  {
73    var grp = document.getElementById('grp.'+grpId);
74    var grpIcon = document.getElementById('grp.'+grpId+'.icon');
75    var vldId = 1;
76    var vld = document.getElementById('vld.'+grpId+'.'+vldId);
77    if (vld && vld.style.display == 'none')
78    {
79      grpIcon.src = getRoot()+'images/joust/minustop.gif';
80    }
81    else
82    {
83      grpIcon.src = getRoot()+'images/joust/plusonly.gif';
84    }
85    while (vld)
86    {
87      Main.showHide(vld.id);
88      vldId++;
89      vld = document.getElementById('vld.'+grpId+'.'+vldId);
90    }
91  }
92  function setAllInGroup(grpId, severity)
93  {
94    var vldId = 1;
95    var vld = document.getElementById('select.'+grpId+'.'+vldId);
96    while (vld)
97    {
98      for (var i = 0; i < vld.length; i++)
99      {
100        if (vld[i].value == severity) 
101        {
102          vld.selectedIndex = i;
103          i = vld.length;
104        }
105      }
106      vldId++;
107      vld = document.getElementById('select.'+grpId+'.'+vldId);
108    }
109  }
110  function setAllOnChange(grpId, selectList)
111  {
112    var severity = selectList[selectList.selectedIndex].value;
113    selectList.selectedIndex = 0;
114    setAllInGroup(grpId, severity);
115  }
116 
117  function showDescription(evt, validatorId)
118  {
119    var description = 'description.'+validatorId;
120    Main.show(description);
121    var el = document.getElementById(description);
122    el.style.left = (evt.clientX + 10) + 'px';
123    el.style.top = (evt.clientY - 10) + 'px';
124  }
125  function hideDescription(validatorId)
126  {
127    var description = 'description.'+validatorId;
128    Main.hide(description);
129  }
130  </script>
131  </base:head>
132    <base:body>
133   
134    <form name="options" action="index.jsp" method="post">
135    <input type="hidden" name="ID" value="<%=ID%>">
136    <input type="hidden" name="cmd" value="SaveValidationOptions">
137   
138    <h3 class="docked">Validation options <base:help tabcontrol="settings" /></h3>
139    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
140      position="bottom">
141    <t:tab id="options" title="Validation options" helpid="experiment.overview.validationoptions">
142   
143      <table border="0" cellspacing="0" cellpadding="0">
144      <%
145      int grp = 0;
146      StringBuilder descriptions = new StringBuilder();
147      for (Map.Entry<String, List<Validator>> entry : validators.entrySet())
148      {
149        String title = entry.getKey();
150        ++grp;
151        int vld = 0;
152        %>
153        <tr id="grp.<%=grp%>">
154          <td style="padding-top: 6px;"><a href="javascript:toggle(<%=grp%>)"
155            ><base:icon id="<%="grp."+grp+".icon"%>" 
156              image="<%=grp > 1 ? "joust/plusonly.gif" : "joust/minustop.gif"%>" 
157            />&nbsp;<b><%=HTML.encodeTags(title)%></b></a>&nbsp;&nbsp;
158          </td>
159          <td style="padding-top: 6px;">
160            <select name="setall.<%=grp%>" onchange="setAllOnChange(<%=grp%>, this)">
161            <option value="">- set all in this group -
162            <%
163            for (Severity s : Severity.values())
164            {
165              %>
166              <option value="<%=s.name()%>"><%=s%>
167              <%
168            }
169            %>
170          </td>
171        </tr>
172        <%
173        Iterator<Validator> vi = entry.getValue().iterator();
174        while (vi.hasNext())
175        {
176          Validator validator = vi.next();
177          ++vld;
178          Severity option = options.getSeverity(validator);
179          String validatorId = validator.getId();
180          boolean hasNext = vi.hasNext();
181          descriptions.append("<div id=\"description.").append(validatorId).append("\"");
182          descriptions.append(" class=\"postit\" style=\"display:none;\">");
183          descriptions.append(HTML.encodeTags(validator.getDescription()));
184          descriptions.append("</div>\n");
185          %>
186          <tr id="vld.<%=grp%>.<%=vld%>" style="<%=grp > 1 ? "display: none;" : ""%>"
187            onmouseover="showDescription(event, '<%=validatorId%>')"
188            onmouseout="hideDescription('<%=validatorId%>')"
189            >
190            <td><base:icon 
191              image="<%=hasNext ? "joust/big/join.gif" : "joust/big/joinbottom.gif"%>" 
192              /><%=HTML.encodeTags(validator.getTitle())%>&nbsp;&nbsp;</td>
193            <td>
194            <select id="select.<%=grp%>.<%=vld%>" name="<%=validatorId%>">
195              <%
196              for (Severity s : Severity.values())
197              {
198                %>
199                <option value="<%=s.name()%>" <%=s == option ? "selected" : "" %>><%=s%>
200                <%
201              }
202              %>
203            </select>
204            </td>
205          </tr>
206          <%
207        }
208      }
209      %>
210      </table>
211      <%=descriptions.toString()%> 
212    </t:tab>
213    </t:tabcontrol>
214   
215    <div align="center">
216    <table>
217    <tr>
218      <td width="50%"><base:button title="Save" onclick="saveOptions()"/></td>
219      <td width="50%"><base:button title="Cancel" onclick="window.close()"/></td>
220    </tr>
221    </table>
222    </div>
223   
224    </form>
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.