source: trunk/www/admin/softwaretypes/view_softwaretype.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 Date Id
File size: 8.1 KB
Line 
1<%-- $Id: view_softwaretype.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.SoftwareType"
36  import="net.sf.basedb.core.Software"
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.SOFTWARETYPE;
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  SoftwareType softwareType = SoftwareType.getById(dc, itemId);
80 
81  final boolean usePermission = softwareType.hasPermission(Permission.USE);
82  final boolean writePermission = softwareType.hasPermission(Permission.WRITE);
83  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, softwareType);
84  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
85  %>
86  <base:page title="<%=title%>">
87  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
88    <ext:scripts context="<%=jspContext%>" />
89    <ext:stylesheets context="<%=jspContext%>" />
90    <script language="JavaScript">
91    function editItem()
92    {
93      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
94    }
95    function runPlugin(cmd)
96    {
97      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 740, 540);
98    }
99    function newSoftware()
100    {
101      Main.viewOrEditItem('<%=ID%>', 'SOFTWARE', 0, true, '&softwaretype_id=<%=itemId%>');
102    }
103    </script>
104  </base:head>
105  <base:body>
106    <p>
107    <p:path>
108      <p:pathelement title="Software types" href="<%="index.jsp?ID="+ID%>" />
109      <p:pathelement title="<%=HTML.encodeTags(softwareType.getName())%>" />
110    </p:path>
111   
112    <t:tabcontrol id="main" active="properties">
113    <t:tab id="properties" title="Properties">
114   
115    <tbl:toolbar
116      >
117      <tbl:button 
118        disabled="<%=writePermission ? false : true%>" 
119        image="<%=writePermission ? "edit.gif" : "edit_disabled.gif"%>" 
120        onclick="editItem()" 
121        title="Edit&hellip;" 
122        tooltip="<%=writePermission ? "Edit this software type" : "You do not have permission to edit this software type"%>" 
123      />
124      <tbl:button
125        image="add.png"
126        onclick="newSoftware()"
127        title="New software&hellip;"
128        tooltip="Create a new software of this type"
129        visible="<%=sc.hasPermission(Permission.CREATE, Item.SOFTWARE) && usePermission%>"
130      />
131      <tbl:button 
132        image="export.gif" 
133        onclick="runPlugin('ExportItem')" 
134        title="Export&hellip;" 
135        tooltip="Export data" 
136        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
137      />
138      <tbl:button 
139        image="runplugin.gif" 
140        onclick="runPlugin('RunPlugin')" 
141        title="Run plugin&hellip;" 
142        tooltip="Run a plugin" 
143        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
144      />
145      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
146        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
147      <tbl:button
148        image="help.gif"
149        onclick="<%="Main.openHelp('" + ID +"', 'softwaretype.view.properties')"%>"
150        title="Help&hellip;"
151        tooltip="Get help about this page"
152      />
153      </tbl:toolbar>
154    <div class="boxedbottom">
155      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(softwareType)%></i></div>
156      <table class="form" cellspacing=0>
157      <tr>
158        <td class="prompt">Name</td>
159        <td><%=HTML.encodeTags(softwareType.getName())%></td>
160      </tr>
161      <tr>
162        <td class="prompt">Registered</td>
163        <td><%=dateFormatter.format(softwareType.getEntryDate())%></td>
164      </tr>
165      <tr>
166        <td class="prompt">System ID</td>
167        <td><%=HTML.encodeTags(softwareType.getSystemId())%></td>
168      </tr>
169      <tr>
170        <td class="prompt">Description</td>
171        <td><%=HTML.niceFormat(softwareType.getDescription())%></td>
172      </tr>
173      </table>
174
175      <%
176      ItemQuery<Software> softwareQuery = softwareType.getSoftware();
177      softwareQuery.include(Include.ALL);
178      softwareQuery.order(Orders.asc(Hql.property("name")));
179      ItemResultList<Software> software = softwareQuery.list(dc);
180      if (software.size() == 0)
181      {
182        %>
183        <h4>Software</h4>
184        No software of this type exists
185        (or, you don't have permission to view them).
186        <%
187      }
188      else
189      {
190        %>
191        <base:section
192          id="software"
193          title="<%="Software (" + software.size() + ")"%>"
194          context="<%=cc%>"
195          >
196          <tbl:table
197            id="software"
198            clazz="itemlist"
199            columns="all"
200            >
201          <tbl:columndef 
202            id="name"
203            title="Name"
204          />
205          <tbl:columndef
206            id="version"
207            title="Version"
208          />
209          <tbl:columndef 
210            id="description"
211            title="Description"
212          />
213          <tbl:data>
214            <tbl:columns>
215            </tbl:columns>
216            <tbl:rows>
217            <%
218            for (Software item : software)
219            {
220              %>
221              <tbl:row>
222                <tbl:cell column="name"><base:icon 
223                    image="deleted.gif" 
224                    tooltip="This item has been scheduled for deletion" 
225                    visible="<%=item.isRemoved()%>"
226                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
227                <tbl:cell column="version"><%=HTML.encodeTags(item.getVersionString())%></tbl:cell>
228                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
229              </tbl:row>
230              <%
231            }
232            %>
233            </tbl:rows>
234          </tbl:data>
235          </tbl:table>
236        </base:section>
237        <%
238      }
239      %>
240    </div>
241      </t:tab>
242      </t:tabcontrol>
243
244  </base:body>
245  </base:page>
246  <%
247}
248finally
249{
250  if (dc != null) dc.close();
251}
252
253%>
Note: See TracBrowser for help on using the repository browser.