source: trunk/www/views/reporters/view_reporter.jsp @ 5943

Last change on this file since 5943 was 5943, checked in by Nicklas Nordborg, 11 years ago

References #1655: GUI improvements

Plate section of Array LIMS.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 8.9 KB
Line 
1<%-- $Id: view_reporter.jsp 5943 2012-02-01 14:49:04Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2005 Nicklas Nordborg
4  Copyright (C) 2006 Johan Enell, Jari Häkkinen, Nicklas Nordborg, Martin Svensson
5  Copyright (C) 2007 Nicklas Nordborg
6
7  This file is part of BASE - BioArray Software Environment.
8  Available at http://base.thep.lu.se/
9
10  BASE is free software; you can redistribute it and/or
11  modify it under the terms of the GNU General Public License
12  as published by the Free Software Foundation; either version 3
13  of the License, or (at your option) any later version.
14
15  BASE is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  GNU General Public License for more details.
19
20  You should have received a copy of the GNU General Public License
21  along with BASE. If not, see <http://www.gnu.org/licenses/>.
22  ------------------------------------------------------------------
23
24  @author Nicklas
25  @version 2.0
26--%>
27<%@ page pageEncoding="UTF-8" session="false"
28  import="net.sf.basedb.core.SessionControl"
29  import="net.sf.basedb.core.DbControl"
30  import="net.sf.basedb.core.SystemItems"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.Permission"
34  import="net.sf.basedb.core.ExtendedProperties"
35  import="net.sf.basedb.core.ExtendedProperty"
36  import="net.sf.basedb.core.Type"
37  import="net.sf.basedb.core.Reporter"
38  import="net.sf.basedb.core.ReporterType"
39  import="net.sf.basedb.core.data.ReporterData"
40  import="net.sf.basedb.core.ItemQuery"
41  import="net.sf.basedb.core.ItemResultIterator"
42  import="net.sf.basedb.core.PermissionDeniedException"
43  import="net.sf.basedb.core.PluginDefinition"
44  import="net.sf.basedb.core.plugin.GuiContext"
45  import="net.sf.basedb.core.plugin.Plugin"
46  import="net.sf.basedb.core.query.Orders"
47  import="net.sf.basedb.core.query.Hql"
48  import="net.sf.basedb.clients.web.Base"
49  import="net.sf.basedb.clients.web.util.HTML"
50  import="net.sf.basedb.util.Values"
51  import="net.sf.basedb.util.formatter.Formatter"
52  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
53  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
54  import="net.sf.basedb.clients.web.extensions.JspContext"
55  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
56  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
57  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
58  import="java.util.Date"
59  import="java.util.Map"
60  import="java.util.List"
61%>
62<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
63<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
64<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
65<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
66<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
67<%!
68  private static final Item itemType = Item.REPORTER;
69  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
70%>
71<%
72final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
73final String ID = sc.getId();
74final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
75final int itemId = cc.getId();
76final float scale = Base.getScale(sc);
77final DbControl dc = sc.newDbControl();
78try
79{
80  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
81
82  String title = null;
83  ReporterData reporter = Reporter.getById(dc, itemId);
84 
85  final boolean writePermission = sc.hasPermission(Permission.WRITE, itemType);
86  final boolean deletePermission = sc.hasPermission(Permission.DELETE, itemType);
87  Formatter<Date> dateTimeFormatter = FormatterFactory.getDateTimeFormatter(sc);
88  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
89  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, reporter);
90  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
91  %>
92  <base:page title="<%=title%>">
93  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css">
94    <ext:scripts context="<%=jspContext%>" />
95    <ext:stylesheets context="<%=jspContext%>" />
96    <script language="JavaScript">
97    function editItem()
98    {
99      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
100    }
101    function deleteItem()
102    {
103      if (confirm('This can\'t be undone. Continue?'))
104      {
105        location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
106      }
107    }
108    function runPlugin(cmd)
109    {
110      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
111    }
112    </script>
113  </base:head>
114  <base:body>
115    <p:path><p:pathelement 
116      title="Reporters" href="<%="index.jsp?ID="+ID%>" 
117      /><p:pathelement title="<%=HTML.encodeTags(reporter.getName())%>" 
118      /></p:path>
119   
120    <t:tabcontrol 
121      id="main" 
122      subclass="content mastertabcontrol" 
123      active="properties">
124    <t:tab id="properties" title="Properties">
125      <div>
126      <table class="fullform bottomborder">
127      <tr>
128        <th class="itemstatus"></th>
129        <td style="padding: 0px;">
130          <tbl:toolbar subclass="bottomborder">
131            <tbl:button 
132              disabled="<%=!writePermission%>" 
133              image="edit.gif" 
134              onclick="editItem()" 
135              title="Edit&hellip;" 
136              tooltip="<%=writePermission ? "Edit this reporter" : "You do not have permission to edit this reporter"%>" 
137            />
138            <tbl:button 
139              disabled="<%=!deletePermission%>" 
140              image="delete.gif" 
141              onclick="deleteItem()" 
142              title="Delete&hellip;" 
143              tooltip="<%=deletePermission ? "Delete this reporter" : "You do not have permission to delete this reporter"%>" 
144            />
145            <tbl:button 
146              image="import.gif" 
147              onclick="runPlugin('ImportItem')" 
148              title="Import&hellip;" 
149              tooltip="Import data" 
150              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
151            />
152            <tbl:button 
153              image="export.gif" 
154              onclick="runPlugin('ExportItem')" 
155              title="Export&hellip;" 
156              tooltip="Export data" 
157              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
158            />
159            <tbl:button 
160              image="runplugin.gif" 
161              onclick="runPlugin('RunPlugin')" 
162              title="Run plugin&hellip;" 
163              tooltip="Run a plugin" 
164              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
165            />
166            <tbl:button
167              image="help.png"
168              onclick="<%="Main.openHelp('" + ID +"', 'reporter.view.properties')"%>"
169              title="Help&hellip;"
170              tooltip="Get help about this page"
171            />
172            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
173              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
174          </tbl:toolbar>
175        </td>
176      </tr>
177      <tr>
178        <th>Name</th>
179        <td><%=HTML.encodeTags(reporter.getName())%></td>
180      </tr>
181      <tr>
182        <th>External ID</th>
183        <td><%=HTML.encodeTags(reporter.getExternalId())%></td>
184      </tr>
185      <tr>
186        <th>Type</th>
187        <td><base:propertyvalue dbcontrol="<%=dc%>" item="<%=reporter%>" property="reporterType" /></td>
188      </tr>
189      <tr>
190        <th>Registered</th>
191        <td><%=dateFormatter.format(reporter.getEntryDate())%></td>
192      </tr>
193      <tr>
194        <th>Last update</th>
195        <td><%=dateTimeFormatter.format(reporter.getLastUpdate())%></td>
196      </tr>
197      <tr>
198        <th class="subprompt">- from/by</th>
199        <td><%=HTML.niceFormat(reporter.getLastSource())%></td>
200      </tr>
201      <tr>
202        <th>Gene symbol</th>
203        <td><%=HTML.encodeTags(reporter.getSymbol())%></td>
204      </tr>
205        <tr>
206          <th>Permissions</th>
207          <td>
208          <%=sc.hasPermission(Permission.READ, itemType) ? "Read" : ""%>
209          <%=sc.hasPermission(Permission.USE, itemType) ? ", Use" : ""%>
210          <%=sc.hasPermission(Permission.WRITE, itemType) ? ", Write" : ""%>
211          <%=sc.hasPermission(Permission.DELETE, itemType) ? ", Delete" : ""%>         
212          </td>
213        </tr>
214      <tr>
215        <th>Description</th>
216        <td><%=HTML.niceFormat(reporter.getDescription())%></td>
217      </tr>
218      </table>
219      </div>
220      <%
221      List<ExtendedProperty> reporterProperties = ExtendedProperties.getProperties("ReporterData");
222      %>
223      <base:section
224        id="extendedProperties"
225        title="<%="Extended properties (" + reporterProperties.size() + ")"%>"
226        context="<%=cc%>"
227        >
228        <table class="fullform fullborder">
229          <%       
230          if (reporterProperties != null)
231          {
232            boolean needsTr = true;
233            for (ExtendedProperty ep : reporterProperties)
234            {
235              String name = ep.getName();
236              Formatter f = FormatterFactory.getExtendedPropertyFormatter(sc, ep);
237              String value = f.format(reporter.getExtended(name));
238              %>
239                <%=needsTr ? "<tr><th>" : "<th class=\"leftborder\">" %>
240                <%=HTML.encodeTags(ep.getTitle())%></th>
241                <td><%=value%></td>
242                <%=needsTr ? "" : "</tr>"%>
243              <%
244              needsTr = !needsTr;
245            }
246            %>
247            <%=needsTr ? "" : "<th class=\"leftborder\"></th><td></td></tr>"%>
248            <%
249          }
250          %>
251        </table>
252      </base:section>
253    </t:tab>
254    </t:tabcontrol>
255
256
257  </base:body>
258  </base:page>
259  <%
260}
261finally
262{
263  if (dc != null) dc.close();
264}
265
266%>
Note: See TracBrowser for help on using the repository browser.