source: trunk/www/admin/platforms/view_platform.jsp @ 5941

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

References #1655: GUI improvements

View pages for all items in the Adminstrate menu.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Id
File size: 12.5 KB
Line 
1<%-- $Id: view_platform.jsp 5941 2012-02-01 13:26:23Z 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:path><p:pathelement 
147      title="Platforms" href="<%="index.jsp?ID="+ID%>"
148      /><p:pathelement title="<%=HTML.encodeTags(platform.getName())%>" 
149      /></p:path>
150   
151    <t:tabcontrol 
152      id="main" 
153      subclass="content mastertabcontrol" 
154      active="properties" switch="switchTab">
155    <t:tab id="properties" title="Properties">
156      <div>
157      <table class="fullform bottomborder">
158      <tr>
159        <th class="itemstatus">
160          <base:icon 
161            image="deleted.gif"
162            onclick="deleteItemPermanently()"
163            tooltip="This item has been flagged for deletion. Click to delete it now."
164            enabled="<%=deletePermanentlyPermission %>"
165            visible="<%=isRemoved%>" 
166          />
167          <base:icon image="used.gif" 
168            onclick="showUsingItems()"
169            tooltip="This item is used by other items and can't be permanently deleted. Show the items that are using this one"
170            visible="<%=isRemoved && isUsed%>" />
171        </th>
172        <td style="padding: 0px;">
173          <tbl:toolbar subclass="bottomborder">
174            <tbl:button 
175              disabled="<%=writePermission ? false : true%>" 
176              image="edit.gif" 
177              onclick="editItem()" 
178              title="Edit&hellip;" 
179              tooltip="<%=writePermission ? "Edit this platform" : "You do not have permission to edit this platform"%>" 
180            />
181            <tbl:button 
182              disabled="<%=deletePermission ? false : true%>" 
183              image="delete.gif" 
184              onclick="deleteItem()" 
185              title="Delete"
186              visible="<%=!platform.isRemoved()%>"
187              tooltip="<%=deletePermission ? "Delete this platform" : "You do not have permission to delete this platform"%>" 
188            />
189            <tbl:button 
190              disabled="<%=writePermission ? false : true%>" 
191              image="restore.gif" 
192              onclick="restoreItem()" 
193              title="Restore"
194              visible="<%=platform.isRemoved()%>"
195              tooltip="<%=writePermission ? "Restore this platform" : "You do not have permission to restore this platform"%>" 
196            />
197            <tbl:button
198              image="add.png"
199              onclick="newVariant()"
200              title="New variant&hellip;"
201              tooltip="Create a new variant of this platform"
202              visible="<%=writePermission%>"
203            />
204            <tbl:button 
205              image="import.gif" 
206              onclick="runPlugin('ImportItem')" 
207              title="Import&hellip;" 
208              tooltip="Import data" 
209              visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
210            />
211            <tbl:button 
212              image="export.gif" 
213              onclick="runPlugin('ExportItem')" 
214              title="Export&hellip;" 
215              tooltip="Export data" 
216              visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
217            />
218            <tbl:button 
219              image="runplugin.gif" 
220              onclick="runPlugin('RunPlugin')" 
221              title="Run plugin&hellip;" 
222              tooltip="Run a plugin" 
223              visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
224            />
225            <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
226              wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
227            <tbl:button
228              image="help.png"
229              onclick="<%="Main.openHelp('" + ID +"', 'platform.view.properties')"%>"
230              title="Help&hellip;"
231              tooltip="Get help about this page"
232            />
233          </tbl:toolbar>
234        </td>
235      </tr>
236      <tr>
237        <th>Name</th>
238        <td><%=HTML.encodeTags(platform.getName())%></td>
239      </tr>
240      <tr>
241        <th>External ID</th>
242        <td><%=HTML.encodeTags(platform.getExternalId())%></td>
243      </tr>
244      <tr>
245        <th>File-only</th>
246        <td><%=platform.isFileOnly() ? "yes" : "no"%></td>
247      </tr>
248      <%
249      RawDataType rdt = platform.getRawDataType();
250      if (!platform.isFileOnly())
251      {
252        %>
253        <tr>
254          <th class="subprompt">raw data type</th>
255          <td><%=rdt == null ? "<i>- any -</i>" : rdt.getName()%></td>
256        </tr>
257        <%
258      }
259      else
260      {
261        %>
262        <tr>
263          <th class="subprompt">- channels</th>
264          <td><%=rdt.getChannels()%></td>
265        </tr>
266        <%
267      }
268      %>
269      <tr>
270        <th>Permissions</th>
271        <td><%=PermissionUtil.getFullPermissionNames(platform)%></td>
272      </tr>
273      <tr >
274        <th>Description</th>
275        <td><%=HTML.niceFormat(platform.getDescription())%></td>
276      </tr>
277      </table>
278      </div>
279     
280      <% 
281      ItemQuery<PlatformFileType> fileTypeQuery = platform.getFileTypes(null, false);
282      fileTypeQuery.include(Include.ALL);
283      fileTypeQuery.join(Hql.leftJoin("variant", "var"));
284      fileTypeQuery.order(Orders.asc(Hql.property("var", "name")));
285      fileTypeQuery.order(Orders.asc(Hql.property("dataFileType.name")));
286      ItemResultList<PlatformFileType> fileTypes = fileTypeQuery.list(dc);
287      %>
288      <base:section 
289        id="dataFileTypes"
290        title="<%="Data file types (" + fileTypes.size() + ")"%>"
291        context="<%=cc%>"
292        >
293        <%
294        if (fileTypes.size() == 0)
295        {
296          %>
297          <div class="messagecontainer note">
298          This platform has no associated data file types (or, you don't have permission to view them).
299          </div>
300          <%
301        }
302        else
303        {
304          %>
305          <tbl:table
306            id="fileTypes"
307            columns="all"
308            >
309          <tbl:columndef 
310            id="name"
311            title="Name"
312          />
313          <tbl:columndef 
314            id="variant"
315            title="Variant"
316          />
317          <tbl:columndef 
318            id="required"
319            title="Required"
320          />
321          <tbl:columndef 
322            id="multiple"
323            title="Multiple files"
324          />
325          <tbl:columndef 
326            id="genericType"
327            title="Generic type"
328          />
329          <tbl:columndef 
330            id="description"
331            title="Description"
332          />
333          <tbl:data>
334            <tbl:headers>
335              <tbl:headerrow>
336                <tbl:columnheaders />
337              </tbl:headerrow>
338            </tbl:headers>
339            <tbl:rows>
340            <%
341            for (PlatformFileType fileType : fileTypes)
342            {
343              DataFileType dft = fileType.getDataFileType();
344              PlatformVariant variant = fileType.getVariant();
345              %>
346              <tbl:row>
347                <tbl:cell column="variant"><base:icon 
348                    image="deleted.gif" 
349                    tooltip="This item has been scheduled for deletion" 
350                    visible="<%=variant != null && variant.isRemoved()%>"
351                  /><%=variant == null ? "<i>- all -</i>" : Base.getLinkedName(ID, variant, false, true)%></tbl:cell>
352                <tbl:cell column="name"><base:icon 
353                    image="deleted.gif" 
354                    tooltip="This item has been scheduled for deletion" 
355                    visible="<%=dft != null && dft.isRemoved()%>"
356                  /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell>
357                <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell>
358                <tbl:cell column="multiple"><%=fileType.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
359                <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell>
360                <tbl:cell column="description"><%=HTML.niceFormat(dft.getDescription())%></tbl:cell>
361              </tbl:row>
362              <%
363            }
364            %>
365            </tbl:rows>
366          </tbl:data>
367          </tbl:table>
368          <%
369        }
370        %>
371      </base:section>
372      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
373        <jsp:param name="ID" value="<%=ID%>" />
374        <jsp:param name="item_type" value="<%=itemType.name()%>" />
375        <jsp:param name="item_id" value="<%=itemId%>" />
376        <jsp:param name="title" value="Other items related to this platform" />
377      </jsp:include>
378    </t:tab>
379    <t:tab id="variants" title="Variants" 
380      tooltip="View and manage variants of this platform" />
381    </t:tabcontrol>
382  </base:body>
383  </base:page>
384  <%
385}
386finally
387{
388  if (dc != null) dc.close();
389}
390
391%>
Note: See TracBrowser for help on using the repository browser.