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

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

References #1655: GUI improvements

  • List of annotations and failures/warnings in the 'Item overview' details.
  • Bottom border in 'Inherit annotations' dialog.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 6.3 KB
Line 
1<%-- $Id: failures.jsp 5957 2012-02-14 10:13:27Z 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  tr.failure
110  {
111    border-bottom: 1px dotted #A0A0A0;
112    border-top: 1px dotted #A0A0A0;
113    cursor: pointer;
114  }
115  tr.failure:first-child
116  {
117    border-top: 1px dotted transparent;
118  }
119  tr.failure td
120  {
121    vertical-align: bottom;
122    padding: 2px;
123  }
124  .index
125  {
126    font-weight: bold;
127    text-align: right;
128  }
129
130  </style>
131  </base:head>
132
133  <base:body>
134    <div class="absolutefull" onmousemove="parent.DragDrop.drag(event)" onmouseup="parent.DragDrop.endDrag(event)" >
135   
136      <div class="absolutefull filled" style="height: 2em; padding-left: 1em;">
137      <table style="width: 100%; height: 100%;"><tr><td><b>
138        <%
139        if (showFailures)
140        {
141          %>
142          <%=errors.size() %> error(s),
143          <%=warnings.size()%> warning(s)
144        <%
145        }       
146        else
147        {
148          %>
149          <i>Item-tree not validated</i>
150          <%
151        }
152        %>
153      </b>
154      </td></tr></table>
155      </div>
156      <%
157      if(showFailures)
158      {
159        %>
160        <div class="absolutefull topborder" style="top: 2em;">
161        <table style="width: 100%; border-collapse: collapse;">
162        <%
163        int index = 0;
164        Iterator<Failure> all = new NestedIterator<Failure>(errors, warnings);
165        while (all.hasNext())
166        {
167          Failure failure = all.next();
168          Validator validator = failure.getValidator();
169          Severity severity = options.getSeverity(validator);
170          if (severity != Severity.IGNORE)
171          {
172            index++;
173            String failureId = "F" + System.identityHashCode(failure);
174            Node node = failure.getNode();
175            BasicItem item = node.getItem();
176            String onClick = "";
177            String tooltip = "";
178            if (item == null)
179            {
180              tooltip = "Get more information about this failure";
181              onClick = "failureOnClick(event, '"+failureId+"', '" + node.getId() + "')";
182            }
183            else
184            {
185              tooltip = "Get more information about this failure (use CTRL, ALT or SHIFT to edit the item)";
186              onClick = "failureOnClick(event, '"+failureId+"', '" + node.getId() + 
187                "', '" + item.getType().name() + "', " + item.getId() + ")";
188            }
189            %>
190            <tr id="<%=failureId%>" class="failure highlight" 
191              onclick="<%=onClick%>" 
192              title="<%=tooltip%>"
193              >
194              <td style="width: 3em;" class="index"><%=index%></td>
195              <td style="width: 24px; text-align: center;" class="text"><base:icon image="<%=severity == Severity.ERROR ? "error.png" : "warning.png"%>" /></td>
196              <td class="text link"><%=HTML.encodeTags(failure.getMessage()) %></td>
197              <td class="text"><%=HTML.encodeTags(node.getTitle()) %></td>
198            </tr>
199            <%
200          }
201        }
202        %>
203        </table>
204        </div>
205        <%
206      }
207      %>
208      </div>
209    </base:body>
210  </base:page>
211  <%
212}
213finally
214{
215  if (dc != null) dc.close();
216}
217%>
Note: See TracBrowser for help on using the repository browser.