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

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

References #1727: Move to HTML5

  • Remove language="javascript" from <script> tags in all JSP files.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.5 KB
Line 
1<%-- $Id: view_list.jsp 6136 2012-09-18 11:15:20Z 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 == 'overview') && tabId != '<%=tab%>')
144      {
145        location.href = 'index.jsp?ID=<%=ID%>&cmd=ViewItem&item_id=<%=itemId%>&tab='+tabId;
146      }
147      else if (tabId == 'members')
148      {
149        viewMembers();
150      }
151      else
152      {
153        TabControl.setActiveTab(tabControlId, tabId);
154      }
155    }
156    function merge(mergeType)
157    {
158      Main.openPopup('merge.jsp?ID=<%=ID%>&item_id=<%=itemId%>&mergeType='+mergeType, 'Union', 600, 400);
159    }
160    function placeOnPlate()
161    {
162      Main.openPopup('members/index.jsp?ID=<%=ID%>&list_id=<%=itemId%>&cmd=PlaceOnPlate', 'PlaceOnPlate', 900, 600);
163    }
164    </script>
165  </base:head>
166  <base:body>
167    <p:path><p:pathelement 
168      title="Biomaterial lists" href="<%="index.jsp?ID="+ID%>" 
169      /><p:pathelement title="<%=HTML.encodeTags(list.getName())%>"
170      /></p:path>
171   
172    <t:tabcontrol 
173      id="main" 
174      subclass="content mastertabcontrol"
175      active="<%=tab%>" switch="switchTab" remember="false">
176    <t:tab id="properties" title="Properties">
177      <div>
178      <table class="fullform bottomborder">
179      <tr>
180        <th class="itemstatus">
181          <base:icon 
182            image="shared.png" 
183            visible="<%=list.isShared()%>"
184            tooltip="This item is shared to other users, groups and/or projects"
185          />
186          <base:icon 
187            image="deleted.png"
188            onclick="deleteItemPermanently()"
189            tooltip="This item has been flagged for deletion. Click to delete it now."
190            enabled="<%=deletePermanentlyPermission %>"
191            visible="<%=isRemoved%>" 
192          />
193          <base:icon image="used.png" 
194            onclick="showUsingItems()"
195            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
196            visible="<%=isRemoved && isUsed%>" />
197        </th>
198        <td style="padding: 0px;">
199          <tbl:toolbar subclass="bottomborder">
200            <tbl:button 
201              disabled="<%=!writePermission%>" 
202              image="edit.png" 
203              onclick="editItem()" 
204              title="Edit&hellip;" 
205              tooltip="<%=writePermission ? "Edit this list" : "You do not have permission to edit this list"%>" 
206            />
207            <tbl:button 
208              disabled="<%=!deletePermission%>" 
209              image="delete.png" 
210              onclick="deleteItem()" 
211              title="Delete"
212              visible="<%=!list.isRemoved()%>"
213              tooltip="<%=deletePermission ? "Delete this list" : "You do not have permission to delete this list"%>" 
214            />
215            <tbl:button 
216              disabled="<%=!writePermission%>" 
217              image="restore.png" 
218              onclick="restoreItem()" 
219              title="Restore"
220              visible="<%=list.isRemoved()%>"
221              tooltip="<%=writePermission ? "Restore this list" : "You do not have permission to restore this list"%>" 
222            />
223            <tbl:button 
224              disabled="<%=!sharePermission%>"
225              image="share.png"
226              onclick="shareItem()" 
227              title="Share&hellip;" 
228              tooltip="<%=sharePermission ? "Share this list to other user, groups and projects" : "You do not have permission to share this list"%>"
229            />
230            <tbl:button 
231              disabled="<%=!setOwnerPermission%>"
232              image="take_ownership.png"
233              onclick="setOwner()" 
234              title="Set owner&hellip;"
235              tooltip="<%=setOwnerPermission ? "Change owner of this item" : "You do not have permission to change ownership of this item"%>"
236            />
237            <tbl:button 
238              image="place_on_plate.png" 
239              onclick="placeOnPlate()" 
240              title="Place on plate&hellip;" 
241              tooltip="Place the biomaterial in this list on a bioplate" 
242              visible="<%=list.getMemberType() != Item.BIOSOURCE%>"
243            />
244            <tbl:button
245              visible="<%=writePermission%>"
246              image="set_operations/union_small.png"
247              onclick="merge('union')"
248              title="Union&hellip;"
249              tooltip="Add items from other lists to this list"
250            />
251            <tbl:button
252              visible="<%=writePermission%>"
253              image="set_operations/intersection_small.png"
254              onclick="merge('intersection')"
255              title="Intersection&hellip;"
256              tooltip="Keep only items that are present in other lists"
257            />
258            <tbl:button
259              visible="<%=writePermission%>"
260              image="set_operations/complement_small.png"
261              onclick="merge('complement')"
262              title="Complement&hellip;"
263              tooltip="Remove items found in other lists from this list"
264            />
265            <tbl:button 
266              image="import.png" 
267              onclick="runPlugin('ImportItem')" 
268              title="Import&hellip;" 
269              tooltip="Import data" 
270              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
271            />
272            <tbl:button 
273              image="export.png" 
274              onclick="runPlugin('ExportItem')" 
275              title="Export&hellip;" 
276              tooltip="Export data" 
277              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
278            />
279            <tbl:button 
280              image="runplugin.png" 
281              onclick="runPlugin('RunPlugin')" 
282              title="Run plugin&hellip;" 
283              tooltip="Run a plugin" 
284              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
285            />
286            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
287              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
288            <tbl:button
289              image="help.png"
290              onclick="<%="Main.openHelp('" + ID +"', 'biomateriallist.view.properties')"%>"
291              title="Help&hellip;"
292              tooltip="Get help about this page"
293            /> 
294          </tbl:toolbar>
295        </td>
296      </tr>
297      <tr>
298        <th>Name</th>
299        <td><%=HTML.encodeTags(list.getName())%></td>
300      </tr>
301      <tr>
302        <th>Member type</th>
303        <td><%=list.getMemberType()%></td>
304      </tr>
305      <tr>
306        <th>Size</th>
307        <td><%=list.getSize()%></td>
308      </tr>
309      <tr>
310        <th>External ID</th>
311        <td><%=HTML.encodeTags(list.getExternalId())%></td>
312      </tr>
313      <tr>
314        <th>Owner</th>
315        <td><base:propertyvalue item="<%=list%>" property="owner"/></td>
316      </tr>
317      <tr>
318        <th>Permissions</th>
319        <td><%=PermissionUtil.getFullPermissionNames(list)%></td>
320      </tr>
321      <tr>
322        <th>Description</th>
323        <td><%=HTML.niceFormat(list.getDescription())%></td>
324      </tr>
325      </table>
326      </div>
327
328      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
329        <jsp:param name="ID" value="<%=ID%>" />
330        <jsp:param name="item_type" value="<%=itemType.name()%>" />
331        <jsp:param name="item_id" value="<%=itemId%>" />
332        <jsp:param name="title" value="Other items related to this list" />
333      </jsp:include>
334      <jsp:include page="../../common/share/list_share.jsp">
335        <jsp:param name="ID" value="<%=ID%>" />
336        <jsp:param name="item_type" value="<%=itemType.name()%>" />
337        <jsp:param name="item_id" value="<%=itemId%>" />
338        <jsp:param name="title" value="Shared to" />
339      </jsp:include>
340    </t:tab>
341    <t:tab id="members" title="Members" />
342    <t:tab id="overview" title="Overview" 
343      tooltip="Display a tree overview of related items">
344      <%
345      if ("overview".equals(tab))
346      {
347        %>
348        <jsp:include page="../../common/overview/overview.jsp">
349          <jsp:param name="item_type" value="<%=itemType.name()%>" />
350          <jsp:param name="item_id" value="<%=itemId%>" />
351          <jsp:param name="ID" value="<%=ID%>" />
352        </jsp:include>
353        <%
354      }
355      %>
356    </t:tab>     
357    </t:tabcontrol>
358
359  </base:body>
360  </base:page>
361  <%
362}
363finally
364{
365  if (dc != null) dc.close();
366}
367
368%>
Note: See TracBrowser for help on using the repository browser.