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

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

References #1655: GUI improvements

  • Fixes rest of view pages in biomaterials menu.
  • Use SVG filter to make disabled button images grayscale.
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id
File size: 15.4 KB
Line 
1<%-- $Id: view_category.jsp 5937 2012-01-27 11:00:26Z 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>
143    <p:path>
144      <p:pathelement title="Annotation type categories" href="<%="index.jsp?ID="+ID%>" />
145      <p:pathelement title="<%=HTML.encodeTags(annotationTypeCategory.getName())%>" />
146    </p:path>
147   
148    <t:tabcontrol id="main" active="properties">
149    <t:tab id="properties" title="Properties">
150   
151    <tbl:toolbar
152      >
153      <tbl:button 
154        disabled="<%=writePermission ? false : true%>" 
155        image="edit.gif" 
156        onclick="editItem()" 
157        title="Edit&hellip;" 
158        tooltip="<%=writePermission ? "Edit this category" : "You do not have permission to edit this category"%>" 
159      />
160      <tbl:button 
161        disabled="<%=deletePermission ? false : true%>" 
162        image="delete.gif" 
163        onclick="deleteItem()" 
164        title="Delete"
165        visible="<%=!annotationTypeCategory.isRemoved()%>"
166        tooltip="<%=deletePermission ? "Delete this category" : "You do not have permission to delete this category"%>" 
167      />
168      <tbl:button 
169        disabled="<%=writePermission ? false : true%>" 
170        image="restore.gif" 
171        onclick="restoreItem()" 
172        title="Restore"
173        visible="<%=annotationTypeCategory.isRemoved()%>"
174        tooltip="<%=writePermission ? "Restore this category" : "You do not have permission to restore this category"%>" 
175      />
176      <tbl:button 
177        disabled="<%=sharePermission ? false : true%>"
178        image="share.gif"
179        onclick="shareItem()" 
180        title="Share&hellip;" 
181        tooltip="<%=sharePermission ? "Share this annotation type category to other user, groups and projects" : "You do not have permission to share this annotation type"%>"
182      />
183      <tbl:button 
184        disabled="<%=setOwnerPermission ? false : true%>"
185        image="take_ownership.png"
186        onclick="setOwner()" 
187        title="Set owner&hellip;"
188        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change owner of this item"%>"
189      />
190      <tbl:button 
191        image="import.gif" 
192        onclick="runPlugin('ImportItem')" 
193        title="Import&hellip;" 
194        tooltip="Import data" 
195        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
196      />
197      <tbl:button 
198        image="export.gif" 
199        onclick="runPlugin('ExportItem')" 
200        title="Export&hellip;" 
201        tooltip="Export data" 
202        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
203      />
204      <tbl:button 
205        image="runplugin.gif" 
206        onclick="runPlugin('RunPlugin')" 
207        title="Run plugin&hellip;" 
208        tooltip="Run a plugin" 
209        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
210      />
211      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
212        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
213      <tbl:button
214        image="help.png"
215        onclick="<%="Main.openHelp('" + ID +"', 'annotationtypecategory.view.properties')"%>"
216        title="Help&hellip;"
217        tooltip="Get help about this page"
218      />
219      </tbl:toolbar>
220    <div class="boxedbottom">
221      <%
222      if (annotationTypeCategory.isRemoved() || annotationTypeCategory.isShared())
223      {
224        %>
225        <div class="itemstatus">
226          <base:icon 
227            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
228            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
229            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
230            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
231          <base:icon image="used.gif" 
232            onclick="showUsingItems()"
233            tooltip="Show the items that are using this one"
234            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
235          <base:icon image="shared.gif" 
236            visible="<%=annotationTypeCategory.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
237        </div>
238        <%
239      }
240      %>
241      <table class="form" cellspacing=0>
242      <tr>
243        <td class="prompt">Name</td>
244        <td><%=HTML.encodeTags(annotationTypeCategory.getName())%></td>
245      </tr>
246      <tr>
247        <td class="prompt">Registered</td>
248        <td><%=dateFormatter.format(annotationTypeCategory.getEntryDate())%></td>
249      </tr>
250      <tr>
251        <td class="prompt">Description</td>
252        <td><%=HTML.niceFormat(annotationTypeCategory.getDescription())%></td>
253      </tr>
254     
255      <tr>
256        <td class="prompt">Owner</td>
257        <td><base:propertyvalue item="<%=annotationTypeCategory%>" property="owner" /></td>
258      </tr>
259      </table>
260     
261      <%
262        ItemQuery<AnnotationType> annotationTypeQuery = annotationTypeCategory.getAnnotationTypes(null);
263        annotationTypeQuery.include(Include.ALL);
264        annotationTypeQuery.order(Orders.asc(Hql.property("name")));
265        ItemResultList<AnnotationType> annotationTypes = annotationTypeQuery.list(dc);
266     
267      if (annotationTypes.size() == 0)
268      {
269        %>
270        <h4>Annotation types</h4>
271        There are no annotation types in this category (or, you don't have permission to view them).
272        <%
273      }
274      else
275      {
276        %>
277        <base:section
278          id="annotationTypes"
279          title="<%="Annotation types (" + annotationTypes.size() + ")"%>"
280          context="<%=cc%>"
281          >
282          <tbl:table
283            id="members"
284           
285            columns="all"
286            >
287          <tbl:columndef 
288            id="name"
289            title="Name"
290          />
291          <tbl:columndef 
292            id="valuetype"
293            title="Value Type"
294          />
295          <tbl:columndef 
296            id="description"
297            title="Description"
298          />
299          <tbl:columndef 
300            id="requiredForMiame"
301            title="Required For Miame"
302          />
303         
304          <tbl:data>
305            <tbl:columns>
306            </tbl:columns>
307            <tbl:rows>
308            <%
309            for (AnnotationType annotationType : annotationTypes)
310            {
311              %>
312              <tbl:row>
313                <tbl:cell column="name"><base:icon 
314                    image="deleted.gif" 
315                    tooltip="This item has been scheduled for deletion" 
316                    visible="<%=annotationType.isRemoved()%>"
317                  /><%=Base.getLinkedName(ID, annotationType, false, true)%></tbl:cell>
318                <tbl:cell column="valuetype"><%=annotationType.getValueType()%></tbl:cell>
319                <tbl:cell column="description"><%=HTML.encodeTags(annotationType.getDescription())%></tbl:cell>
320                <tbl:cell column="requiredForMiame"><%=annotationType.isRequiredForMiame() ? "yes" : "no"%></tbl:cell>
321              </tbl:row>
322              <%
323            }
324            %>
325            </tbl:rows>
326          </tbl:data>
327          </tbl:table>
328        </base:section>
329        <%
330      }
331      %>
332      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
333        <jsp:param name="ID" value="<%=ID%>" />
334        <jsp:param name="item_type" value="<%=itemType.name()%>" />
335        <jsp:param name="item_id" value="<%=itemId%>" />
336        <jsp:param name="title" value="Other items related to this category" />
337      </jsp:include>
338      <%
339      // Tables with users/groups/projects that this item is shared to
340      MultiPermissions mp = new MultiPermissions(Collections.singleton(annotationTypeCategory));
341      ItemResultList<User> users = mp.getUsers().list(dc);
342      ItemResultList<Group> groups = mp.getGroups().list(dc);
343      ItemResultList<Project> projects = mp.getProjects().list(dc);
344      int totalShare = users.size() + groups.size() + projects.size();
345     
346      if (totalShare > 0)
347      {
348        %>
349        <base:section 
350          id="sharedTo" 
351          title="<%="Shared to (" + totalShare + ")"%>"
352          context="<%=cc%>"
353          >
354          <tbl:table 
355            id="itemsSharedTo"
356           
357            columns="all"
358          >
359            <tbl:columndef 
360              id="itemType"
361              title="Item type"
362            />
363            <tbl:columndef 
364              id="name"
365              title="Name"
366            />
367            <tbl:columndef 
368              id="permissions"
369              title="Permissions"
370            />
371            <tbl:data>
372              <tbl:columns>
373              </tbl:columns>
374              <tbl:rows>
375              <%
376              for (Project project : projects)
377              {
378                Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
379                %>     
380                <tbl:row>
381                  <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
382                  <tbl:cell column="name"><base:icon 
383                    image="deleted.gif" 
384                    tooltip="This item has been scheduled for deletion" 
385                    visible="<%=project.isRemoved()%>"
386                  /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
387                  <tbl:cell column="permissions">
388                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
389                  </tbl:cell>
390                </tbl:row>
391                <%
392              }
393              for (Group group : groups)
394              {
395                Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
396                %>
397                <tbl:row>             
398                  <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
399                  <tbl:cell column="name"><base:icon 
400                    image="deleted.gif" 
401                    tooltip="This item has been scheduled for deletion" 
402                    visible="<%=group.isRemoved()%>"
403                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
404                  <tbl:cell column="permissions">
405                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
406                  </tbl:cell>
407                </tbl:row>
408                <% 
409              }
410              for (User user : users)
411              {
412                Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
413                %>
414                <tbl:row>             
415                  <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
416                  <tbl:cell column="name"><base:icon 
417                    image="deleted.gif" 
418                    tooltip="This item has been scheduled for deletion" 
419                    visible="<%=user.isRemoved()%>"
420                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
421                  <tbl:cell column="permissions">
422                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
423                  </tbl:cell>
424                </tbl:row>
425                <%
426              }
427              %>
428              </tbl:rows>
429            </tbl:data>
430          </tbl:table>
431        </base:section>
432        <%
433      }
434      else
435      {
436        %>
437        <h4>Shared to</h4>
438        This annotation type category is not shared
439        (or, you don't have permission to view the ones it is shared to).
440        <%
441      }
442      %>
443
444    </div>
445      </t:tab>
446      </t:tabcontrol>
447
448  </base:body>
449  </base:page>
450  <%
451}
452finally
453{
454  if (dc != null) dc.close();
455}
456
457%>
Note: See TracBrowser for help on using the repository browser.