source: trunk/www/common/overview/ajax.jsp @ 4823

Last change on this file since 4823 was 4823, checked in by Martin Svensson, 14 years ago

References #1240. The node-icons are getting updated when expanding the item-tree and an error or warning appears.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 3.2 KB
Line 
1<%-- $Id: ajax.jsp 4823 2009-03-19 15:08:24Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2009 Martin Svensson
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--%>
23<%@ page session="false"
24  import="net.sf.basedb.core.SessionControl"
25  import="net.sf.basedb.core.DbControl"
26  import="net.sf.basedb.core.Item"
27  import="net.sf.basedb.util.overview.GenericOverview"
28  import="net.sf.basedb.util.overview.Node"
29  import="net.sf.basedb.util.overview.OverviewUtil"
30  import="net.sf.basedb.clients.web.Base"
31  import="net.sf.basedb.clients.web.WebException"
32%>
33<%
34final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
35final String ID = sc.getId();
36final String cmd = request.getParameter("cmd");
37final String root = request.getContextPath()+"/";
38final String nodeId = request.getParameter("node_id");
39DbControl dc = null;
40out.clear();
41try
42{
43  if ("GetSubNodes".equals(cmd))
44  {
45    dc = sc.newDbControl();
46    GenericOverview overview = OverviewUtil.getCurrentOverview(sc);
47    Node parent = overview.getNode("N"+nodeId);
48    overview.expand(dc, parent, false);
49    overview.updateFailureCountOnNodes();
50    if (parent != null && parent.numChildren() > 0)
51    {
52      String parentIconSuffix = "";
53      String parentTooltip = "";
54      int errors = parent.getNumErrors();
55      int warnings = parent.getNumWarnings();
56      if (errors > 0)
57      {
58        parentIconSuffix = "Error"; 
59        parentTooltip = errors + " error(s) on this item";
60      }
61      else if (warnings > 0)
62      {     
63        parentIconSuffix = "Warning";
64        parentTooltip = warnings + " warning(s) on this item";
65      }
66      for (Node n : parent.getChildren())
67      {       
68        String folderIcon = n.getNodeType() == Node.Type.FOLDER ? "Folder" : "Item";
69        if (n.getItemType() == Item.ANNOTATIONTYPE && parent.getItemType() == Item.PROTOCOL)
70        {
71          folderIcon = "ProtocolParameter";
72        }
73        else if (n.getItemType() == Item.ANNOTATION)
74        {
75          folderIcon = "Annotation";
76        }       
77        String tooltip = "";
78        int numChildren = n.getChildren() == null ? 
79          0 : n.getChildren().size();
80        %>begin
81id  <%=n.getId()%>
82title <%=n.getTitle() + (n.getNodeType() == Node.Type.FOLDER ? " (" + numChildren + ")" : "")%>
83hashCode  <%=n.hashCode()%>
84folderIcon  <%=folderIcon %>
85parentIconSuffix  <%=parentIconSuffix%>
86tooltip <%=tooltip%>
87parentTooltip <%=parentTooltip%>
88end
89<%
90      }
91      dc.commit();
92    }
93  }
94  else
95  {
96    throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd);
97  }
98}
99finally
100{
101  if (dc != null) dc.close();
102}
103//out.flush();
104//out.close();
105%>
Note: See TracBrowser for help on using the repository browser.