source: trunk/www/common/overview/failures.jsp @ 5951

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

References #1655: GUI improvements

  • Fixes rest of list pages in Biomaterial LIMS menu
  • Introduced an 'iframe' page type so that thos pages doesn't have to 'cannibalise' on the 'popup' page type (doesn't works well with absolutely positioned content).
  • Fixed subclass="dialogbuttons" on all list pages when used in popup form


  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.2 KB
Line 
1<%-- $Id: failures.jsp 5951 2012-02-09 14:19:17Z 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 pageEncoding="UTF-8" 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.BasicItem"
28  import="net.sf.basedb.core.Nameable"
29  import="net.sf.basedb.core.ItemContext"
30  import="net.sf.basedb.core.Permission"
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.NestedIterator"
35  import="net.sf.basedb.util.overview.GenericOverview"
36  import="net.sf.basedb.util.overview.OverviewUtil"
37  import="net.sf.basedb.util.overview.Node"
38  import="net.sf.basedb.util.overview.ValidationOptions"
39  import="net.sf.basedb.util.overview.Validator"
40  import="net.sf.basedb.util.overview.Severity"
41  import="net.sf.basedb.util.overview.Failure"
42  import="java.util.List"
43  import="java.util.LinkedList"
44  import="java.util.Iterator"
45  import="java.util.Set"
46  import="java.util.HashSet"
47%>
48<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
49<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
50<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
51<%
52final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
53final String ID = sc.getId();
54final float scale = Base.getScale(sc);
55final DbControl dc = null;
56try
57{
58  GenericOverview overview = OverviewUtil.getCurrentOverview(sc);
59  ValidationOptions options = overview.getValidationOptions();
60  Boolean showFailures = Values.getBoolean(request.getParameter("show_failures"), false);
61  List<Failure> failures = overview.getFailures();
62  if (failures == null) failures = new LinkedList<Failure>();
63  List<Failure> errors = new LinkedList<Failure>();
64  List<Failure> warnings = new LinkedList<Failure>();
65  Set<Failure> duplicates = new HashSet<Failure>();
66 
67  for (Failure failure : failures)
68  {
69    if (!duplicates.contains(failure))
70    {
71      duplicates.add(failure);
72      Validator validator = failure.getValidator();
73      Severity severity = options.getSeverity(validator);
74      if (severity == Severity.ERROR)
75      {
76        errors.add(failure);
77      }
78      else if (severity == Severity.WARNING)
79      {
80        warnings.add(failure);
81      }
82    }
83  }
84  %>
85  <base:page title="" type="iframe">
86  <base:head scripts="" styles="newjoust.css">
87  <script language="JavaScript">
88  var selectedFailure = null;
89  function failureOnClick(evt, failureId, nodeId, itemType, itemId)
90  {
91    if (itemType && evt && (evt.altKey || evt.ctrlKey || evt.shiftKey))
92    {
93      Main.viewOrEditItem('<%=ID%>', itemType, itemId, true);
94    }
95    else
96    {
97      window.parent.frames['tree'].selectNode(nodeId);
98      if (selectedFailure) Main.removeClass(selectedFailure, 'selected');
99      selectedFailure = document.getElementById(failureId);
100      Main.addClass(selectedFailure, 'selected');
101    }
102  }
103  function itemOnClick(evt, itemType, itemId)
104  {
105    Table.itemOnClick(formId, evt, itemId, 'default', viewItem, editItem, returnSelected);
106  }
107  </script>
108  <style>
109  .failure td {
110    vertical-align: bottom;
111    border-bottom: 1px dotted #999999;
112    padding: 2px;
113  }
114  .index {
115    font-weight: bold;
116    text-align: right;
117  }
118  .summary {
119    border-bottom: 1px solid #999999;
120    padding-top: 2px;
121    padding-bottom: 2px;
122    xposition: fixed;
123    xtop: 0px;
124    width:100%;
125    background: #ffffff;
126  }
127  </style>
128  </base:head>
129
130  <base:body>
131    <div class="absolutefull" onmousemove="parent.DragDrop.drag(event)" onmouseup="parent.DragDrop.endDrag(event)" >
132   
133      <div class="summary">
134      <b>
135      <%
136      if (showFailures)
137      {
138        %>
139        <%=errors.size() %> error(s),
140        <%=warnings.size()%> warning(s)
141      <%
142      }       
143      else
144      {
145        %>
146        <i>Item-tree not validated</i>
147        <%
148      }
149      %>
150      </b>
151      </div>
152      <%
153      if(showFailures)
154      {
155        %>
156        <br>
157        <div class="joust">
158        <table border="0" cellspacing="0" cellpadding="0" width="100%">
159        <%
160        int index = 0;
161        Iterator<Failure> all = new NestedIterator<Failure>(errors, warnings);
162        while (all.hasNext())
163        {
164          Failure failure = all.next();
165          Validator validator = failure.getValidator();
166          Severity severity = options.getSeverity(validator);
167          if (severity != Severity.IGNORE)
168          {
169            index++;
170            String failureId = "F" + System.identityHashCode(failure);
171            Node node = failure.getNode();
172            BasicItem item = node.getItem();
173            String onClick = "";
174            String tooltip = "";
175            if (item == null)
176            {
177              tooltip = "Get more information about this failure";
178              onClick = "failureOnClick(event, '"+failureId+"', '" + node.getId() + "')";
179            }
180            else
181            {
182              tooltip = "Get more information about this failure (use CTRL, ALT or SHIFT to edit the item)";
183              onClick = "failureOnClick(event, '"+failureId+"', '" + node.getId() + 
184                "', '" + item.getType().name() + "', " + item.getId() + ")";
185            }
186            %>
187            <tr id="<%=failureId%>" class="menuitem failure" 
188              onclick="<%=onClick%>" 
189              title="<%=tooltip%>"
190              >
191              <td width="20px" class="index text"><%=index%></td>
192              <td width="20px" class="text"><base:icon image="<%=severity == Severity.ERROR ? "error.png" : "warning.png"%>" /></td>
193              <td class="text"><%=HTML.encodeTags(failure.getMessage()) %></td>
194              <td class="text"><%=HTML.encodeTags(node.getTitle()) %></td>
195            </tr>
196            <%
197          }
198        }
199        %>
200        </table>
201        </div>
202        <%
203      }
204      %>
205      </div>
206    </base:body>
207  </base:page>
208  <%
209}
210finally
211{
212  if (dc != null) dc.close();
213}
214%>
Note: See TracBrowser for help on using the repository browser.