source: trunk/www/admin/annotationtypecategories/view_category.jsp @ 5941

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

References #1655: GUI improvements

View pages for all items in the Adminstrate menu.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 12.7 KB
Line 
1<%-- $Id: view_category.jsp 5941 2012-02-01 13:26:23Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Nicklas Nordborg, Dominic Oyeniran
4  Copyright (C) 2007 Martin Svensson
5
6  This file is part of BASE - BioArray Software Environment.
7  Available at http://base.thep.lu.se/
8
9  BASE is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License
11  as published by the Free Software Foundation; either version 3
12  of the License, or (at your option) any later version.
13
14  BASE is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  GNU General Public License for more details.
18
19  You should have received a copy of the GNU General Public License
20  along with BASE. If not, see <http://www.gnu.org/licenses/>.
21  ------------------------------------------------------------------
22
23  @author Dominic
24  @version 2.0
25--%>
26<%@ page pageEncoding="UTF-8" session="false"
27  import="net.sf.basedb.core.SessionControl"
28  import="net.sf.basedb.core.DbControl"
29  import="net.sf.basedb.core.Group"
30  import="net.sf.basedb.core.Include"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.ItemQuery"
34  import="net.sf.basedb.core.ItemResultList"
35  import="net.sf.basedb.core.AnnotationTypeCategory"
36  import="net.sf.basedb.core.AnnotationType"
37  import="net.sf.basedb.core.query.Orders"
38  import="net.sf.basedb.core.query.Hql"
39  import="net.sf.basedb.core.MultiPermissions"
40  import="net.sf.basedb.core.Permission"
41  import="net.sf.basedb.core.PermissionDeniedException"
42  import="net.sf.basedb.core.PluginDefinition"
43  import="net.sf.basedb.core.plugin.GuiContext"
44  import="net.sf.basedb.core.plugin.Plugin"
45  import="net.sf.basedb.core.Project"
46  import="net.sf.basedb.core.User"
47  import="net.sf.basedb.clients.web.Base"
48  import="net.sf.basedb.clients.web.PermissionUtil"
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.Collections"
60  import="java.util.Map"
61  import="java.util.Set"
62%>
63<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
64<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
65<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
66<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
67<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
68<%!
69  private static final Item itemType = Item.ANNOTATIONTYPECATEGORY;
70  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
71%>
72<%
73final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
74final String ID = sc.getId();
75final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
76final int itemId = cc.getId();
77final float scale = Base.getScale(sc);
78final DbControl dc = sc.newDbControl();
79try
80{
81  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
82  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
83
84  String title = null;
85  AnnotationTypeCategory annotationTypeCategory = AnnotationTypeCategory.getById(dc, itemId);
86 
87  final boolean writePermission = annotationTypeCategory.hasPermission(Permission.WRITE);
88  final boolean deletePermission = annotationTypeCategory.hasPermission(Permission.DELETE);
89  final boolean sharePermission = annotationTypeCategory.hasPermission(Permission.SET_PERMISSION);
90  final boolean setOwnerPermission = annotationTypeCategory.hasPermission(Permission.SET_OWNER);
91  final boolean isOwner = annotationTypeCategory.isOwner();
92  final boolean isRemoved = annotationTypeCategory.isRemoved();
93  final boolean isUsed = isRemoved && annotationTypeCategory.isUsed();
94  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
95  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, annotationTypeCategory);
96  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
97  %>
98  <base:page title="<%=title%>">
99  <base:head scripts="tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
100    <ext:scripts context="<%=jspContext%>" />
101    <ext:stylesheets context="<%=jspContext%>" />
102    <script language="JavaScript">
103    function editItem()
104    {
105      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
106    }
107    function shareItem()
108    {
109      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareAnnotationTypeCategory', 600, 400);
110    }
111    function deleteItem()
112    {
113      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
114    }
115    function deleteItemPermanently()
116    {
117      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
118    }
119    function itemDeleted()
120    {
121      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
122    }
123    function showUsingItems()
124    {
125      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
126    }
127    function restoreItem()
128    {
129      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
130    }
131    function setOwner()
132    {
133      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
134    }
135    function runPlugin(cmd)
136    {
137      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
138    }
139    </script>
140  </base:head>
141  <base:body>
142    <p:path><p:pathelement 
143      title="Annotation type categories" href="<%="index.jsp?ID="+ID%>" 
144      /><p:pathelement title="<%=HTML.encodeTags(annotationTypeCategory.getName())%>" 
145      /></p:path>
146   
147    <t:tabcontrol 
148      id="main" 
149      subclass="content mastertabcontrol" 
150      active="properties">
151    <t:tab id="properties" title="Properties">
152      <div>
153      <table class="fullform bottomborder">
154      <tr>
155        <th class="itemstatus">
156          <base:icon 
157            image="shared.gif" 
158            visible="<%=annotationTypeCategory.isShared()%>"
159            tooltip="This item is shared to other users, groups and/or projects"
160          />
161          <base:icon 
162            image="deleted.gif"
163            onclick="deleteItemPermanently()"
164            tooltip="This item has been flagged for deletion. Click to delete it now."
165            enabled="<%=deletePermanentlyPermission %>"
166            visible="<%=isRemoved%>" 
167          />
168          <base:icon image="used.gif" 
169            onclick="showUsingItems()"
170            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
171            visible="<%=isRemoved && isUsed%>" />
172        </th>
173        <td style="padding: 0px;">
174          <tbl:toolbar subclass="bottomborder">
175            <tbl:button 
176              disabled="<%=writePermission ? false : true%>" 
177              image="edit.gif" 
178              onclick="editItem()" 
179              title="Edit&hellip;" 
180              tooltip="<%=writePermission ? "Edit this category" : "You do not have permission to edit this category"%>" 
181            />
182            <tbl:button 
183              disabled="<%=deletePermission ? false : true%>" 
184              image="delete.gif" 
185              onclick="deleteItem()" 
186              title="Delete"
187              visible="<%=!annotationTypeCategory.isRemoved()%>"
188              tooltip="<%=deletePermission ? "Delete this category" : "You do not have permission to delete this category"%>" 
189            />
190            <tbl:button 
191              disabled="<%=writePermission ? false : true%>" 
192              image="restore.gif" 
193              onclick="restoreItem()" 
194              title="Restore"
195              visible="<%=annotationTypeCategory.isRemoved()%>"
196              tooltip="<%=writePermission ? "Restore this category" : "You do not have permission to restore this category"%>" 
197            />
198            <tbl:button 
199              disabled="<%=sharePermission ? false : true%>"
200              image="share.gif"
201              onclick="shareItem()" 
202              title="Share&hellip;" 
203              tooltip="<%=sharePermission ? "Share this annotation type category to other user, groups and projects" : "You do not have permission to share this annotation type"%>"
204            />
205            <tbl:button 
206              disabled="<%=setOwnerPermission ? false : true%>"
207              image="take_ownership.png"
208              onclick="setOwner()" 
209              title="Set owner&hellip;"
210              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change owner of this item"%>"
211            />
212            <tbl:button 
213              image="import.gif" 
214              onclick="runPlugin('ImportItem')" 
215              title="Import&hellip;" 
216              tooltip="Import data" 
217              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
218            />
219            <tbl:button 
220              image="export.gif" 
221              onclick="runPlugin('ExportItem')" 
222              title="Export&hellip;" 
223              tooltip="Export data" 
224              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
225            />
226            <tbl:button 
227              image="runplugin.gif" 
228              onclick="runPlugin('RunPlugin')" 
229              title="Run plugin&hellip;" 
230              tooltip="Run a plugin" 
231              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
232            />
233            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
234              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
235            <tbl:button
236              image="help.png"
237              onclick="<%="Main.openHelp('" + ID +"', 'annotationtypecategory.view.properties')"%>"
238              title="Help&hellip;"
239              tooltip="Get help about this page"
240            />
241          </tbl:toolbar>
242        </td>
243      </tr>
244      <tr>
245        <th>Name</th>
246        <td><%=HTML.encodeTags(annotationTypeCategory.getName())%></td>
247      </tr>
248      <tr>
249        <th>Registered</th>
250        <td><%=dateFormatter.format(annotationTypeCategory.getEntryDate())%></td>
251      </tr>
252      <tr>
253        <th>Owner</th>
254        <td><base:propertyvalue item="<%=annotationTypeCategory%>" property="owner" /></td>
255      </tr>
256      <tr>
257        <th>Permissions</th>
258        <td><%=PermissionUtil.getFullPermissionNames(annotationTypeCategory)%></td>
259      </tr>
260      <tr>
261        <th>Description</th>
262        <td><%=HTML.niceFormat(annotationTypeCategory.getDescription())%></td>
263      </tr>
264      </table>
265      </div>
266     
267      <%
268      ItemQuery<AnnotationType> annotationTypeQuery = annotationTypeCategory.getAnnotationTypes(null);
269      annotationTypeQuery.include(Include.ALL);
270      annotationTypeQuery.order(Orders.asc(Hql.property("name")));
271      ItemResultList<AnnotationType> annotationTypes = annotationTypeQuery.list(dc);
272      %>
273      <base:section
274        id="annotationTypes"
275        title="<%="Annotation types (" + annotationTypes.size() + ")"%>"
276        context="<%=cc%>"
277        >
278        <%
279        if (annotationTypes.size() == 0)
280        {
281          %>
282          <div class="messagecontainer note">
283          There are no annotation types in this category (or, you don't have permission to view them).
284          </div>
285          <%
286        }
287        else
288        {
289          %>
290          <tbl:table
291            id="members"
292            columns="all"
293            >
294          <tbl:columndef 
295            id="name"
296            title="Name"
297          />
298          <tbl:columndef 
299            id="valuetype"
300            title="Value Type"
301          />
302          <tbl:columndef 
303            id="description"
304            title="Description"
305          />
306          <tbl:columndef 
307            id="requiredForMiame"
308            title="Required For Miame"
309          />
310          <tbl:data>
311            <tbl:headers>
312              <tbl:headerrow>
313                <tbl:columnheaders />
314              </tbl:headerrow>
315            </tbl:headers>
316            <tbl:rows>
317            <%
318            for (AnnotationType annotationType : annotationTypes)
319            {
320              %>
321              <tbl:row>
322                <tbl:cell column="name"><base:icon 
323                    image="deleted.gif" 
324                    tooltip="This item has been scheduled for deletion" 
325                    visible="<%=annotationType.isRemoved()%>"
326                  /><%=Base.getLinkedName(ID, annotationType, false, true)%></tbl:cell>
327                <tbl:cell column="valuetype"><%=annotationType.getValueType()%></tbl:cell>
328                <tbl:cell column="description"><%=HTML.encodeTags(annotationType.getDescription())%></tbl:cell>
329                <tbl:cell column="requiredForMiame"><%=annotationType.isRequiredForMiame() ? "yes" : "no"%></tbl:cell>
330              </tbl:row>
331              <%
332            }
333            %>
334            </tbl:rows>
335          </tbl:data>
336        </tbl:table>
337        <%
338      }
339      %>
340      </base:section>
341      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
342        <jsp:param name="ID" value="<%=ID%>" />
343        <jsp:param name="item_type" value="<%=itemType.name()%>" />
344        <jsp:param name="item_id" value="<%=itemId%>" />
345        <jsp:param name="title" value="Other items related to this category" />
346      </jsp:include>
347      <jsp:include page="../../common/share/list_share.jsp">
348        <jsp:param name="ID" value="<%=ID%>" />
349        <jsp:param name="item_type" value="<%=itemType.name()%>" />
350        <jsp:param name="item_id" value="<%=itemId%>" />
351        <jsp:param name="title" value="Shared to" />
352      </jsp:include>
353    </t:tab>
354    </t:tabcontrol>
355
356  </base:body>
357  </base:page>
358  <%
359}
360finally
361{
362  if (dc != null) dc.close();
363}
364
365%>
Note: See TracBrowser for help on using the repository browser.