source: trunk/www/common/overview/options.jsp @ 5076

Last change on this file since 5076 was 5076, checked in by Nicklas Nordborg, 14 years ago

Fixes #1362: Validate the number of raw data spots against the number of array design features

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 9.6 KB
Line 
1<%-- $Id: options.jsp 5076 2009-08-25 09:15:41Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 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<%@ page session="false"
23  import="net.sf.basedb.core.SessionControl"
24  import="net.sf.basedb.core.DbControl"
25  import="net.sf.basedb.core.Project"
26  import="net.sf.basedb.core.Item"
27  import="net.sf.basedb.core.ItemContext"
28  import="net.sf.basedb.core.Permission"
29  import="net.sf.basedb.core.Presets"
30  import="net.sf.basedb.core.Presets.Preset"
31  import="net.sf.basedb.clients.web.Base"
32  import="net.sf.basedb.clients.web.util.HTML"
33  import="net.sf.basedb.util.Values"
34  import="net.sf.basedb.util.overview.GenericOverview"
35  import="net.sf.basedb.util.overview.OverviewUtil"
36  import="net.sf.basedb.util.overview.Node"
37  import="net.sf.basedb.util.overview.ValidationOptions"
38  import="net.sf.basedb.util.overview.Severity"
39  import="net.sf.basedb.util.overview.Validator"
40  import="java.util.List"
41  import="java.util.Map"
42  import="java.util.Iterator"
43%>
44<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
45<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
46<%
47final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
48final String ID = sc.getId();
49final float scale = Base.getScale(sc);
50final DbControl dc = sc.newDbControl();
51final String presetName = Values.getStringOrNull(request.getParameter("presetName"));
52final boolean resetToDefault = Values.getBoolean(request.getParameter("resetToDefault"));
53try
54{
55  Presets presets = OverviewUtil.getValidationPresets(sc);
56  ValidationOptions options = null;
57  if (resetToDefault)
58  {
59    options = new ValidationOptions();
60  }
61  else if (presetName == null)
62  {
63    options = new ValidationOptions(presets.getDefault());
64  }
65  else
66  {
67    options = new ValidationOptions(presets.getPreset(presetName));
68  }
69  Map<String, List<Validator>> validators = OverviewUtil.getValidators();
70  %>
71  <base:page title="Validation options" type="popup">
72  <base:head scripts="tabcontrol.js" styles="tabcontrol.css">
73  <script language="JavaScript">
74  function saveOptions()
75  {
76    document.forms['options'].submit();
77  }
78  function toggle(grpId)
79  {
80    var grp = document.getElementById('grp.'+grpId);
81    var grpIcon = document.getElementById('grp.'+grpId+'.icon');
82    var vldId = 1;
83    var vld = document.getElementById('vld.'+grpId+'.'+vldId);
84    if (vld && vld.style.display == 'none')
85    {
86      grpIcon.src = getRoot()+'images/joust/minustop.gif';
87    }
88    else
89    {
90      grpIcon.src = getRoot()+'images/joust/plusonly.gif';
91    }
92    while (vld)
93    {
94      Main.showHide(vld.id);
95      vldId++;
96      vld = document.getElementById('vld.'+grpId+'.'+vldId);
97    }
98  }
99  function setAllInGroup(grpId, severity)
100  {
101    var vldId = 1;
102    var vld = document.getElementById('select.'+grpId+'.'+vldId);
103    while (vld)
104    {
105      for (var i = 0; i < vld.length; i++)
106      {
107        if (vld[i].value == severity) 
108        {
109          vld.selectedIndex = i;
110          i = vld.length;
111        }
112      }
113      vldId++;
114      vld = document.getElementById('select.'+grpId+'.'+vldId);
115    }
116  }
117  function setAllOnChange(grpId, selectList)
118  {
119    var severity = selectList[selectList.selectedIndex].value;
120    selectList.selectedIndex = 0;
121    setAllInGroup(grpId, severity);
122  }
123 
124  function showDescription(evt, validatorId)
125  {
126    var description = 'description.'+validatorId;
127    Main.show(description);
128    var el = document.getElementById(description);
129    el.style.left = (evt.clientX + 10) + 'px';
130    el.style.top = (evt.clientY - 10) + 'px';
131  }
132  function hideDescription(validatorId)
133  {
134    var description = 'description.'+validatorId;
135    Main.hide(description);
136  }
137  function presetsOnChange()
138  {
139    var frm = document.forms['options'];
140    var selected = frm.presets[frm.presets.selectedIndex].value;
141    if (selected == '')
142    {
143      location.href = 'options.jsp?ID=<%=ID%>&resetToDefault=1';
144    }
145    else if (selected != '---')
146    {
147      location.href = 'options.jsp?ID=<%=ID%>&presetName='+encodeURIComponent(selected);
148    }
149  }
150  function saveAsOnClick()
151  {
152    Main.openPopup('save_preset.jsp?ID=<%=ID%>', 'SaveValidationPreset', 480, 200);
153  }
154  function saveAsPreset(name)
155  {
156    var frm = document.forms['options'];
157    frm.cmd.value = 'SaveAsPreset';
158    Forms.createHidden(frm, 'presetName', name);
159    frm.submit();
160  }
161  function removeOnClick()
162  {
163    var frm = document.forms['options'];
164    var selected = frm.presets[frm.presets.selectedIndex].value;
165    if (selected != '---' && selected != '')
166    {
167      if (confirm('Remove preset: \'' + selected + '\'? This can\'t be undone.'))
168      {
169        location.href = 'index.jsp?ID=<%=ID%>&cmd=RemovePreset&presetName='+escape(selected);
170      }
171    }
172  }
173  </script>
174  </base:head>
175    <base:body>
176   
177    <form name="options" action="index.jsp" method="post">
178    <input type="hidden" name="ID" value="<%=ID%>">
179    <input type="hidden" name="cmd" value="SaveValidationOptions">
180   
181    <h3 class="docked">Validation options <base:help tabcontrol="settings" /></h3>
182    <t:tabcontrol id="settings" contentstyle="<%="height: "+(int)(scale*370)+"px;"%>" 
183      position="bottom">
184    <t:tab id="options" title="Validation options" helpid="item.overview.validationoptions">
185   
186      <table border="0" cellspacing="0" cellpadding="0">
187      <tr>
188      <td style="border-bottom: 1px solid #999999;"><b>Presets</b></td>
189      <td style="border-bottom: 1px solid #999999; padding-bottom: 4px;">
190        <select name="presets" onchange="presetsOnChange()">
191          <option value="---" class="selectoptionheader">-- predefined --
192          <option value="" <%="".equals(presetName) ? "selected" : "" %>>BASE default
193          <option value="---" class="selectoptionheader">-- user defined --
194          <%
195          for (Preset preset : presets)
196          {
197            String name = HTML.encodeTags(preset.getName());
198            String selected = presetName != null && presetName.equals(preset.getName()) ?
199              "selected" : "";
200            %>
201            <option value="<%=name%>" <%=selected%>><%=name%>
202            <%         
203          }
204          %>
205        </select>
206      </td>
207      <td style="border-bottom: 1px solid #999999; padding-left: 4px; padding-bottom: 4px;"><base:button title="Save as&hellip;" onclick="saveAsOnClick()" /></td>
208      <td style="border-bottom: 1px solid #999999; padding-left: 4px; padding-bottom: 4px;"><base:button title="Remove&hellip;" onclick="removeOnClick()" /></td>
209      </tr>
210      <%
211      int grp = 0;
212      StringBuilder descriptions = new StringBuilder();
213      for (Map.Entry<String, List<Validator>> entry : validators.entrySet())
214      {
215        String title = entry.getKey();
216        ++grp;
217        int vld = 0;
218        %>
219        <tr id="grp.<%=grp%>">
220          <td style="padding-top: 6px;"><a href="javascript:toggle(<%=grp%>)"
221            ><base:icon id="<%="grp."+grp+".icon"%>" 
222              image="<%=grp > 1 ? "joust/plusonly.gif" : "joust/minustop.gif"%>" 
223            />&nbsp;<b><%=HTML.encodeTags(title)%></b></a>&nbsp;&nbsp;
224          </td>
225          <td style="padding-top: 6px;" colspan="3">
226            <select name="setall.<%=grp%>" onchange="setAllOnChange(<%=grp%>, this)">
227            <option value="">- set all in this group -
228            <%
229            for (Severity s : Severity.values())
230            {
231              %>
232              <option value="<%=s.name()%>"><%=s%>
233              <%
234            }
235            %>
236          </td>
237        </tr>
238        <%
239        Iterator<Validator> vi = entry.getValue().iterator();
240        while (vi.hasNext())
241        {
242          Validator validator = vi.next();
243          ++vld;
244          Severity option = options.getSeverity(validator);
245          String validatorId = validator.getId();
246          boolean hasNext = vi.hasNext();
247          descriptions.append("<div id=\"description.").append(validatorId).append("\"");
248          descriptions.append(" class=\"postit\" style=\"display:none;\">");
249          descriptions.append(HTML.encodeTags(validator.getDescription()));
250          descriptions.append("</div>\n");
251          %>
252          <tr id="vld.<%=grp%>.<%=vld%>" style="<%=grp > 1 ? "display: none;" : ""%>"
253            >
254            <td
255              onmouseover="showDescription(event, '<%=validatorId%>')"
256              onmouseout="hideDescription('<%=validatorId%>')"
257              ><base:icon 
258              image="<%=hasNext ? "joust/big/join.gif" : "joust/big/joinbottom.gif"%>" 
259              /><%=HTML.encodeTags(validator.getTitle())%>&nbsp;&nbsp;</td>
260            <td colspan="3">
261            <select id="select.<%=grp%>.<%=vld%>" name="<%=validatorId%>">
262              <%
263              for (Severity s : Severity.values())
264              {
265                %>
266                <option value="<%=s.name()%>" <%=s == option ? "selected" : "" %>><%=s%>
267                <%
268              }
269              %>
270            </select>
271            <%
272            if (validator == Validator.NONMATCHING_SPOTCOUNT)
273            {
274              %>
275              Threshold:
276              <input type="text" class="text" 
277                name="threshold" 
278                title="Threshold, as a percentage or an absolute value" 
279                size="8"
280                value="<%=HTML.encodeTags(options.getOption(validator, "threshold", "5%"))%>" >
281              <%
282            }
283            %>
284            </td>
285          </tr>
286          <%
287        }
288      }
289      %>
290      </table>
291      <%=descriptions.toString()%> 
292    </t:tab>
293    </t:tabcontrol>
294   
295    <div align="center">
296    <table>
297    <tr>
298      <td width="50%"><base:button title="Save" onclick="saveOptions()"/></td>
299      <td width="50%"><base:button title="Cancel" onclick="window.close()"/></td>
300    </tr>
301    </table>
302    </div>
303   
304    </form>
305    </base:body>
306  </base:page>
307  <%
308}
309finally
310{
311  if (dc != null) dc.close();
312}
313%>
Note: See TracBrowser for help on using the repository browser.