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

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

References #1240. Some adjustments on menuitems' tooltip- and cursor- behavior. The validate-toolbutton is decided to validate the whole tree and not only already loaded nodes.

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