source: trunk/www/admin/datafiletypes/view_filetype.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: 10.9 KB
Line 
1<%-- $Id:view_filetype.jsp 3820 2007-10-12 10:03:18Z 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.DataFileType"
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.Include"
37  import="net.sf.basedb.core.ItemQuery"
38  import="net.sf.basedb.core.ItemResultList"
39  import="net.sf.basedb.core.PermissionDeniedException"
40  import="net.sf.basedb.core.PluginDefinition"
41  import="net.sf.basedb.core.plugin.GuiContext"
42  import="net.sf.basedb.core.plugin.Plugin"
43  import="net.sf.basedb.core.query.Orders"
44  import="net.sf.basedb.core.query.Hql"
45  import="net.sf.basedb.clients.web.Base"
46  import="net.sf.basedb.clients.web.PermissionUtil"
47  import="net.sf.basedb.clients.web.util.HTML"
48  import="net.sf.basedb.util.formatter.Formatter"
49  import="net.sf.basedb.clients.web.formatter.FormatterFactory"
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="net.sf.basedb.util.Values"
56  import="java.util.Map"
57  import="java.util.Date"
58%>
59<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
60<%@ taglib prefix="tbl" uri="/WEB-INF/table.tld" %>
61<%@ taglib prefix="t" uri="/WEB-INF/tab.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.DATAFILETYPE;
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  DataFileType fileType = DataFileType.getById(dc, itemId);
81 
82  final boolean writePermission = fileType.hasPermission(Permission.WRITE);
83  final boolean deletePermission = fileType.hasPermission(Permission.DELETE);
84  final boolean isRemoved = fileType.isRemoved();
85  final boolean isUsed = isRemoved && fileType.isUsed();
86  final boolean deletePermanentlyPermission = deletePermission && !isUsed;
87  JspContext jspContext = ExtensionsControl.createContext(dc, pageContext, guiContext, fileType);
88  ExtensionsInvoker invoker = ToolbarUtil.useExtensions(jspContext);
89  %>
90  <base:page title="<%=title%>">
91  <base:head scripts="tabcontrol.js" styles="toolbar.css,headertabcontrol.css,path.css,table.css">
92    <ext:scripts context="<%=jspContext%>" />
93    <ext:stylesheets context="<%=jspContext%>" />
94    <script language="JavaScript">
95    function editItem()
96    {
97      Main.viewOrEditItem('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>, true);
98    }
99    function deleteItem()
100    {
101      location.replace('index.jsp?ID=<%=ID%>&cmd=DeleteItem&item_id=<%=itemId%>');
102    }
103    function restoreItem()
104    {
105      location.replace('index.jsp?ID=<%=ID%>&cmd=RestoreItem&item_id=<%=itemId%>');
106    }
107    function deleteItemPermanently()
108    {
109      Main.deleteItemPermanently('<%=ID%>', true, '<%=itemType.name()%>', <%=itemId%>, '&callback=itemDeleted');
110    }
111    function itemDeleted()
112    {
113      Main.listItems('<%=ID%>', '<%=itemType.name()%>');
114    }
115    function showUsingItems()
116    {
117      Main.showUsingItems('<%=ID%>', '<%=itemType.name()%>', <%=itemId%>);
118    }
119    function runPlugin(cmd)
120    {
121      Main.openPopup('index.jsp?ID=<%=ID%>&cmd='+cmd+'&item_id=<%=itemId%>', 'RunPlugin'+cmd, 750, 500);
122    }
123    </script>
124  </base:head>
125  <base:body>
126    <p>
127    <p:path>
128      <p:pathelement title="Data file types" href="<%="index.jsp?ID="+ID%>" />
129      <p:pathelement title="<%=HTML.encodeTags(fileType.getName())%>" />
130    </p:path>
131   
132    <t:tabcontrol id="main" active="properties">
133    <t:tab id="properties" title="Properties">
134   
135    <tbl:toolbar
136      >
137      <tbl:button 
138        disabled="<%=writePermission ? false : true%>" 
139        image="edit.gif" 
140        onclick="editItem()" 
141        title="Edit&hellip;" 
142        tooltip="<%=writePermission ? "Edit this data file type" : "You do not have permission to edit this data file type"%>" 
143      />
144      <tbl:button 
145        disabled="<%=deletePermission ? false : true%>" 
146        image="delete.gif" 
147        onclick="deleteItem()" 
148        title="Delete"
149        visible="<%=!fileType.isRemoved()%>"
150        tooltip="<%=deletePermission ? "Delete this data file type" : "You do not have permission to delete this data file type"%>" 
151      />
152      <tbl:button 
153        disabled="<%=writePermission ? false : true%>" 
154        image="restore.gif" 
155        onclick="restoreItem()" 
156        title="Restore"
157        visible="<%=fileType.isRemoved()%>"
158        tooltip="<%=writePermission ? "Restore this data file type" : "You do not have permission to restore this data file type"%>" 
159      />
160      <tbl:button 
161        image="import.gif" 
162        onclick="runPlugin('ImportItem')" 
163        title="Import&hellip;" 
164        tooltip="Import data" 
165        visible="<%=pluginCount.containsKey(Plugin.MainType.IMPORT)%>"
166      />
167      <tbl:button 
168        image="export.gif" 
169        onclick="runPlugin('ExportItem')" 
170        title="Export&hellip;" 
171        tooltip="Export data" 
172        visible="<%=pluginCount.containsKey(Plugin.MainType.EXPORT)%>"
173      />
174      <tbl:button 
175        image="runplugin.gif" 
176        onclick="runPlugin('RunPlugin')" 
177        title="Run plugin&hellip;" 
178        tooltip="Run a plugin" 
179        visible="<%=pluginCount.containsKey(Plugin.MainType.OTHER)%>"
180      />
181      <ext:render extensions="<%=invoker%>" context="<%=jspContext%>" 
182        wrapper="<%=new PrefixSuffixRenderer(jspContext, "<td>", "</td>") %>"/>
183      <tbl:button
184        image="help.png"
185        onclick="<%="Main.openHelp('" + ID +"', 'datafiletype.view.properties')"%>"
186        title="Help&hellip;"
187        tooltip="Get help about this page"
188      />
189      </tbl:toolbar>
190    <div class="boxedbottom">
191      <div class="itemstatus">
192        Permissions on this item:
193        <i><%=PermissionUtil.getFullPermissionNames(fileType)%></i>
194      </div>
195      <%
196      if (fileType.isRemoved())
197      {
198        %>
199        <div class="itemstatus">
200          <base:icon 
201            image="<%=deletePermanentlyPermission ? "deleted.gif" : "deleted_disabled.gif"%>"
202            onclick="<%=deletePermanentlyPermission ? "deleteItemPermanently()" : null%>"
203            tooltip="<%=deletePermanentlyPermission ? "Permanently delete this item" : null%>"
204            visible="<%=isRemoved%>"> This item has been flagged for deletion<br></base:icon>
205          <base:icon image="used.gif" 
206            onclick="showUsingItems()"
207            tooltip="Show the items that are using this one"
208            visible="<%=isUsed%>"> This item is used by other items and can't be permanently deleted<br></base:icon>
209        </div>
210        <%
211      }
212      %>
213      <table class="form" cellspacing=0>
214      <tr>
215        <td class="prompt">Name</td>
216        <td><%=HTML.encodeTags(fileType.getName())%></td>
217      </tr>
218      <tr>
219        <td class="prompt">External ID</td>
220        <td><%=HTML.encodeTags(fileType.getExternalId())%></td>
221      </tr>
222      <tr>
223        <td class="prompt">Item type</td>
224        <td><%=fileType.getItemType()%></td>
225      </tr>
226      <tr>
227        <td class="prompt">File extension</td>
228        <td><%=HTML.encodeTags(fileType.getExtension())%></td>
229      </tr>
230      <tr>
231        <td class="prompt">Generic file type</td>
232        <td><base:propertyvalue item="<%=fileType%>" property="genericType" /></td>
233      </tr>
234      <tr >
235        <td class="prompt">Description</td>
236        <td><%=HTML.niceFormat(fileType.getDescription())%></td>
237      </tr>
238      </table>
239     
240      <%
241      ItemQuery<PlatformFileType> platformQuery = fileType.getPlatforms();
242      platformQuery.include(Include.ALL);
243      platformQuery.order(Orders.asc(Hql.property("platform.name")));
244      ItemResultList<PlatformFileType> platforms = platformQuery.list(dc);
245      if (platforms.size() == 0)
246      {
247        %>
248        <h4>Platforms</h4>
249        This file type is not used by any platforms or variants
250        (or, you don't have permission to view them).
251        <%
252      }
253      else
254      {
255        %>
256        <h4 class="docked">Used on platforms</h4>
257        <tbl:table
258          id="platforms"
259         
260          columns="all"
261          >
262        <tbl:columndef 
263          id="platform"
264          title="Platform"
265        />
266        <tbl:columndef 
267          id="variant"
268          title="Variant"
269        />
270        <tbl:columndef 
271          id="required"
272          title="Required"
273        />
274        <tbl:columndef 
275          id="multiple"
276          title="Multiple files"
277        />
278        <tbl:data>
279          <tbl:columns>
280          </tbl:columns>
281          <tbl:rows>
282          <%
283          for (PlatformFileType item : platforms)
284          {
285            Platform p = item.getPlatform();
286            PlatformVariant v = item.getVariant();
287            %>
288            <tbl:row>
289              <tbl:cell column="platform"><base:icon 
290                  image="deleted.gif" 
291                  tooltip="This item has been scheduled for deletion" 
292                  visible="<%=p.isRemoved()%>"
293                /><%=Base.getLinkedName(ID, p, false, true)%></tbl:cell>
294              <tbl:cell column="variant"><base:icon 
295                  image="deleted.gif" 
296                  tooltip="This item has been scheduled for deletion" 
297                  visible="<%=v!= null && v.isRemoved()%>"
298                /><%=v == null ? "<i>- all -</i>" : Base.getLinkedName(ID, v, false, true)%></tbl:cell>
299              <tbl:cell column="required"><%=item.isRequired() ? "yes" : "no"%></tbl:cell>
300              <tbl:cell column="multiple"><%=item.getAllowMultiple() ? "yes" : "no"%></tbl:cell>
301            </tbl:row>
302            <%
303          }
304          %>
305          </tbl:rows>
306        </tbl:data>
307        </tbl:table>
308        <%
309      }
310      %>
311      <jsp:include page="../../common/anytoany/list_anytoany.jsp">
312        <jsp:param name="ID" value="<%=ID%>" />
313        <jsp:param name="item_type" value="<%=itemType.name()%>" />
314        <jsp:param name="item_id" value="<%=itemId%>" />
315        <jsp:param name="title" value="Other items related to this file type" />
316      </jsp:include>
317     
318    </div>
319      </t:tab>
320      </t:tabcontrol>
321  </base:body>
322  </base:page>
323  <%
324}
325finally
326{
327  if (dc != null) dc.close();
328}
329
330%>
Note: See TracBrowser for help on using the repository browser.