source: trunk/www/admin/platforms/variants/view_variant.jsp @ 5937

Last change on this file since 5937 was 5937, checked in by Nicklas Nordborg, 11 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.0 KB
Line 
1<%-- $Id: view_variant.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.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>
129    <p:path>
130      <p:pathelement title="Platforms" href="<%="../index.jsp?ID="+ID%>" />
131      <p:pathelement 
132        title="<%=HTML.encodeTags(platform.getName())%>" 
133        href="<%="index.jsp?ID="+ID+"&platform_id="+platformId%>" />
134      <p:pathelement title="<%=HTML.encodeTags(variant.getName())%>" />
135    </p:path>
136   
137    <t:tabcontrol id="main" active="properties">
138    <t:tab id="properties" title="Properties">
139
140    <tbl:toolbar
141      >
142      <tbl:button 
143        disabled="<%=writePermission ? false : true%>" 
144        image="edit.gif" 
145        onclick="editItem()" 
146        title="Edit&hellip;" 
147        tooltip="<%=writePermission ? "Edit this platform variant" : "You do not have permission to edit this variant"%>" 
148      />
149      <tbl:button 
150        disabled="<%=deletePermission ? false : true%>" 
151        image="delete.gif" 
152        onclick="deleteItem()" 
153        title="Delete"
154        visible="<%=!variant.isRemoved()%>"
155        tooltip="<%=deletePermission ? "Delete this platform variant" : "You do not have permission to delete this platform variant"%>" 
156      />
157      <tbl:button 
158        disabled="<%=writePermission ? false : true%>" 
159        image="restore.gif" 
160        onclick="restoreItem()" 
161        title="Restore"
162        visible="<%=variant.isRemoved()%>"
163        tooltip="<%=writePermission ? "Restore this platform" : "You do not have permission to restore this platform variant"%>" 
164      />
165      <tbl:button 
166        image="import.gif" 
167        onclick="runPlugin('ImportItem')" 
168        title="Import&hellip;" 
169        tooltip="Import data" 
170        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
171      />
172      <tbl:button 
173        image="export.gif" 
174        onclick="runPlugin('ExportItem')" 
175        title="Export&hellip;" 
176        tooltip="Export data" 
177        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
178      />
179      <tbl:button 
180        image="runplugin.gif" 
181        onclick="runPlugin('RunPlugin')" 
182        title="Run plugin&hellip;" 
183        tooltip="Run a plugin" 
184        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
185      />
186      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
187        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
188      <tbl:button
189        image="help.png"
190        onclick="<%="Main.openHelp('" + ID +"', 'platformvariant.view.properties')"%>"
191        title="Help&hellip;"
192        tooltip="Get help about this page"
193      />
194      </tbl:toolbar>
195    <div class="boxedbottom">
196      <div class="itemstatus">Permissions on this item: <i><%=PermissionUtil.getFullPermissionNames(platform)%></i></div>
197      <%
198      if (variant.isRemoved())
199      {
200        %>
201        <div class="itemstatus">
202          <base:icon 
203            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
204            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
205            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
206            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
207          <base:icon image="used.gif" 
208            onclick="showUsingItems()"
209            tooltip="Show the items that are using this one"
210            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
211        </div>
212        <%
213      }
214      %>
215      <table class="form" cellspacing=0>
216      <tr>
217        <td class="prompt">Name</td>
218        <td><%=HTML.encodeTags(variant.getName())%></td>
219      </tr>
220      <tr>
221        <td class="prompt">External ID</td>
222        <td><%=HTML.encodeTags(variant.getExternalId())%></td>
223      </tr>
224      <tr>
225        <td class="prompt">File-only</td>
226        <td><%=variant.isFileOnly() ? "yes" : "no"%></td>
227      </tr>
228      <%
229      RawDataType rdt = variant.getRawDataType();
230      if (!variant.isFileOnly())
231      {
232        %>
233        <tr>
234          <td class="prompt">Raw data type</td>
235          <td><%=rdt == null ? "<i>- any -</i>" : rdt.getName()%></td>
236        </tr>
237        <%
238      }
239      else
240      {
241        %>
242        <tr>
243          <td class="prompt">Channels</td>
244          <td><%=rdt.getChannels()%></td>
245        </tr>
246        <%
247      }
248      %>
249      <tr >
250        <td class="prompt">Description</td>
251        <td><%=HTML.niceFormat(variant.getDescription())%></td>
252      </tr>
253      </table>
254     
255      <% 
256      ItemQuery<PlatformFileType> fileTypeQuery = platform.getFileTypes(variant, false);
257      fileTypeQuery.include(Include.ALL);
258      fileTypeQuery.join(Hql.leftJoin("variant", "var"));
259      fileTypeQuery.order(Orders.asc(Hql.property("var", "name")));
260      fileTypeQuery.order(Orders.asc(Hql.property("dataFileType.name")));
261      ItemResultList<PlatformFileType> fileTypes = fileTypeQuery.list(dc);
262     
263      if (fileTypes.size() == 0)
264      {
265        %>
266        <h4>Data file types</h4>
267        This platform variant has no associated data file types (or, you don't have permission to view them).
268        <%
269      }
270      else
271      {
272        %>
273        <base:section 
274          id="fileTypes"
275          title="<%="Data file type (" + fileTypes.size() + ")"%>"
276          context="<%=cc%>"
277          >       
278          <tbl:table
279            id="fileTypes"
280           
281            columns="all"
282            >
283          <tbl:columndef 
284            id="name"
285            title="Name"
286          />
287          <tbl:columndef 
288            id="variant"
289            title="Variant"
290          />
291          <tbl:columndef 
292            id="required"
293            title="Required"
294          />
295          <tbl:columndef 
296            id="multiple"
297            title="Multiple files"
298          />
299          <tbl:columndef 
300            id="genericType"
301            title="Generic type"
302          />
303          <tbl:columndef 
304            id="description"
305            title="Description"
306          />
307          <tbl:data>
308            <tbl:columns>
309            </tbl:columns>
310            <tbl:rows>
311            <%
312            for (PlatformFileType fileType : fileTypes)
313            {
314              DataFileType dft = fileType.getDataFileType();
315              PlatformVariant thisVariant = fileType.getVariant();
316              %>
317              <tbl:row>
318                <tbl:cell column="variant"><base:icon 
319                    image="deleted.gif" 
320                    tooltip="This item has been scheduled for deletion" 
321                    visible="<%=thisVariant != null && thisVariant.isRemoved()%>"
322                  /><%=thisVariant == null ? "<i>- all -</i>" : Base.getLinkedName(ID, thisVariant, false, true)%></tbl:cell>
323                <tbl:cell column="name"><base:icon 
324                    image="deleted.gif" 
325                    tooltip="This item has been scheduled for deletion" 
326                    visible="<%=dft != null && dft.isRemoved()%>"
327                  /><%=Base.getLinkedName(ID, dft, false, true)%></tbl:cell>
328                <tbl:cell column="required"><%=fileType.isRequired() ? "yes" : "no"%></tbl:cell>
329                <tbl:cell column="multiple"><%=fileType.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
330                <tbl:cell column="genericType"><base:propertyvalue item="<%=dft%>" property="genericType" /></tbl:cell>
331                <tbl:cell column="description"><%=HTML.niceFormat(dft.getDescription())%></tbl:cell>
332              </tbl:row>
333              <%
334            }
335            %>
336            </tbl:rows>
337          </tbl:data>
338          </tbl:table>
339        </base:section>
340        <%
341      }
342      %>
343      <jsp:include page="../../../common/anytoany/list_anytoany.jsp">
344        <jsp:param name="ID" value="<%=ID%>" />
345        <jsp:param name="item_type" value="<%=itemType.name()%>" />
346        <jsp:param name="item_id" value="<%=itemId%>" />
347        <jsp:param name="title" value="Other items related to this variant" />
348      </jsp:include>
349      </div>
350    </t:tab>
351    </t:tabcontrol>
352  </base:body>
353  </base:page>
354  <%
355}
356finally
357{
358  if (dc != null) dc.close();
359}
360
361%>
Note: See TracBrowser for help on using the repository browser.