source: trunk/www/admin/protocoltypes/view_protocoltype.jsp @ 5042

Last change on this file since 5042 was 5042, checked in by Martin Svensson, 13 years ago

References #360 Covering the submenu items in 'Administrate' menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.5 KB
Line 
1<%-- $Id: view_protocoltype.jsp 5042 2009-08-11 10:48:42Z martin $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, 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  @author Nicklas
23  @version 2.0
24--%>
25<%@ page session="false"
26  import="net.sf.basedb.core.SessionControl"
27  import="net.sf.basedb.core.DbControl"
28  import="net.sf.basedb.core.SystemItems"
29  import="net.sf.basedb.core.Include"
30  import="net.sf.basedb.core.Item"
31  import="net.sf.basedb.core.ItemContext"
32  import="net.sf.basedb.core.ItemQuery"
33  import="net.sf.basedb.core.ItemResultList"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.ProtocolType"
36  import="net.sf.basedb.core.Protocol"
37  import="net.sf.basedb.core.PermissionDeniedException"
38  import="net.sf.basedb.core.PluginDefinition"
39  import="net.sf.basedb.core.plugin.GuiContext"
40  import="net.sf.basedb.core.plugin.Plugin"
41  import="net.sf.basedb.core.query.Orders"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.PermissionUtil"
45  import="net.sf.basedb.clients.web.util.HTML"
46  import="net.sf.basedb.util.Values"
47  import="net.sf.basedb.util.formatter.Formatter"
48  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
49  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
50  import="net.sf.basedb.clients.web.extensions.JspContext"
51  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
52  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
53  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
54  import="java.util.Date"
55  import="java.util.Map"
56%>
57<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
58<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
59<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
60<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
61<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
62<%!
63  private static final Item itemType = Item.PROTOCOLTYPE;
64  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
65%>
66<%
67final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
68final String ID = sc.getId();
69final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
70final int itemId = cc.getId();
71final float scale = Base.getScale(sc);
72final DbControl dc = sc.newDbControl();
73try
74{
75  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
76  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
77
78  String title = null;
79  ProtocolType protocolType = ProtocolType.getById(dc, itemId);
80 
81  final boolean usePermission = protocolType.hasPermission(Permission.USE);
82  final boolean writePermission = protocolType.hasPermission(Permission.WRITE);
83  final boolean deletePermission = protocolType.hasPermission(Permission.DELETE);
84  final boolean isRemoved = protocolType.isRemoved();
85  final boolean isUsed = isRemoved && protocolType.isUsed();
86  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
87  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, protocolType);
88  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
89  %>
90  <base:page title="<%=title%>">
91  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
92    <ext:scripts context="<%=jspContext%>" />
93    <ext:stylesheets context="<%=jspContext%>" />
94    <script language="JavaScript">
95    function editItem()
96    {
97      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
98    }
99    function deleteItem()
100    {
101      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
102    }
103    function restoreItem()
104    {
105      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
106    }
107    function deleteItemPermanently()
108    {
109      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
110    }
111    function itemDeleted()
112    {
113      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
114    }
115    function showUsingItems()
116    {
117      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
118    }
119    function runPlugin(cmd)
120    {
121      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
122    }
123    function newProtocol()
124    {
125      Main.viewOrEditItem('<%=ID%>', 'PROTOCOL', 0, true, '&protocoltype_id=<%=itemId%>');
126    }
127    </script>
128  </base:head>
129  <base:body>
130    <p>
131    <p:path>
132      <p:pathelement title="Protocol types" href="<%="index.jsp?ID="+ID%>" />
133      <p:pathelement title="<%=HTML.encodeTags(protocolType.getName())%>" />
134    </p:path>
135   
136    <t:tabcontrol id="main" active="properties">
137    <t:tab id="properties" title="Properties">
138   
139    <tbl:toolbar
140      >
141      <tbl:button 
142        disabled="<%=writePermission ? false : true%>" 
143        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
144        onclick="editItem()" 
145        title="Edit&hellip;" 
146        tooltip="<%=writePermission ? "Edit this protocol type" : "You do not have permission to edit this protocoltype"%>" 
147      />
148      <tbl:button 
149        disabled="<%=deletePermission ? false : true%>" 
150        image="<%=deletePermission ? "delete.gif" : "delete_disabled.gif"%>" 
151        onclick="deleteItem()" 
152        title="Delete"
153        visible="<%=!protocolType.isRemoved()%>"
154        tooltip="<%=deletePermission ? "Delete this protocol type" : "You do not have permission to delete this protocol type"%>" 
155      />
156      <tbl:button 
157        disabled="<%=writePermission ? false : true%>" 
158        image="<%=writePermission ? "restore.gif" : "restore_disabled.gif"%>" 
159        onclick="restoreItem()" 
160        title="Restore"
161        visible="<%=protocolType.isRemoved()%>"
162        tooltip="<%=writePermission ? "Restore this protocol type" : "You do not have permission to restore this protocol type"%>" 
163      />
164      <tbl:button
165        image="add.png"
166        onclick="newProtocol()"
167        title="New protocol&hellip;"
168        tooltip="Create a new protocol of this type"
169        visible="<%=sc.hasPermission(Permission.CREATE, Item.PROTOCOL) && usePermission%>"
170      />
171      <tbl:button 
172        image="import.gif" 
173        onclick="runPlugin('ImportItem')" 
174        title="Import&hellip;" 
175        tooltip="Import data" 
176        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
177      />
178      <tbl:button 
179        image="export.gif" 
180        onclick="runPlugin('ExportItem')" 
181        title="Export&hellip;" 
182        tooltip="Export data" 
183        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
184      />
185      <tbl:button 
186        image="runplugin.gif" 
187        onclick="runPlugin('RunPlugin')" 
188        title="Run plugin&hellip;" 
189        tooltip="Run a plugin" 
190        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
191      />
192      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
193        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
194      <tbl:button
195        image="help.gif"
196        onclick="<%="Main.openHelp('" + ID +"', 'protocoltype.view.properties')"%>"
197        title="Help&hellip;"
198        tooltip="Get help about this page"
199      />
200      </tbl:toolbar>
201    <div class="boxedbottom">
202      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(protocolType)%></i></div>
203      <%
204      if (protocolType.isRemoved())
205      {
206        %>
207        <div class="itemstatus">
208          <base:icon 
209            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
210            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
211            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
212            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
213          <base:icon image="used.gif" 
214            onclick="showUsingItems()"
215            tooltip="Show the items that are using this one"
216            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
217        </div>
218        <%
219      }
220      %>
221      <table class="form" cellspacing=0>
222      <tr>
223        <td class="prompt">Name</td>
224        <td><%=HTML.encodeTags(protocolType.getName())%></td>
225      </tr>
226      <tr>
227        <td class="prompt">Registered</td>
228        <td><%=dateFormatter.format(protocolType.getEntryDate())%></td>
229      </tr>
230      <tr>
231        <td class="prompt">System ID</td>
232        <td><%=HTML.encodeTags(protocolType.getSystemId())%></td>
233      </tr>
234      <tr>
235        <td class="prompt">Description</td>
236        <td><%=HTML.niceFormat(protocolType.getDescription())%></td>
237      </tr>
238      </table>
239     
240      <%
241      ItemQuery<Protocol> protocolQuery = protocolType.getProtocols();
242      protocolQuery.include(Include.ALL);
243      protocolQuery.order(Orders.asc(Hql.property("name")));
244      ItemResultList<Protocol> protocols = protocolQuery.list(dc);
245      if (protocols.size() == 0)
246      {
247        %>
248        <h4>Protocols</h4>
249        No protocols of this type exists
250        (or, you don't have permission to view them).
251        <%
252      }
253      else
254      {
255        %>
256        <base:section 
257          id="protocols" 
258          title="<%="Protocols (" + protocols.size() + ")"%>"
259          context="<%=cc%>"
260          >
261          <tbl:table
262            id="protocols"
263            clazz="itemlist"
264            columns="all"
265            >
266          <tbl:columndef 
267            id="name"
268            title="Name"
269          />
270          <tbl:columndef
271            id="file"
272            title="File"
273          />
274          <tbl:columndef 
275            id="description"
276            title="Description"
277          />
278          <tbl:data>
279            <tbl:columns>
280            </tbl:columns>
281            <tbl:rows>
282            <%
283            for (Protocol item : protocols)
284            {
285              %>
286              <tbl:row>
287                <tbl:cell column="name"><base:icon 
288                    image="deleted.gif" 
289                    tooltip="This item has been scheduled for deletion" 
290                    visible="<%=item.isRemoved()%>"
291                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
292                <tbl:cell column="file"><base:propertyvalue item="<%=item%>" property="file" /></tbl:cell>
293                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
294              </tbl:row>
295              <%
296            }
297            %>
298            </tbl:rows>
299          </tbl:data>
300          </tbl:table>
301        </base:section>
302        <%
303      }
304      %>     
305     
306    </div>
307      </t:tab>
308      </t:tabcontrol>
309
310  </base:body>
311  </base:page>
312  <%
313}
314finally
315{
316  if (dc != null) dc.close();
317}
318
319%>
Note: See TracBrowser for help on using the repository browser.