source: trunk/www/views/reporterlists/view_reporterlist.jsp @ 5937

Last change on this file since 5937 was 5937, checked in by Nicklas Nordborg, 10 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:keywords set to Date Id
File size: 14.8 KB
Line 
1<%-- $Id: view_reporterlist.jsp 5937 2012-01-27 11:00:26Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Nicklas Nordborg, Martin Svensson
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 modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 3 of the License, or
12  (at your option) any later version.
13 
14  BASE is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  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 Nicklas
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.SystemItems"
30  import="net.sf.basedb.core.Group"
31  import="net.sf.basedb.core.Item"
32  import="net.sf.basedb.core.ItemContext"
33  import="net.sf.basedb.core.ItemResultList"
34  import="net.sf.basedb.core.Permission"
35  import="net.sf.basedb.core.ReporterList"
36  import="net.sf.basedb.core.User"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.MultiPermissions"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.plugin.GuiContext"
42  import="net.sf.basedb.core.plugin.Plugin"
43  import="net.sf.basedb.core.Project"
44  import="net.sf.basedb.clients.web.Base"
45  import="net.sf.basedb.clients.web.PermissionUtil"
46  import="net.sf.basedb.clients.web.util.HTML"
47  import="net.sf.basedb.util.Values"
48  import="net.sf.basedb.util.formatter.Formatter"
49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
50  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
51  import="net.sf.basedb.clients.web.extensions.JspContext"
52  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
53  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
54  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
55  import="java.util.Date"
56  import="java.util.Collections"
57  import="java.util.List"
58  import="java.util.Map"
59  import="java.util.Set"
60%>
61<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
62<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
63<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
64<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
65<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
66<%!
67  private static final Item itemType = Item.REPORTERLIST;
68  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
69%>
70<%
71final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
72final String ID = sc.getId();
73final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
74final int itemId = cc.getId();
75final float scale = Base.getScale(sc);
76final DbControl dc = sc.newDbControl();
77try
78{
79  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
80  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
81
82  String title = null;
83  final ReporterList reporterList = ReporterList.getById(dc, itemId);
84 
85  final boolean writePermission = reporterList.hasPermission(Permission.WRITE);
86  final boolean deletePermission = reporterList.hasPermission(Permission.DELETE);
87  final boolean sharePermission = reporterList.hasPermission(Permission.SET_PERMISSION);
88  final boolean setOwnerPermission = reporterList.hasPermission(Permission.SET_OWNER);
89  final boolean isRemoved = reporterList.isRemoved();
90  final boolean isUsed = isRemoved && reporterList.isUsed();
91  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
92  final boolean isOwner = reporterList.isOwner();
93  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, reporterList);
94  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
95  %>
96  <base:page title="<%=title%>">
97  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
98    <ext:scripts context="<%=jspContext%>" />
99    <ext:stylesheets context="<%=jspContext%>" />
100    <script language="JavaScript">
101    function editItem()
102    {
103      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
104    }
105    function shareItem()
106    {
107      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareReporterList', 600, 400);
108    }
109    function deleteItem()
110    {
111      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
112    }
113    function restoreItem()
114    {
115      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
116    }
117    function deleteItemPermanently()
118    {
119      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
120    }
121    function itemDeleted()
122    {
123      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
124    }
125    function showUsingItems()
126    {
127      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
128    }
129    function setOwner()
130    {
131      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
132    }
133    function runPlugin(cmd)
134    {
135      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
136    }
137    function viewReporters()
138    {
139      location.href = 'reporters/index.jsp?ID=<%=ID%>&cmd=List&reporterlist_id=<%=itemId%>';
140    }
141    function switchTab(tabControlId, tabId)
142    {
143      if (tabId == 'reporters')
144      {
145        viewReporters();
146      }
147      else
148      {
149        TabControl.setActiveTab(tabControlId, tabId);
150      }
151    }
152    function merge(mergeType)
153    {
154      Main.openPopup('merge.jsp?ID=<%=ID%>&item_id=<%=itemId%>&mergeType='+mergeType, 'Union', 600, 400);
155    }
156    </script>
157  </base:head>
158  <base:body>
159    <p>
160    <p:path>
161      <p:pathelement title="Reporter lists" href="<%="index.jsp?ID="+ID%>" />
162      <p:pathelement title="<%=HTML.encodeTags(reporterList.getName())%>" />
163    </p:path>
164   
165    <t:tabcontrol id="main" active="properties" switch="switchTab">
166    <t:tab id="properties" title="Properties">
167    <tbl:toolbar
168      >
169      <tbl:button 
170        disabled="<%=writePermission ? false : true%>" 
171        image="edit.gif" 
172        onclick="editItem()" 
173        title="Edit&hellip;" 
174        tooltip="<%=writePermission ? "Edit this reporter list" : "You do not have permission to edit this reporter list"%>" 
175      />
176      <tbl:button 
177        disabled="<%=deletePermission ? false : true%>" 
178        image="delete.gif" 
179        onclick="deleteItem()" 
180        title="Delete"
181        visible="<%=!reporterList.isRemoved()%>"
182        tooltip="<%=deletePermission ? "Delete this reporter list" : "You do not have permission to delete this reporter list"%>" 
183      />
184      <tbl:button 
185        disabled="<%=writePermission ? false : true%>" 
186        image="restore.gif" 
187        onclick="restoreItem()" 
188        title="Restore"
189        visible="<%=reporterList.isRemoved()%>"
190        tooltip="<%=writePermission ? "Restore this reporter list" : "You do not have permission to restore this reporter list"%>" 
191      />
192      <tbl:button 
193        disabled="<%=sharePermission ? false : true%>"
194        image="share.gif"
195        onclick="shareItem()" 
196        title="Share&hellip;" 
197        tooltip="<%=sharePermission ? "Share this reporter list to other user, groups and projects" : "You do not have permission to share this formula"%>"
198      />
199      <tbl:button 
200        disabled="<%=setOwnerPermission ? false : true%>"
201        image="take_ownership.png"
202        onclick="setOwner()" 
203        title="Set owner&hellip;"
204        tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
205      />
206      <tbl:button
207        visible="<%=writePermission%>"
208        image="set_operations/union_small.png"
209        onclick="merge('union')"
210        title="Union&hellip;"
211        tooltip="Add reporters from other lists to this list"
212      />
213      <tbl:button
214        visible="<%=writePermission%>"
215        image="set_operations/intersection_small.png"
216        onclick="merge('intersection')"
217        title="Intersection&hellip;"
218        tooltip="Keep only reporters that are present in other lists"
219      />
220      <tbl:button
221        visible="<%=writePermission%>"
222        image="set_operations/complement_small.png"
223        onclick="merge('complement')"
224        title="Complement&hellip;"
225        tooltip="Remove reporters in other lists from this list"
226      />
227      <tbl:button 
228        image="import.gif" 
229        onclick="runPlugin('ImportItem')" 
230        title="Import&hellip;" 
231        tooltip="Import data" 
232        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
233      />
234      <tbl:button 
235        image="export.gif" 
236        onclick="runPlugin('ExportItem')" 
237        title="Export&hellip;" 
238        tooltip="Export data" 
239        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
240      />
241      <tbl:button 
242        image="runplugin.gif" 
243        onclick="runPlugin('RunPlugin')" 
244        title="Run plugin&hellip;" 
245        tooltip="Run a plugin" 
246        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
247      />
248      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
249        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
250      <tbl:button
251        image="help.png"
252        onclick="<%="Main.openHelp('" + ID +"', 'reporterlist.view.properties')"%>"
253        title="Help&hellip;"
254        tooltip="Get help about this page"
255      />
256      </tbl:toolbar>
257    <div class="boxedbottom">
258      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(reporterList)%></i></div>
259      <%
260      if (reporterList.isRemoved() || reporterList.isShared())
261      {
262        %>
263        <div class="itemstatus">
264          <base:icon 
265            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
266            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
267            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
268            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
269          <base:icon image="used.gif" 
270            onclick="showUsingItems()"
271            tooltip="Show the items that are using this one"
272            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
273          <base:icon image="shared.gif" 
274            visible="<%=reporterList.isShared()%>"> This item is shared to other users, groups and/or projects</base:icon>
275        </div>
276        <%
277      }
278      %>
279      <table class="form" cellspacing="0">
280      <tr>
281        <td class="prompt">Name</td>
282        <td><%=HTML.encodeTags(reporterList.getName())%></td>
283      </tr>
284      <tr>
285        <td class="prompt">Registered</td>
286        <td><%=dateFormatter.format(reporterList.getEntryDate())%></td>
287      </tr>
288      <tr>
289        <td class="prompt">External ID</td>
290        <td><%=HTML.encodeTags(reporterList.getExternalId())%></td>
291      </tr>
292      <tr>
293        <td class="prompt">Size</td>
294        <td><%=reporterList.getSize()%></td>
295      </tr>
296      <tr>
297        <td class="prompt">Experiment</td>
298        <td><base:propertyvalue item="<%=reporterList%>" property="experiment" /></td>
299      </tr>
300      <tr>
301        <td class="prompt">Owner</td>
302        <td><base:propertyvalue item="<%=reporterList%>" property="owner" /></td>
303      </tr>
304      <tr>
305        <td class="prompt">Description</td>
306        <td><%=HTML.niceFormat(reporterList.getDescription())%></td>
307      </tr>
308      </table>
309      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
310        <jsp:param name="ID" value="<%=ID%>" />
311        <jsp:param name="item_type" value="<%=itemType.name()%>" />
312        <jsp:param name="item_id" value="<%=itemId%>" />
313        <jsp:param name="title" value="Other items related to this reporter list" />
314      </jsp:include>
315      <%
316      // Tables with users/groups/projects that this item is shared to
317      MultiPermissions mp = new MultiPermissions(Collections.singleton(reporterList));
318      ItemResultList<User> users = mp.getUsers().list(dc);
319      ItemResultList<Group> groups = mp.getGroups().list(dc);
320      ItemResultList<Project> projects = mp.getProjects().list(dc);
321      int totalShare = users.size() + groups.size() + projects.size();
322     
323      if (totalShare > 0)
324      {
325        %>
326        <base:section
327          id="sharedTo"
328          title="<%="Shared to (" + totalShare + ")"%>"
329          context="<%=cc%>"
330          >
331          <tbl:table 
332            id="itemsSharedTo"
333           
334            columns="all"
335          >
336            <tbl:columndef 
337              id="itemType"
338              title="Item type"
339            />
340            <tbl:columndef 
341              id="name"
342              title="Name"
343            />
344            <tbl:columndef 
345              id="permissions"
346              title="Permissions"
347            />
348            <tbl:data>
349              <tbl:columns>
350              </tbl:columns>
351              <tbl:rows>
352              <%
353              for (Project project : projects)
354              {
355                Set<Permission> permissions = mp.getPermissions(project).values().iterator().next();
356                %>     
357                <tbl:row>
358                  <tbl:cell column="itemType"><%=project.getType()%></tbl:cell>
359                  <tbl:cell column="name"><base:icon 
360                    image="deleted.gif" 
361                    tooltip="This item has been scheduled for deletion" 
362                    visible="<%=project.isRemoved()%>"
363                  /><%=Base.getLinkedName(ID, project, false, true)%></tbl:cell>
364                  <tbl:cell column="permissions">
365                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
366                  </tbl:cell>
367                </tbl:row>
368                <%
369              }
370              for (Group group : groups)
371              {
372                Set<Permission> permissions = mp.getPermissions(group).values().iterator().next();
373                %>
374                <tbl:row>             
375                  <tbl:cell column="itemType"><%=group.getType()%></tbl:cell>
376                  <tbl:cell column="name"><base:icon 
377                    image="deleted.gif" 
378                    tooltip="This item has been scheduled for deletion" 
379                    visible="<%=group.isRemoved()%>"
380                  /><%=Base.getLinkedName(ID, group, false, true)%></tbl:cell>
381                  <tbl:cell column="permissions">
382                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
383                  </tbl:cell>
384                </tbl:row>
385                <% 
386              }
387              for (User user : users)
388              {
389                Set<Permission> permissions = mp.getPermissions(user).values().iterator().next();
390                %>
391                <tbl:row>             
392                  <tbl:cell column="itemType"><%=user.getType()%></tbl:cell>
393                  <tbl:cell column="name"><base:icon 
394                    image="deleted.gif" 
395                    tooltip="This item has been scheduled for deletion" 
396                    visible="<%=user.isRemoved()%>"
397                  /><%=Base.getLinkedName(ID, user, false, true)%></tbl:cell>
398                  <tbl:cell column="permissions">
399                    <%=PermissionUtil.translatePermissionsToString(permissions)%>
400                  </tbl:cell>
401                </tbl:row>
402                <%
403              }
404              %>
405              </tbl:rows>
406            </tbl:data>
407          </tbl:table>
408        </base:section>
409        <%
410      }
411      else
412      {
413        %>
414        <h4>Shared to</h4>
415        This reporter list is not shared
416        (or, you don't have permission to view the ones it is shared to).
417        <%
418      }
419      %>
420
421    </div>
422    </t:tab>
423   
424    <t:tab id="reporters" title="Reporters" 
425      tooltip="List the reporters in this reporter list" />
426   
427    </t:tabcontrol>
428
429  </base:body>
430  </base:page>
431  <%
432}
433finally
434{
435  if (dc != null) dc.close();
436}
437
438%>
Note: See TracBrowser for help on using the repository browser.