source: trunk/www/biomaterials/lists/view_list.jsp @ 6242

Last change on this file since 6242 was 6242, checked in by Nicklas Nordborg, 9 years ago

References #1729 and #1730. Implement lazy loading of 'Item overview' as a tab activation event instead of a page reload.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.3 KB
Line 
1<%-- $Id: view_list.jsp 6242 2013-02-25 09:10:44Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2008 Nicklas Nordborg
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.10
24--%>
25<%@ page pageEncoding="UTF-8" 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.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.Permission"
36  import="net.sf.basedb.core.BioMaterialList"
37  import="net.sf.basedb.core.MultiPermissions"
38  import="net.sf.basedb.core.User"
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.core.query.Orders"
45  import="net.sf.basedb.core.query.Hql"
46  import="net.sf.basedb.clients.web.Base"
47  import="net.sf.basedb.clients.web.PermissionUtil"
48  import="net.sf.basedb.clients.web.util.HTML"
49  import="net.sf.basedb.util.Values"
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.Collections"
56  import="java.util.Map"
57  import="java.util.Set"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
61<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
62<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
63<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
64<%!
65  private static final Item itemType = Item.BIOMATERIALLIST;
66  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
67%>
68<%
69final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
70final String ID = sc.getId();
71final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
72final int itemId = cc.getId();
73final String tab = Values.getString(request.getParameter("tab"), "properties");
74final float scale = Base.getScale(sc);
75final DbControl dc = sc.newDbControl();
76try
77{
78  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
79
80  String title = null;
81  BioMaterialList list = BioMaterialList.getById(dc, itemId);
82 
83  final boolean writePermission = list.hasPermission(Permission.WRITE);
84  final boolean deletePermission = list.hasPermission(Permission.DELETE);
85  final boolean sharePermission = list.hasPermission(Permission.SET_PERMISSION);
86  final boolean usePermission = list.hasPermission(Permission.USE);
87  final boolean setOwnerPermission = list.hasPermission(Permission.SET_OWNER);
88  final boolean isRemoved = list.isRemoved();
89  final boolean isUsed = isRemoved && list.isUsed();
90  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
91  final boolean isOwner = list.isOwner();
92  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, list);
93  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
94  %>
95  <base:page title="<%=title%>">
96  <base:head scripts="table.js,tabcontrol.js" styles="table.css,toolbar.css,headertabcontrol.css,path.css">
97    <ext:scripts context="<%=jspContext%>" />
98    <ext:stylesheets context="<%=jspContext%>" />
99    <script>
100    function editItem()
101    {
102      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
103    }
104    function shareItem()
105    {
106      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=ShareItem&item_id=<%=itemId%>', 'ShareBioMaterialList', 600, 400);
107    }
108    function deleteItem()
109    {
110      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
111    }
112    function restoreItem()
113    {
114      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
115    }
116    function deleteItemPermanently()
117    {
118      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
119    }
120    function itemDeleted()
121    {
122      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
123    }
124    function showUsingItems()
125    {
126      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
127    }
128    function setOwner()
129    {
130      Main.openPopup('index.jsp?ID=<%=ID%>&cmd=SetOwnerOfItem&item_id=<%=itemId%>', 'SetOwnerOfItem', 450, 300);
131    }
132    function runPlugin(cmd)
133    {
134      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
135    }
136    function viewMembers()
137    {
138      location.href = 'members/index.jsp?ID=<%=ID%>&cmd=List&list_id=<%=itemId%>';
139    }
140    function switchTab(tabControlId, tabId)
141    {
142      if (TabControl.isActive(tabControlId, tabId)) return;
143      if (tabId == 'members')
144      {
145        viewMembers();
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    function placeOnPlate()
157    {
158      Main.openPopup('members/index.jsp?ID=<%=ID%>&list_id=<%=itemId%>&cmd=PlaceOnPlate', 'PlaceOnPlate', 900, 600);
159    }
160    </script>
161  </base:head>
162  <base:body>
163    <p:path><p:pathelement 
164      title="Biomaterial lists" href="<%="index.jsp?ID="+ID%>" 
165      /><p:pathelement title="<%=HTML.encodeTags(list.getName())%>"
166      /></p:path>
167   
168    <t:tabcontrol 
169      id="main" 
170      subclass="content mastertabcontrol"
171      active="<%=tab%>" switch="switchTab" remember="false">
172    <t:tab id="properties" title="Properties">
173      <div>
174      <table class="fullform bottomborder">
175      <tr>
176        <th class="itemstatus">
177          <base:icon 
178            image="shared.png" 
179            visible="<%=list.isShared()%>"
180            tooltip="This item is shared to other users, groups and/or projects"
181          />
182          <base:icon 
183            image="deleted.png"
184            onclick="deleteItemPermanently()"
185            tooltip="This item has been flagged for deletion. Click to delete it now."
186            enabled="<%=deletePermanentlyPermission %>"
187            visible="<%=isRemoved%>" 
188          />
189          <base:icon image="used.png" 
190            onclick="showUsingItems()"
191            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
192            visible="<%=isRemoved && isUsed%>" />
193        </th>
194        <td style="padding: 0px;">
195          <tbl:toolbar subclass="bottomborder">
196            <tbl:button 
197              disabled="<%=!writePermission%>" 
198              image="edit.png" 
199              onclick="editItem()" 
200              title="Edit&hellip;" 
201              tooltip="<%=writePermission ? "Edit this list" : "You do not have permission to edit this list"%>" 
202            />
203            <tbl:button 
204              disabled="<%=!deletePermission%>" 
205              image="delete.png" 
206              onclick="deleteItem()" 
207              title="Delete"
208              visible="<%=!list.isRemoved()%>"
209              tooltip="<%=deletePermission ? "Delete this list" : "You do not have permission to delete this list"%>" 
210            />
211            <tbl:button 
212              disabled="<%=!writePermission%>" 
213              image="restore.png" 
214              onclick="restoreItem()" 
215              title="Restore"
216              visible="<%=list.isRemoved()%>"
217              tooltip="<%=writePermission ? "Restore this list" : "You do not have permission to restore this list"%>" 
218            />
219            <tbl:button 
220              disabled="<%=!sharePermission%>"
221              image="share.png"
222              onclick="shareItem()" 
223              title="Share&hellip;" 
224              tooltip="<%=sharePermission ? "Share this list to other user, groups and projects" : "You do not have permission to share this list"%>"
225            />
226            <tbl:button 
227              disabled="<%=!setOwnerPermission%>"
228              image="take_ownership.png"
229              onclick="setOwner()" 
230              title="Set owner&hellip;"
231              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
232            />
233            <tbl:button 
234              image="place_on_plate.png" 
235              onclick="placeOnPlate()" 
236              title="Place on plate&hellip;" 
237              tooltip="Place the biomaterial in this list on a bioplate" 
238              visible="<%=list.getMemberType() != Item.BIOSOURCE%>"
239            />
240            <tbl:button
241              visible="<%=writePermission%>"
242              image="set_operations/union_small.png"
243              onclick="merge('union')"
244              title="Union&hellip;"
245              tooltip="Add items from other lists to this list"
246            />
247            <tbl:button
248              visible="<%=writePermission%>"
249              image="set_operations/intersection_small.png"
250              onclick="merge('intersection')"
251              title="Intersection&hellip;"
252              tooltip="Keep only items that are present in other lists"
253            />
254            <tbl:button
255              visible="<%=writePermission%>"
256              image="set_operations/complement_small.png"
257              onclick="merge('complement')"
258              title="Complement&hellip;"
259              tooltip="Remove items found in other lists from this list"
260            />
261            <tbl:button 
262              image="import.png" 
263              onclick="runPlugin('ImportItem')" 
264              title="Import&hellip;" 
265              tooltip="Import data" 
266              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
267            />
268            <tbl:button 
269              image="export.png" 
270              onclick="runPlugin('ExportItem')" 
271              title="Export&hellip;" 
272              tooltip="Export data" 
273              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
274            />
275            <tbl:button 
276              image="runplugin.png" 
277              onclick="runPlugin('RunPlugin')" 
278              title="Run plugin&hellip;" 
279              tooltip="Run a plugin" 
280              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
281            />
282            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
283              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
284            <tbl:button
285              image="help.png"
286              onclick="<%="Main.openHelp('" + ID +"', 'biomateriallist.view.properties')"%>"
287              title="Help&hellip;"
288              tooltip="Get help about this page"
289            /> 
290          </tbl:toolbar>
291        </td>
292      </tr>
293      <tr>
294        <th>Name</th>
295        <td><%=HTML.encodeTags(list.getName())%></td>
296      </tr>
297      <tr>
298        <th>Member type</th>
299        <td><%=list.getMemberType()%></td>
300      </tr>
301      <tr>
302        <th>Size</th>
303        <td><%=list.getSize()%></td>
304      </tr>
305      <tr>
306        <th>External ID</th>
307        <td><%=HTML.encodeTags(list.getExternalId())%></td>
308      </tr>
309      <tr>
310        <th>Owner</th>
311        <td><base:propertyvalue item="<%=list%>" property="owner"/></td>
312      </tr>
313      <tr>
314        <th>Permissions</th>
315        <td><%=PermissionUtil.getFullPermissionNames(list)%></td>
316      </tr>
317      <tr>
318        <th>Description</th>
319        <td><%=HTML.niceFormat(list.getDescription())%></td>
320      </tr>
321      </table>
322      </div>
323
324      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
325        <jsp:param name="ID" value="<%=ID%>" />
326        <jsp:param name="item_type" value="<%=itemType.name()%>" />
327        <jsp:param name="item_id" value="<%=itemId%>" />
328        <jsp:param name="title" value="Other items related to this list" />
329      </jsp:include>
330      <jsp:include page="../../common/share/list_share.jsp">
331        <jsp:param name="ID" value="<%=ID%>" />
332        <jsp:param name="item_type" value="<%=itemType.name()%>" />
333        <jsp:param name="item_id" value="<%=itemId%>" />
334        <jsp:param name="title" value="Shared to" />
335      </jsp:include>
336    </t:tab>
337    <t:tab id="members" title="Members" />
338    <t:tab id="overview" title="Overview" 
339      tooltip="Display a tree overview of related items"
340      activate="Overview.loadOnce()">
341      <jsp:include page="../../common/overview/overview.jsp">
342        <jsp:param name="item_type" value="<%=itemType.name()%>" />
343        <jsp:param name="item_id" value="<%=itemId%>" />
344        <jsp:param name="ID" value="<%=ID%>" />
345      </jsp:include>
346    </t:tab>     
347    </t:tabcontrol>
348
349  </base:body>
350  </base:page>
351  <%
352}
353finally
354{
355  if (dc != null) dc.close();
356}
357
358%>
Note: See TracBrowser for help on using the repository browser.