source: trunk/www/views/experiments/overview/tree.jsp @ 3033

Last change on this file since 3033 was 3033, checked in by Nicklas Nordborg, 15 years ago

References #262, #340: First prototype for experiment overview. Reads most of an
experiment. Limited validation. No presets. No detailed information about an error/warning.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 7.8 KB
Line 
1<%-- $Id: tree.jsp 3033 2006-12-15 14:30:37Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) Authors contributing to this file.
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 2
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 this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA  02111-1307, USA.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.Experiment"
31  import="net.sf.basedb.core.Project"
32  import="net.sf.basedb.core.Item"
33  import="net.sf.basedb.core.ItemContext"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.clients.web.Base"
36  import="net.sf.basedb.clients.web.util.HTML"
37  import="net.sf.basedb.util.Values"
38  import="net.sf.basedb.util.overview.ExperimentOverview"
39  import="net.sf.basedb.util.overview.Node"
40  import="net.sf.basedb.util.overview.ValidationOptions"
41  import="java.util.List"
42%>
43<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
44<%!
45String generateSubTree(Node startNode, String ID)
46{
47  StringBuilder sb = new StringBuilder();
48  List<Node> children = startNode.getChildren();
49  if (children == null) return "";
50  for (Node child : children)
51  {
52    String folderIcon = child.getNodeType() == Node.Type.FOLDER ? "Folder" : "Item";
53    int errors = child.getNumErrors();
54    int warnings = child.getNumWarnings();
55    int childErrors = child.getChildErrors();
56    int childWarnings = child.getChildWarnings();
57    if (errors > 0)
58    {
59      folderIcon += "Error";
60    }
61    else if (warnings > 0)
62    {
63      folderIcon += "Warning";
64    }
65    else if (childErrors > 0)
66    {
67      folderIcon += "ChildError";
68    }
69    else if (childWarnings > 0)
70    {
71      folderIcon += "ChildWarning";
72    }
73    if (child.getNodeType() == Node.Type.ITEM && child.getItem() == null)
74    {
75      folderIcon = "ItemDenied";
76    }
77    String tooltip = "";
78    if (warnings > 0 && errors > 0)
79    {
80      tooltip += errors + " error(s); " + warnings + " warning(s) on this item";
81    }
82    else if (errors > 0)
83    {
84      tooltip += errors + " error(s) on this item";
85    }
86    else if (warnings > 0)
87    {
88      tooltip += warnings + " warning(s) on this item";
89    }
90    if (childErrors > 0 && childWarnings > 0)
91    {
92      if (tooltip.length() > 0) tooltip += "; ";
93      tooltip += childErrors + " error(s); " + childWarnings + " warning(s) on child items";
94    }
95    else if (childErrors > 0)
96    {
97      if (tooltip.length() > 0) tooltip += "; ";
98      tooltip += childErrors + " error(s) on child items";
99    }
100    else if (childWarnings > 0)
101    {
102      if (tooltip.length() > 0) tooltip += "; ";
103      tooltip += childWarnings + " warning(s) on child items";
104    }
105    int numChildren = child.getChildren() == null ? 
106      0 : child.getChildren().size();
107    sb.append("var node").append(child.hashCode()).append(" = JoustMenu.addChildItem(").append("node"+startNode.hashCode());
108    sb.append(",'").append(folderIcon).append("'");
109    sb.append(",'").append(HTML.javaScriptEncode(child.getTitle()));
110    sb.append(child.getNodeType() == Node.Type.FOLDER ? " (" + numChildren + ")" : "").append("',");
111    sb.append("'','" + HTML.javaScriptEncode(tooltip) + "', '").append(child.getId()).append("')\n");
112    sb.append(generateSubTree(child, ID));
113  }
114  return sb.toString();
115}
116%>
117<%
118final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
119final String ID = sc.getId();
120final float scale = Base.getScale(sc);
121final ItemContext cc = sc.getCurrentContext(Item.EXPERIMENT);
122final int itemId = cc.getId();
123final DbControl dc = sc.newDbControl();
124try
125{
126  Experiment experiment = Experiment.getById(dc, itemId);
127  Project project = sc.getActiveProjectId() == 0 ? null : Project.getById(dc, sc.getActiveProjectId());
128  ExperimentOverview overview = ExperimentOverview.getOverview(experiment, project);
129  Node rootNode = overview.getRootNode();
130  String rootIcon = "Home";
131  if (rootNode.getNumErrors() > 0 || rootNode.getChildErrors() > 0)
132  {
133    rootIcon = "Error";
134  }
135  else if (rootNode.getNumWarnings() > 0 || rootNode.getChildWarnings() > 0)
136  {
137    rootIcon = "Warning";
138  }
139  %>
140  <base:page title="" type="popup">
141  <base:head scripts="newjoust.js" styles="newjoust.css">
142  <script language="JavaScript">
143  var isInitialised = false;
144  function initialise()
145  {
146    if (parent && parent.parent && parent.parent.adjustIFrameSize) parent.parent.adjustIFrameSize();
147    IconStore.init();
148    var path = getRoot()+'images/joust/';
149   
150    IconStore.addIcon('Warning', getRoot() + 'images/warning.gif', 16, 16);
151    IconStore.addIcon('Error', getRoot() + 'images/error.gif', 16, 16);
152    IconStore.addIcon('FolderWarning', path + 'folderwarning.gif', 18, 16);
153    IconStore.addIcon('FolderWarningSelected', path + 'folderwarningselected.gif', 18, 16);
154    IconStore.addIcon('FolderChildWarning', path + 'folderchildwarning.gif', 18, 16);
155    IconStore.addIcon('FolderChildWarningSelected', path + 'folderchildwarningselected.gif', 18, 16);
156    IconStore.addIcon('FolderError', path + 'foldererror.gif', 18, 16);
157    IconStore.addIcon('FolderErrorSelected', path + 'foldererrorselected.gif', 18, 16);
158    IconStore.addIcon('FolderChildError', path + 'folderchilderror.gif', 18, 16);
159    IconStore.addIcon('FolderChildErrorSelected', path + 'folderchilderrorselected.gif', 18, 16);
160    IconStore.addIcon('Item', path + 'item.gif', 18, 16);
161    IconStore.addIcon('ItemSelected', path + 'itemselected.gif', 18, 16);
162    IconStore.addIcon('ItemWarning', path + 'itemwarning.gif', 18, 16);
163    IconStore.addIcon('ItemWarningSelected', path + 'itemwarningselected.gif', 18, 16);
164    IconStore.addIcon('ItemChildWarning', path + 'itemchildwarning.gif', 18, 16);
165    IconStore.addIcon('ItemChildWarningSelected', path + 'itemchildwarningselected.gif', 18, 16);
166    IconStore.addIcon('ItemError', path + 'itemerror.gif', 18, 16);
167    IconStore.addIcon('ItemErrorSelected', path + 'itemerrorselected.gif', 18, 16);
168    IconStore.addIcon('ItemChildError', path + 'itemchilderror.gif', 18, 16);
169    IconStore.addIcon('ItemChildErrorSelected', path + 'itemchilderrorselected.gif', 18, 16);
170    IconStore.addIcon('ItemDenied', path + 'itemdenied.gif', 18, 16);
171    IconStore.addIcon('ItemDeniedSelected', path + 'itemdeniedselected.gif', 18, 16);
172    var node<%=rootNode.hashCode()%> = JoustMenu.addMenuItem(-1, '<%=rootIcon%>', '<%=HTML.javaScriptEncode(experiment.getName())%>', '', '', '<%=rootNode.getId()%>');
173    <%=generateSubTree(rootNode, ID)%>
174    JoustMenu.draw('joust');
175    isInitialised = true;
176  }
177
178  function openAll()
179  {
180    JoustMenu.openAll();
181  }
182
183  function closeAll()
184  {
185    JoustMenu.closeAll();
186  }
187  var loadedTime = new Date().getTime();
188  function refreshIfOutdated()
189  {
190    var currentTime = new Date().getTime();
191    if (currentTime - loadedTime > 2000)
192    {
193      location.reload();
194    }
195  }
196  </script>
197  </base:head>
198    <base:body onload="initialise()" 
199      style="background: #E0E0E0; xborder-right: 1px solid #666666; padding-left: 0px; padding-right: 0px;" >
200    <div id="main" class="joust" style="width:100%;">
201      <div id="joust" style="overflow: auto;">
202      </div>
203      <div style="width:99%;">
204      <table align="center">
205      <tr>
206        <td><base:button onclick="openAll()" title="Expand all" image="joust/plus.gif" /></td>
207        <td><base:button onclick="closeAll()" title="Collapse all" image="joust/minus.gif" /></td>
208      </tr>
209      </table>
210      </div>
211    </div>
212    </base:body>
213
214  </base:page>
215  <%
216}
217finally
218{
219  if (dc != null) dc.close();
220}
221%>
Note: See TracBrowser for help on using the repository browser.