source: trunk/www/lims/geometries/view_geometry.jsp @ 5942

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

References #1655: GUI improvements

Modify lots of boolean taglib parameters.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 10.7 KB
Line 
1<%-- $Id: view_geometry.jsp 5942 2012-02-01 14:12:59Z nicklas $
2  ------------------------------------------------------------------
3  Copyright (C) 2006 Jari Häkkinen, Nicklas Nordborg, Martin Svensson
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.0
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.Item"
30  import="net.sf.basedb.core.ItemContext"
31  import="net.sf.basedb.core.Permission"
32  import="net.sf.basedb.core.PlateGeometry"
33  import="net.sf.basedb.core.PlateType"
34  import="net.sf.basedb.core.ItemQuery"
35  import="net.sf.basedb.core.Include"
36  import="net.sf.basedb.core.ItemResultList"
37  import="net.sf.basedb.core.PermissionDeniedException"
38  import="net.sf.basedb.core.PluginDefinition"
39  import="net.sf.basedb.core.plugin.GuiContext"
40  import="net.sf.basedb.core.plugin.Plugin"
41  import="net.sf.basedb.core.query.Orders"
42  import="net.sf.basedb.core.query.Hql"
43  import="net.sf.basedb.clients.web.Base"
44  import="net.sf.basedb.clients.web.PermissionUtil"
45  import="net.sf.basedb.clients.web.util.HTML"
46  import="net.sf.basedb.util.Values"
47  import="net.sf.basedb.util.formatter.Formatter"
48  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
49  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
50  import="net.sf.basedb.clients.web.extensions.JspContext"
51  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
52  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
53  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
54  import="java.util.Date"
55  import="java.util.Map"
56  import="java.util.Set"
57  import="java.util.List"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
61<%@ taglib prefix="tbl" uri="/WEB-INF/table.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.PLATEGEOMETRY;
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 float scale = Base.getScale(sc);
74final DbControl dc = sc.newDbControl();
75try
76{
77  Formatter<Date> dateFormatter = FormatterFactory.getDateFormatter(sc);
78  Map<Plugin.MainType, Integer> pluginCount = PluginDefinition.countPlugins(dc, guiContext);
79
80  String title = null;
81  PlateGeometry geometry = PlateGeometry.getById(dc, itemId);
82 
83  final boolean usePermission = geometry.hasPermission(Permission.USE);
84  final boolean writePermission = geometry.hasPermission(Permission.WRITE);
85  final boolean deletePermission = geometry.hasPermission(Permission.DELETE);
86  final boolean sharePermission = geometry.hasPermission(Permission.SET_PERMISSION);
87  final boolean isRemoved = geometry.isRemoved();
88  final boolean isUsed = isRemoved && geometry.isUsed();
89  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
90  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, geometry);
91  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
92  %>
93  <base:page title="<%=title%>">
94  <base:head scripts="table.js,tabcontrol.js" styles="toolbar.css,table.css,headertabcontrol.css,path.css">
95    <ext:scripts context="<%=jspContext%>" />
96    <ext:stylesheets context="<%=jspContext%>" />
97    <script language="JavaScript">
98    function editItem()
99    {
100      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
101    }
102    function deleteItem()
103    {
104      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
105    }
106    function restoreItem()
107    {
108      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
109    }
110    function deleteItemPermanently()
111    {
112      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
113    }
114    function itemDeleted()
115    {
116      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
117    }
118    function showUsingItems()
119    {
120      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
121    }
122    function runPlugin(cmd)
123    {
124      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
125    }
126    function newPlateType()
127    {
128      Main.viewOrEditItem('<%=ID%>', 'PLATETYPE', 0, true, '&plategeometry_id=<%=itemId%>');
129    }
130    </script>
131  </base:head>
132  <base:body>
133    <p>
134    <p:path>
135      <p:pathelement title="Plate geometries" href="<%="index.jsp?ID="+ID%>" />
136      <p:pathelement title="<%=HTML.encodeTags(geometry.getName())%>" />
137    </p:path>
138   
139    <t:tabcontrol id="main" active="properties">
140    <t:tab id="properties" title="Properties">
141   
142    <tbl:toolbar
143      >
144      <tbl:button 
145        disabled="<%=!writePermission%>" 
146        image="edit.gif" 
147        onclick="editItem()" 
148        title="Edit&hellip;" 
149        tooltip="<%=writePermission ? "Edit this plate geometry" : "You do not have permission to edit this plate geometry"%>" 
150      />
151      <tbl:button 
152        disabled="<%=!deletePermission%>" 
153        image="delete.gif" 
154        onclick="deleteItem()" 
155        title="Delete"
156        visible="<%=!geometry.isRemoved()%>"
157        tooltip="<%=deletePermission ? "Delete this plate geometry" : "You do not have permission to delete this plate geometry"%>" 
158      />
159      <tbl:button 
160        disabled="<%=!writePermission%>" 
161        image="restore.gif" 
162        onclick="restoreItem()" 
163        title="Restore"
164        visible="<%=geometry.isRemoved()%>"
165        tooltip="<%=writePermission ? "Restore this plate geometry" : "You do not have permission to restore this plate geometry"%>" 
166      />
167      <tbl:button
168        image="add.png"
169        onclick="newPlateType()"
170        title="New plate type&hellip;"
171        tooltip="Create a new plate type with this geometry"
172        visible="<%=sc.hasPermission(Permission.CREATE, Item.PLATETYPE) && usePermission%>"
173      />
174      <tbl:button 
175        image="import.gif" 
176        onclick="runPlugin('ImportItem')" 
177        title="Import&hellip;" 
178        tooltip="Import data" 
179        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
180      />
181      <tbl:button 
182        image="export.gif" 
183        onclick="runPlugin('ExportItem')" 
184        title="Export&hellip;" 
185        tooltip="Export data" 
186        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
187      />
188      <tbl:button 
189        image="runplugin.gif" 
190        onclick="runPlugin('RunPlugin')" 
191        title="Run plugin&hellip;" 
192        tooltip="Run a plugin" 
193        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
194      />
195      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
196        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
197      <tbl:button
198        image="help.png"
199        onclick="<%="Main.openHelp('" + ID +"', 'plategeometry.view.properties')"%>"
200        title="Help&hellip;"
201        tooltip="Get help about this page"
202      />
203      </tbl:toolbar>
204    <div class="boxedbottom">
205      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(geometry)%></i></div>
206      <%
207      if (geometry.isRemoved())
208      {
209        %>
210        <div class="itemstatus">
211          <base:icon 
212            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
213            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
214            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
215            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
216          <base:icon image="used.gif" 
217            onclick="showUsingItems()"
218            tooltip="Show the items that are using this one"
219            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
220        </div>
221        <%
222      }
223      %>
224      <table class="form" cellspacing=0>
225      <tr>
226        <td class="prompt">Name</td>
227        <td><%=HTML.encodeTags(geometry.getName())%></td>
228      </tr>
229      <tr>
230        <td class="prompt">Registered</td>
231        <td><%=dateFormatter.format(geometry.getEntryDate())%></td>
232      </tr>
233      <tr>
234        <td class="prompt">Rows</td>
235        <td><%=geometry.getRows()%></td>
236      </tr>
237      <tr>
238        <td class="prompt">Columns</td>
239        <td><%=geometry.getColumns()%></td>
240      </tr>
241      <tr>
242        <td class="prompt">Description</td>
243        <td><%=HTML.niceFormat(geometry.getDescription())%></td>
244      </tr>
245      </table>
246
247      <%
248      ItemQuery<PlateType> plateTypeQuery = geometry.getPlateTypes();
249      plateTypeQuery.include(Include.ALL);
250      plateTypeQuery.order(Orders.asc(Hql.property("name")));
251      ItemResultList<PlateType> plateTypes = plateTypeQuery.list(dc);
252      if (plateTypes.size() == 0)
253      {
254        %>
255        <h4>Plate types</h4>
256        No plate types have this geometry
257        (or, you don't have permission to view them).
258        <%
259      }
260      else
261      {
262        %>
263        <base:section 
264          id="types" 
265          title="<%="Plate types (" + plateTypes.size() + ")"%>"
266          context="<%=cc%>"
267          >
268          <tbl:table
269            id="plateTypes"
270           
271            columns="all"
272            >
273          <tbl:columndef 
274            id="name"
275            title="Name"
276          />
277          <tbl:columndef 
278            id="description"
279            title="Description"
280          />
281          <tbl:data>
282            <tbl:columns>
283            </tbl:columns>
284            <tbl:rows>
285            <%
286            for (PlateType item : plateTypes)
287            {
288              %>
289              <tbl:row>
290                <tbl:cell column="name"><base:icon 
291                    image="deleted.gif" 
292                    tooltip="This item has been scheduled for deletion" 
293                    visible="<%=item.isRemoved()%>"
294                  /><%=Base.getLinkedName(ID, item, false, true)%></tbl:cell>
295                <tbl:cell column="description"><%=HTML.encodeTags(item.getDescription())%></tbl:cell>
296              </tbl:row>
297              <%
298            }
299            %>
300            </tbl:rows>
301          </tbl:data>
302          </tbl:table>
303        </base:section>
304        <%
305      }
306      %>
307      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
308        <jsp:param name="ID" value="<%=ID%>" />
309        <jsp:param name="item_type" value="<%=itemType.name()%>" />
310        <jsp:param name="item_id" value="<%=itemId%>" />
311        <jsp:param name="title" value="Other items related to this geometry" />
312      </jsp:include>
313    </div>
314      </t:tab>
315      </t:tabcontrol>
316
317
318  </base:body>
319  </base:page>
320  <%
321}
322finally
323{
324  if (dc != null) dc.close();
325}
326
327%>
Note: See TracBrowser for help on using the repository browser.