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

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

Refernces #1193: Generic tree-like item overview

Web interface has been added to Hybridization view.

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