source: trunk/www/admin/platforms/view_platform.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: 12.4 KB
Line 
1<%-- $Id: view_platform.jsp 5937 2012-01-27 11:00:26Z 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.Include"
32  import="net.sf.basedb.core.Permission"
33  import="net.sf.basedb.core.Platform"
34  import="net.sf.basedb.core.PlatformVariant"
35  import="net.sf.basedb.core.PlatformFileType"
36  import="net.sf.basedb.core.DataFileType"
37  import="net.sf.basedb.core.RawDataType"
38  import="net.sf.basedb.core.ItemQuery"
39  import="net.sf.basedb.core.ItemResultList"
40  import="net.sf.basedb.core.PermissionDeniedException"
41  import="net.sf.basedb.core.PluginDefinition"
42  import="net.sf.basedb.core.plugin.GuiContext"
43  import="net.sf.basedb.core.plugin.Plugin"
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.formatter.Formatter"
50  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
51  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
52  import="net.sf.basedb.clients.web.extensions.JspContext"
53  import="net.sf.basedb.clients.web.extensions.renderer.PrefixSuffixRenderer"
54  import="net.sf.basedb.clients.web.extensions.toolbar.ToolbarUtil"
55  import="net.sf.basedb.util.extensions.ExtensionsInvoker"
56  import="net.sf.basedb.util.Values"
57  import="java.util.Map"
58  import="java.util.Date"
59%>
60<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
61<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
62<%@ taglib prefix="t" uri="/WEB-INF/tab.tld" %>
63<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
64<%@ taglib prefix="ext" uri="/WEB-INF/extensions.tld" %>
65<%!
66  private static final Item itemType = Item.PLATFORM;
67  private static final GuiContext guiContext = new GuiContext(itemType, GuiContext.Type.ITEM);
68%>
69<%
70final SessionControl sc = Base.getExistingSessionControl(pageContext, true);
71final String ID = sc.getId();
72final ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, null);
73final int itemId = cc.getId();
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  Platform platform = Platform.getById(dc, itemId);
82 
83  final boolean writePermission = platform.hasPermission(Permission.WRITE);
84  final boolean deletePermission = platform.hasPermission(Permission.DELETE);
85  final boolean isRemoved = platform.isRemoved();
86  final boolean isUsed = isRemoved && platform.isUsed();
87  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
88  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, platform);
89  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
90  %>
91  <base:page title="<%=title%>">
92  <base:head scripts="tabcontrol.js,table.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
93    <ext:scripts context="<%=jspContext%>" />
94    <ext:stylesheets context="<%=jspContext%>" />
95    <script language="JavaScript">
96    function editItem()
97    {
98      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
99    }
100    function deleteItem()
101    {
102      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
103    }
104    function restoreItem()
105    {
106      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
107    }
108    function deleteItemPermanently()
109    {
110      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
111    }
112    function itemDeleted()
113    {
114      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
115    }
116    function showUsingItems()
117    {
118      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
119    }
120    function runPlugin(cmd)
121    {
122      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
123    }
124    function newVariant()
125    {
126      Main.viewOrEditItem('<%=ID%>', 'PLATFORMVARIANT', 0, true, '&platform_id=<%=itemId%>');
127    }
128    function viewVariants()
129    {
130      location.href = 'variants/index.jsp?ID=<%=ID%>&cmd=List&platform_id=<%=itemId%>';
131    }
132    function switchTab(tabControlId, tabId)
133    {
134      if (tabId == 'variants')
135      {
136        viewVariants();
137      }
138      else
139      {
140        TabControl.setActiveTab(tabControlId, tabId);
141      }
142    }
143    </script>
144  </base:head>
145  <base:body>
146    <p>
147    <p:path>
148      <p:pathelement title="Platforms" href="<%="index.jsp?ID="+ID%>" />
149      <p:pathelement title="<%=HTML.encodeTags(platform.getName())%>" />
150    </p:path>
151   
152    <t:tabcontrol id="main" active="properties" switch="switchTab">
153    <t:tab id="properties" title="Properties">
154   
155    <tbl:toolbar
156      >
157      <tbl:button 
158        disabled="<%=writePermission ? false : true%>" 
159        image="edit.gif" 
160        onclick="editItem()" 
161        title="Edit&hellip;" 
162        tooltip="<%=writePermission ? "Edit this platform" : "You do not have permission to edit this platform"%>" 
163      />
164      <tbl:button 
165        disabled="<%=deletePermission ? false : true%>" 
166        image="delete.gif" 
167        onclick="deleteItem()" 
168        title="Delete"
169        visible="<%=!platform.isRemoved()%>"
170        tooltip="<%=deletePermission ? "Delete this platform" : "You do not have permission to delete this platform"%>" 
171      />
172      <tbl:button 
173        disabled="<%=writePermission ? false : true%>" 
174        image="restore.gif" 
175        onclick="restoreItem()" 
176        title="Restore"
177        visible="<%=platform.isRemoved()%>"
178        tooltip="<%=writePermission ? "Restore this platform" : "You do not have permission to restore this platform"%>" 
179      />
180      <tbl:button
181        image="add.png"
182        onclick="newVariant()"
183        title="New variant&hellip;"
184        tooltip="Create a new variant of this platform"
185        visible="<%=writePermission%>"
186      />
187      <tbl:button 
188        image="import.gif" 
189        onclick="runPlugin('ImportItem')" 
190        title="Import&hellip;" 
191        tooltip="Import data" 
192        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
193      />
194      <tbl:button 
195        image="export.gif" 
196        onclick="runPlugin('ExportItem')" 
197        title="Export&hellip;" 
198        tooltip="Export data" 
199        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
200      />
201      <tbl:button 
202        image="runplugin.gif" 
203        onclick="runPlugin('RunPlugin')" 
204        title="Run plugin&hellip;" 
205        tooltip="Run a plugin" 
206        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
207      />
208      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
209        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
210      <tbl:button
211        image="help.png"
212        onclick="<%="Main.openHelp('" + ID +"', 'platform.view.properties')"%>"
213        title="Help&hellip;"
214        tooltip="Get help about this page"
215      />
216      </tbl:toolbar>
217    <div class="boxedbottom">
218      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(platform)%></i></div>
219      <%
220      if (platform.isRemoved())
221      {
222        %>
223        <div class="itemstatus">
224          <base:icon 
225            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
226            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
227            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
228            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
229          <base:icon image="used.gif" 
230            onclick="showUsingItems()"
231            tooltip="Show the items that are using this one"
232            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
233        </div>
234        <%
235      }
236      %>
237      <table class="form" cellspacing=0>
238      <tr>
239        <td class="prompt">Name</td>
240        <td><%=HTML.encodeTags(platform.getName())%></td>
241      </tr>
242      <tr>
243        <td class="prompt">External ID</td>
244        <td><%=HTML.encodeTags(platform.getExternalId())%></td>
245      </tr>
246      <tr>
247        <td class="prompt">File-only</td>
248        <td><%=platform.isFileOnly() ? "yes" : "no"%></td>
249      </tr>
250      <%
251      RawDataType rdt = platform.getRawDataType();
252      if (!platform.isFileOnly())
253      {
254        %>
255        <tr>
256          <td class="prompt">Raw data type</td>
257          <td><%=rdt == null ? "<i>- any -</i>" : rdt.getName()%></td>
258        </tr>
259        <%
260      }
261      else
262      {
263        %>
264        <tr>
265          <td class="prompt">Channels</td>
266          <td><%=rdt.getChannels()%></td>
267        </tr>
268        <%
269      }
270      %>
271      <tr >
272        <td class="prompt">Description</td>
273        <td><%=HTML.niceFormat(platform.getDescription())%></td>
274      </tr>
275      </table>
276     
277      <% 
278      ItemQuery<PlatformFileType> fileTypeQuery = platform.getFileTypes(null, false);
279      fileTypeQuery.include(Include.ALL);
280      fileTypeQuery.join(Hql.leftJoin("variant", "var"));
281      fileTypeQuery.order(Orders.asc(Hql.property("var", "name")));
282      fileTypeQuery.order(Orders.asc(Hql.property("dataFileType.name")));
283      ItemResultList<PlatformFileType> fileTypes = fileTypeQuery.list(dc);
284     
285      if (fileTypes.size() == 0)
286      {
287        %>
288        <h4>Data file types</h4>
289        This platform has no associated data file types (or, you don't have permission to view them).
290        <%
291      }
292      else
293      {
294        %>
295        <base:section 
296          id="dataFileTypes"
297          title="<%="Data file types (" + fileTypes.size() + ")"%>"
298          context="<%=cc%>"
299          >       
300          <tbl:table
301            id="fileTypes"
302           
303            columns="all"
304            >
305          <tbl:columndef 
306            id="name"
307            title="Name"
308          />
309          <tbl:columndef 
310            id="variant"
311            title="Variant"
312          />
313          <tbl:columndef 
314            id="required"
315            title="Required"
316          />
317          <tbl:columndef 
318            id="multiple"
319            title="Multiple files"
320          />
321          <tbl:columndef 
322            id="genericType"
323            title="Generic type"
324          />
325          <tbl:columndef 
326            id="description"
327            title="Description"
328          />
329          <tbl:data>
330            <tbl:columns>
331            </tbl:columns>
332            <tbl:rows>
333            <%
334            for (PlatformFileType fileType : fileTypes)
335            {
336              DataFileType dft = fileType.getDataFileType();
337              PlatformVariant variant = fileType.getVariant();
338              %>
339              <tbl:row>
340                <tbl:cell column="variant"><base:icon 
341                    image="deleted.gif" 
342                    tooltip="This item has been scheduled for deletion" 
343                    visible="<%=variant != null && variant.isRemoved()%>"
344                  /><%=variant == null ? "<i>- all -</i>" : Base.getLinkedName(ID, variant, false, true)%></tbl:cell>
345                <tbl:cell column="name"><base:icon 
346                    image="deleted.gif" 
347                    tooltip="This item has been scheduled for deletion" 
348                    visible="<%=dft != null && dft.isRemoved()%>"
349                  /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell>
350                <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell>
351                <tbl:cell column="multiple"><%=fileType.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
352                <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell>
353                <tbl:cell column="description"><%=HTML.niceFormat(dft.getDescription())%></tbl:cell>
354              </tbl:row>
355              <%
356            }
357            %>
358            </tbl:rows>
359          </tbl:data>
360          </tbl:table>
361        </base:section>
362        <%
363      }
364      %>
365      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
366        <jsp:param name="ID" value="<%=ID%>" />
367        <jsp:param name="item_type" value="<%=itemType.name()%>" />
368        <jsp:param name="item_id" value="<%=itemId%>" />
369        <jsp:param name="title" value="Other items related to this platform" />
370      </jsp:include>
371      </div>
372    </t:tab>
373    <t:tab id="variants" title="Variants" 
374      tooltip="View and manage variants of this platform" />
375    </t:tabcontrol>
376  </base:body>
377  </base:page>
378  <%
379}
380finally
381{
382  if (dc != null) dc.close();
383}
384
385%>
Note: See TracBrowser for help on using the repository browser.