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

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

References #1655: GUI improvements

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