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